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 intcompareTo(Version that)booleanequals(Object o)intgetMajor()Returns the major version number.intgetMinor()Returns the minor version number.inthashCode()booleanisCompatibleWith(Version that)Returnsfalseif: the MAJOR version numbers are not the same.StringtoString()static Versionversion(int major)Creates a new version using the provided version information and a minor.static Versionversion(int major, int minor)Creates a new version using the provided version information.static Versionversion(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-nullstring 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:
compareToin interfaceComparable<Version>
-
isCompatibleWith
public boolean isCompatibleWith(Version that)
Returnsfalseif:- the MAJOR version numbers are not the same.
-
the MAJOR version numbers are the same but
thisMINOR version number is LOWER thanthatMINOR 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- TheVersionto match against.- Returns:
trueif both MAJOR version numbers are the same and ifthisMINOR version number is HIGHER thanthatMINOR version number.
-
-