Class Version
java.lang.Object
de.iip_ecosphere.platform.support.Version
- All Implemented Interfaces:
Comparable<Version>
Artifact or service version. The format in terms of a pseudo "regular expression" number is
("." number)*.- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intCompares two versions considering null for both parameters and results in: -1 : this is smaller <=> given version and this is bigger.intCompares two versions and results in: -1 : this is smaller <=> given version and this is bigger.static booleanReturns whether two versions are equal.booleanintgetSegment(int index) Returns the version segment specified byindex.intReturns the number of the segments.inthashCode()static final booleanReturns whether the givenstringdenotes a version.toString()Returns a textual representation of this instance.
-
Field Details
-
PATTERN
-
SEPARATOR
- See Also:
-
segments
private int[] segments
-
-
Constructor Details
-
Version
Creates a new version by parsing a string.- Parameters:
version- the version string in form empty or i(.i)* with i integer numbers- Throws:
IllegalArgumentException- in case of format problems
-
Version
public Version(int... version) Version created from version segments.- Parameters:
version- version number segments (from left to right), withoutSEPARATOR
-
-
Method Details
-
isVersion
Returns whether the givenstringdenotes a version.- Parameters:
string- the string to be tested- Returns:
trueifstringis a version,falseelse
-
getSegmentCount
public int getSegmentCount()Returns the number of the segments.- Returns:
- the number of segments
-
getSegment
public int getSegment(int index) Returns the version segment specified byindex.- Parameters:
index- a 0-based index specifying the segment to be returned- Returns:
- the specified segment
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getSegmentCount()
-
compareTo
Compares two versions and results in: -1 : this is smaller <=> given version and this is bigger. 0 : given version and this are equal. +1 : this is bigger <=> given version is smaller.- Specified by:
compareToin interfaceComparable<Version>- Parameters:
version- version to compare.- Returns:
- result in {-1, 0, 1}.
-
toString
Returns a textual representation of this instance. -
equals
Returns whether two versions are equal.- Parameters:
version1- the first version instance (may be null)version2- the second version instance (may be null)- Returns:
trueifversion1equalsversion2,falseelse
-
compare
Compares two versions considering null for both parameters and results in: -1 : this is smaller <=> given version and this is bigger. 0 : given version and this are equal. +1 : this is bigger <=> given version is smaller.- Parameters:
version1- the first version to compare.version2- the second version to compare.- Returns:
- result in {-1, 0, 1}.
-
hashCode
public int hashCode() -
equals
-