Class Version
java.lang.Object
nl.colorize.util.Version
- All Implemented Interfaces:
Comparable<Version>
Represents a version number with arbitrary precision. Examples of version
numbers that can be represented by this class are "1.0" and "1.6.0b31".
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true ifversionStringrepresents a version number that can be represented by this class.intCompares this version number toother.intCompares this version number toother, considering only the first N digits.booleaninthashCode()booleanbooleanisNewerThan(Version other) booleanisOlderThan(Version other) booleanstatic VersionParses a version number from the specified version string.toString()Returns the version string that is represented by this object.truncate(int maxDigits) Returns a newVersioninstance that is a truncated version of this one.
-
Field Details
-
UNKNOWN
-
-
Method Details
-
compareTo
Compares this version number toother. This will return one of the following values:- 1 if this version is newer than
other - -1 if this version is older than
other - 0 if both versions are equal
- Specified by:
compareToin interfaceComparable<Version>
- 1 if this version is newer than
-
compareTo
Compares this version number toother, considering only the first N digits. For example, comparing "1.0.0" and "1.0.2" will return 1 with a precision of 3 digits, but 0 with a precision of 2 digits.- Throws:
IllegalArgumentException- ifprecisionis 0 or less.
-
isAtLeast
-
isNewerThan
-
isOlderThan
-
truncate
Returns a newVersioninstance that is a truncated version of this one. For example, truncating the version number 1.2.3 to 2 digits will return 1.2. Truncating a version number that contains textual suffixes will remove those suffixes.- Throws:
IllegalArgumentException- if there is not at least 1 digit left.
-
isUnknown
public boolean isUnknown() -
equals
-
hashCode
-
toString
-
parse
Parses a version number from the specified version string.- Throws:
IllegalArgumentException- if the version string cannot be parsed.
-
canParse
Returns true ifversionStringrepresents a version number that can be represented by this class. In other words, this method indicates whetherparse(String)will throw an exception if invoked withversionString.
-