public class Version extends Object implements Comparable<Version>
Here is the grammar for version strings:
version ::= major('.'minor('.'micro('.'nano)?)?)? major ::= [0-9]+ minor ::= [0-9]+ micro ::= [0-9]+ nano ::= [0-9]+
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private String |
original |
private int[] |
parts |
static Pattern |
VERSION_PATTERN |
Constructor and Description |
---|
Version(String version)
Created a version identifier from the specified string.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version object)
Compares this
Version object to another object. |
boolean |
equals(Object object)
Compares this
Version object to another object. |
int |
hashCode() |
String |
toString()
Returns the original string representation of this version identifier.
|
public static final Pattern VERSION_PATTERN
private final String original
private final int[] parts
public Version(String version)
version
- String representation of the version identifier.IllegalArgumentException
- If version
is improperly
formatted.public String toString()
public boolean equals(Object object)
Version
object to another object.
A version is considered to be equal to another version if all the parts are equal.
public int compareTo(Version object)
Version
object to another object.
The comparison considers each of the parts (major, minor, micro, nano) in turn, comparing like with like. At any point the comparison is not equal, a result is known.
compareTo
in interface Comparable<Version>
object
- The Version
object to be compared.Version
object.ClassCastException
- If the specified object is not a Version
.