public final class GenericVersionScheme extends Object implements VersionScheme
This scheme accepts versions of any form, interpreting a version as a sequence of numeric and alphabetic segments. The characters '-', '_', and '.' as well as the mere transitions from digit to letter and vice versa delimit the version segments. Delimiters are treated as equivalent.
Numeric segments are compared mathematically, alphabetic segments are compared lexicographically and case-insensitively. However, the following qualifier strings are recognized and treated specially: "alpha" = "a" < "beta" = "b" < "milestone" = "m" < "cr" = "rc" < "snapshot" < "final" = "ga" < "sp". All of those well-known qualifiers are considered smaller/older than other strings. An empty segment/string is equivalent to 0.
In addition to the above mentioned qualifiers, the tokens "min" and "max" may be used as final version segment to denote the smallest/greatest version having a given prefix. For example, "1.2.min" denotes the smallest version in the 1.2 line, "1.2.max" denotes the greatest version in the 1.2 line. A version range of the form "[M.N.*]" is short for "[M.N.min, M.N.max]".
Numbers and strings are considered incomparable against each other. Where version segments of different kind would collide, comparison will instead assume that the previous segments are padded with trailing 0 or "ga" segments, respectively, until the kind mismatch is resolved, e.g. "1-alpha" = "1.0.0-alpha" < "1.0.1-ga" = "1.0.1".
| Constructor and Description |
|---|
GenericVersionScheme()
Creates a new instance of the version scheme for parsing versions.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
Version |
parseVersion(String version) |
VersionConstraint |
parseVersionConstraint(String constraint) |
VersionRange |
parseVersionRange(String range) |
public GenericVersionScheme()
public Version parseVersion(String version) throws InvalidVersionSpecificationException
parseVersion in interface VersionSchemeInvalidVersionSpecificationExceptionpublic VersionRange parseVersionRange(String range) throws InvalidVersionSpecificationException
parseVersionRange in interface VersionSchemeInvalidVersionSpecificationExceptionpublic VersionConstraint parseVersionConstraint(String constraint) throws InvalidVersionSpecificationException
parseVersionConstraint in interface VersionSchemeInvalidVersionSpecificationExceptionCopyright © 2010–2022 The Apache Software Foundation. All rights reserved.