public static class RuntimeMetaData.DefaultListener extends java.lang.Object implements RuntimeMetaData.Listener
RuntimeMetaData.Listener
which
responds to mismatched versions by throwing the provided
RuntimeMetaData.VersionMismatchException
if the reported version mismatch
indicates the versions differ by more than the major and
minor version components.
For example, version strings x.y and x.y.z are considered "compatible", and this listener will not throw an exception. Likewise, version strings x.y-SNAPSHOT and x.y.z are considered "compatible" because the major and minor components x.y are the same in each.
For the purposes of this listener, version numbers are assumed to have the form major.minor.patch.revision-suffix, with the individual components defined as follows.
4
for ANTLR 4..
(dot) appearing before it is
also omitted..
(dot) appearing before it is also omitted.-
(hyphen-minus) appearing before it is also
omitted.Modifier and Type | Field and Description |
---|---|
static RuntimeMetaData.DefaultListener |
INSTANCE
A default instance of
RuntimeMetaData.DefaultListener which is automatically
registered to receive version mismatch events. |
Constructor and Description |
---|
RuntimeMetaData.DefaultListener() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
isMinorVersionMatch(RuntimeMetaData.VersionMismatchException ex)
Determines if the reported version mismatch are a match when
considering only the major and minor version
components of the version strings.
|
void |
reportVersionMismatch(RuntimeMetaData.VersionMismatchException ex)
Report a version mismatch which was detected by
RuntimeMetaData.checkVersion(java.lang.String, java.lang.String) . |
public static final RuntimeMetaData.DefaultListener INSTANCE
RuntimeMetaData.DefaultListener
which is automatically
registered to receive version mismatch events.public void reportVersionMismatch(@NotNull RuntimeMetaData.VersionMismatchException ex) throws RuntimeMetaData.VersionMismatchException
RuntimeMetaData.checkVersion(java.lang.String, java.lang.String)
.
Implementations of this method may, but are not required to, throw the provided exception. Note that if a registered listener throws the provided exception during the handling of this event, the following will be impacted:
RuntimeMetaData.checkVersion(java.lang.String, java.lang.String)
will be
unusable due to throwing an exception in a static initializer
block.RuntimeMetaData.DefaultListener
instance
is always the last listener called (unless it is unregistered), it
will not affect the execution of any other registered listeners, even
in the case where it throws an exception.
The default implementation only throws an exception when the reported
version mismatch contains a mismatched major or
minor version component. For details about the syntax of the
input version
, see the documentation for
RuntimeMetaData.DefaultListener
.
reportVersionMismatch
in interface RuntimeMetaData.Listener
ex
- a RuntimeMetaData.VersionMismatchException
instance containing
detailed information about the specific version mismatch detectedRuntimeMetaData.VersionMismatchException
protected boolean isMinorVersionMatch(@NotNull RuntimeMetaData.VersionMismatchException ex)
ex
- a RuntimeMetaData.VersionMismatchException
instance containing
detailed information about the specific version mismatch detectedtrue
if the major and minor version
components of the version strings match; otherwise, false
.