Package org.jenkinsci.remoting.util
Class VersionNumber
- java.lang.Object
-
- org.jenkinsci.remoting.util.VersionNumber
-
- All Implemented Interfaces:
Comparable<VersionNumber>
public class VersionNumber extends Object implements Comparable<VersionNumber>
Immutable representation of a version number based on the Mercury version numbering scheme.VersionNumber
s areComparable
.Special tokens
We allow a component to be not just a number, but also "ea", "ea1", "ea2". "ea" is treated as "ea0", and eaN < M for any M < 0.
'*' is also allowed as a component, and '*' < M for any M < 0.
'SNAPSHOT' is also allowed as a component, and "N.SNAPSHOT" is interpreted as "N-1.*"
2.0.* < 2.0.1 < 2.0.1-SNAPSHOT < 2.0.0.99 < 2.0.0 < 2.0.ea < 2.0
This class is re-implemented in 1.415. The class was originally introduced in 1.139- Since:
- 1.139
- Author:
- Stephen Connolly (stephenc@apache.org), Kenney Westerhof (kenney@apache.org), Hervé Boutemy (hboutemy@apache.org)
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<VersionNumber>
DESCENDING
-
Constructor Summary
Constructors Constructor Description VersionNumber(String version)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(VersionNumber o)
boolean
equals(Object o)
int
getDigitAt(int idx)
Returns a digit (numeric component) by its position.int
hashCode()
boolean
isNewerThan(VersionNumber rhs)
boolean
isNewerThanOrEqualTo(VersionNumber rhs)
boolean
isOlderThan(VersionNumber rhs)
boolean
isOlderThanOrEqualTo(VersionNumber rhs)
String
toString()
-
-
-
Field Detail
-
DESCENDING
public static final Comparator<VersionNumber> DESCENDING
-
-
Constructor Detail
-
VersionNumber
public VersionNumber(String version)
-
-
Method Detail
-
compareTo
public int compareTo(VersionNumber o)
- Specified by:
compareTo
in interfaceComparable<VersionNumber>
-
isOlderThan
public boolean isOlderThan(VersionNumber rhs)
-
isNewerThan
public boolean isNewerThan(VersionNumber rhs)
-
isOlderThanOrEqualTo
public boolean isOlderThanOrEqualTo(VersionNumber rhs)
-
isNewerThanOrEqualTo
public boolean isNewerThanOrEqualTo(VersionNumber rhs)
-
getDigitAt
public int getDigitAt(int idx)
Returns a digit (numeric component) by its position. Once a non-numeric component is found all remaining components are also considered non-numeric by this method.- Parameters:
idx
- Digit position we want to retrieve starting by 0.- Returns:
- The digit or -1 in case the position does not correspond with a digit.
-
-