public final class Version extends Object implements Comparable<Version>
Version("5", "*").compareTo(Version("5.0", "*") == 0
Version("5", "*").equals(Version("5.0", "*") == false;
The concrete versions produced by toMinimumVersion() and toMaximumVersion()
do have consistent compareTo()/equals() behavior, as these versions are
guaranteed to not contain wildcards.Modifier and Type | Field and Description |
---|---|
static Range<Version> |
ALL_VERSIONS
A range of versions from MIN_VERSION to MAX_VERSION.
|
static Version |
MAX_VERSION
A constant value holding a maximum upper bound for versions.
|
static Version |
MIN_VERSION
A constant value holding the minimum value a version can have: 0.
|
Constructor and Description |
---|
Version(String version)
Creates a Version instance from the dot-separated Version String using null as the padding
|
Version(String version,
String versionPadding)
Creates a Version instance from the dot-separated Version String and the
versionPadding.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version otherVersion)
When comparing Versions, each version
subsection is compared from left to right.
|
boolean |
equals(Object o) |
int |
hashCode() |
Version |
toMaximumVersion()
Converts this Version to an equivalent "maximum" instance.
|
Version |
toMinimumVersion()
Converts this Version to an equivalent "minimum" instance.
|
String |
toString() |
public static final Version MIN_VERSION
public static final Version MAX_VERSION
public Version(String version)
version
- The dot-separated version to representNullPointerException
- if the version is nullIllegalArgumentException
- if the version is an empty StringVersion(String, String)
public Version(String version, String versionPadding)
version
- The dot-separated version to representversionPadding
- The value to return for sub-version sections
requested beyond the sub-version sections present in the version String.
If null or empty, no padding will be performed.NullPointerException
- if version is nullIllegalArgumentException
- if version is the empty Stringpublic int compareTo(Version otherVersion)
compareTo
in interface Comparable<Version>
otherVersion
- The Version object to compare this Version Object withpublic Version toMinimumVersion()
public Version toMaximumVersion()
Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.