Package org.forgerock.http.routing
Class Version
- java.lang.Object
-
- org.forgerock.http.routing.Version
-
- All Implemented Interfaces:
Comparable<Version>
public final class Version extends Object implements Comparable<Version>
Represents some version in the form majorNumber.minorNumber, for instance 2.4.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Version that)
boolean
equals(Object o)
int
getMajor()
Returns the major version number.int
getMinor()
Returns the minor version number.int
hashCode()
boolean
isCompatibleWith(Version that)
Returnsfalse
if: the MAJOR version numbers are not the same.String
toString()
static Version
version(int major)
Creates a new version using the provided version information and a minor.static Version
version(int major, int minor)
Creates a new version using the provided version information.static Version
version(String s)
Parses the string argument as a version.
-
-
-
Method Detail
-
version
public static Version version(int major, int minor)
Creates a new version using the provided version information.- Parameters:
major
- Major version number.minor
- Minor version number.- Returns:
- The version.
-
version
public static Version version(int major)
Creates a new version using the provided version information and a minor.- Parameters:
major
- Major version number.- Returns:
- The version.
-
version
public static Version version(String s)
Parses the string argument as a version. The string must be one of the following forms:major major.minor
- Parameters:
s
- The non-null
string to be parsed as a version.- Returns:
- The parsed version.
- Throws:
IllegalArgumentException
- If the string does not contain a parsable version.
-
getMajor
public int getMajor()
Returns the major version number.- Returns:
- The major version number.
-
getMinor
public int getMinor()
Returns the minor version number.- Returns:
- The minor version number.
-
compareTo
public int compareTo(Version that)
- Specified by:
compareTo
in interfaceComparable<Version>
-
isCompatibleWith
public boolean isCompatibleWith(Version that)
Returnsfalse
if:- the MAJOR version numbers are not the same.
-
the MAJOR version numbers are the same but
this
MINOR version number is LOWER thanthat
MINOR version number.
i.e. this version number - "2.0", that version number - "2.1" WILL NOT match, but this version number - "2.4", that version number - "2.1" WILL match. In other words, verifies ascending compatibility.
- Parameters:
that
- TheVersion
to match against.- Returns:
true
if both MAJOR version numbers are the same and ifthis
MINOR version number is HIGHER thanthat
MINOR version number.
-
-