Package org.forgerock.openig.tools.am
Class Version
- java.lang.Object
-
- org.forgerock.openig.tools.am.Version
-
- All Implemented Interfaces:
Comparable<Version>
- Direct Known Subclasses:
AmVersion
public class Version extends Object implements Comparable<Version>
Supports version with the following format: major[.minor[.micro]].Components described as follows:
- major: positive integer, mandatory, the major version number (such as 5 or 13)
- minor: positive integer, optional, the minor version number
- micro: positive integer, optional, the micro version number
This class implements the
Comparable
interface in order to ease natural ordering of versions. Note that qualifier is not part of the comparison.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Version(int major, int minor, int micro)
Constructs a new Version from its given components.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Predicate<Version>
between(Version minInclusive, Version maxInclusive)
Returns a predicate that verifies if this version is in between the givenminInclusive
andmaxInclusive
versions (inclusive).int
compareTo(Version o)
boolean
equals(Object o)
static Predicate<Version>
equalTo(Version version)
Returns a predicate that verifies strict equality.static Predicate<Version>
greaterThan(Version version)
Returns a predicate that verifies if this version is strictly greater than the givenversion
.static Predicate<Version>
greaterThanOrEqualTo(Version version)
Returns a predicate that verifies if this version is greater or equal to the givenversion
.int
hashCode()
boolean
is(Predicate<Version> predicate)
Returnstrue
if this version satisfy the given predicate.static Predicate<Version>
lowerThan(Version version)
Returns a predicate that verifies if this version is strictly lower than the givenversion
.static Predicate<Version>
lowerThanOrEqualTo(Version version)
Returns a predicate that verifies if this version is lower or equal to the givenversion
.int
major()
Returns major component of the version.int
micro()
Returns micro component of the version.int
minor()
Returns minor component of the version.static Version
of(String in)
Parse an input string, decomposing it in its base elements (major, minor, micro).static Predicate<Version>
strictlyBetween(Version minExclusive, Version maxExclusive)
Returns a predicate that verifies if this version is in between the givenminExclusive
andmaxExclusive
versions (exclusive).String
toString()
static Version
v(int major)
Builds a version from its components (minor set to0
, micro set to0
, no qualifier).static Version
v(int major, int minor)
Builds a version from its components (micro set to0
, no qualifier).static Version
v(int major, int minor, int micro)
Builds a version from its components.
-
-
-
Method Detail
-
of
public static Version of(String in)
Parse an input string, decomposing it in its base elements (major, minor, micro).- Parameters:
in
- version as a string- Returns:
- the corresponding version
-
v
public static Version v(int major)
Builds a version from its components (minor set to0
, micro set to0
, no qualifier).- Parameters:
major
- major version number- Returns:
- a version
-
v
public static Version v(int major, int minor)
Builds a version from its components (micro set to0
, no qualifier).- Parameters:
major
- major version numberminor
- minor version number- Returns:
- a version
-
v
public static Version v(int major, int minor, int micro)
Builds a version from its components.- Parameters:
major
- major version numberminor
- minor version numbermicro
- micro version number- Returns:
- a version
-
major
public int major()
Returns major component of the version.- Returns:
- major component of the version.
-
minor
public int minor()
Returns minor component of the version.- Returns:
- minor component of the version.
-
micro
public int micro()
Returns micro component of the version.- Returns:
- micro component of the version.
-
is
public boolean is(Predicate<Version> predicate)
Returnstrue
if this version satisfy the given predicate.- Parameters:
predicate
- the assertion tested against this version- Returns:
- true if the assertion is satisfied, false otherwise
-
equalTo
public static Predicate<Version> equalTo(Version version)
Returns a predicate that verifies strict equality.- Parameters:
version
- expected version- Returns:
- a predicate that verifies strict equality.
-
greaterThan
public static Predicate<Version> greaterThan(Version version)
Returns a predicate that verifies if this version is strictly greater than the givenversion
.- Parameters:
version
- expected version- Returns:
- a predicate that verifies if this version is strictly greater than the given
version
.
-
greaterThanOrEqualTo
public static Predicate<Version> greaterThanOrEqualTo(Version version)
Returns a predicate that verifies if this version is greater or equal to the givenversion
.- Parameters:
version
- expected version- Returns:
- a predicate that verifies if this version is greater or equal to the given
version
.
-
lowerThan
public static Predicate<Version> lowerThan(Version version)
Returns a predicate that verifies if this version is strictly lower than the givenversion
.- Parameters:
version
- expected version- Returns:
- a predicate that verifies if this version is strictly lower than the given
version
.
-
lowerThanOrEqualTo
public static Predicate<Version> lowerThanOrEqualTo(Version version)
Returns a predicate that verifies if this version is lower or equal to the givenversion
.- Parameters:
version
- expected version- Returns:
- a predicate that verifies if this version is lower or equal to the given
version
.
-
between
public static Predicate<Version> between(Version minInclusive, Version maxInclusive)
Returns a predicate that verifies if this version is in between the givenminInclusive
andmaxInclusive
versions (inclusive).- Parameters:
minInclusive
- minimum versionmaxInclusive
- maximum version- Returns:
- a predicate that verifies if this version is in between the given versions (inclusive)
-
strictlyBetween
public static Predicate<Version> strictlyBetween(Version minExclusive, Version maxExclusive)
Returns a predicate that verifies if this version is in between the givenminExclusive
andmaxExclusive
versions (exclusive).- Parameters:
minExclusive
- minimum versionmaxExclusive
- maximum version- Returns:
- a predicate that verifies if this version is in between the given versions (exclusive)
-
compareTo
public int compareTo(Version o)
- Specified by:
compareTo
in interfaceComparable<Version>
-
-