Class Version
java.lang.Object
net.ssehub.easy.basics.modelManagement.Version
- All Implemented Interfaces:
Comparable<Version>
Represents the version of an import.
- Author:
- Marcel Lueder, Holger Eichelberger, Pastusch
-
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.booleanstatic booleanReturns whether two versions are equal.Returns a version that is one higher in the first segment than the actual version.intgetSegment(int index) Returns the version segment specified byindex.intReturns the number of the segments.Returns the version in a textual form.inthashCode()static final booleanReturns whether the givenstringdenotes a version.toString()Returns a textual representation of this instance.static StringReturns the textual version ofversion(null-safe).
-
Field Details
-
NULL_VALUE
-
PATTERN
-
SEPARATOR
- See Also:
-
segments
private int[] segments
-
-
Constructor Details
-
Version
private Version()Represents the null-Version (not given). -
Version
Creates a new version by parsing a string.- Parameters:
version- the version string in form i(.i)* with i integer numbers- Throws:
VersionFormatException- in case of format problems
-
Version
public Version(int... version) Constructor of the version class.- Parameters:
version- Version number
-
-
Method Details
-
isVersion
Returns whether the givenstringdenotes a version.- Parameters:
string- the string to be tested- Returns:
trueifstringis a version,falseelse
-
getVersion
Returns the version in a textual form.- Returns:
- the version in textual form
-
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. -
toString
Returns the textual version ofversion(null-safe).- Parameters:
version- the version to be converted into text- Returns:
- the textual representation
-
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}.
-
getIncrementedVersion
Returns a version that is one higher in the first segment than the actual version.- Returns:
- A version that is increased by one in the first segment.
- Throws:
VersionFormatException- in case of format problems.
-
hashCode
public int hashCode() -
equals
-