Class Version
- java.lang.Object
-
- net.ssehub.easy.basics.modelManagement.Version
-
-
Field Summary
Fields Modifier and Type Field Description static VersionNULL_VALUEprivate static java.util.regex.PatternPATTERNprivate int[]segmentsprivate static java.lang.StringSEPARATOR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcompare(Version version1, Version version2)Compares two versions considering null for both parameters and results in: -1 : this is smaller <=> given version and this is bigger.intcompareTo(Version version)Compares two versions and results in: -1 : this is smaller <=> given version and this is bigger.booleanequals(java.lang.Object obj)static booleanequals(Version version1, Version version2)Returns whether two versions are equal.VersiongetIncrementedVersion()Returns a version that is one higher in the first segment than the actual version.intgetSegment(int index)Returns the version segment specified byindex.intgetSegmentCount()Returns the number of the segments.java.lang.StringgetVersion()Returns the version in a textual form.inthashCode()static booleanisVersion(java.lang.String string)Returns whether the givenstringdenotes a version.java.lang.StringtoString()Returns a textual representation of this instance.static java.lang.StringtoString(Version version)Returns the textual version ofversion(null-safe).
-
-
-
Field Detail
-
NULL_VALUE
public static final Version NULL_VALUE
-
PATTERN
private static final java.util.regex.Pattern PATTERN
-
SEPARATOR
private static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
segments
private int[] segments
-
-
Constructor Detail
-
Version
private Version()
Represents the null-Version (not given).
-
Version
public Version(java.lang.String version) throws VersionFormatExceptionCreates 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 Detail
-
isVersion
public static final boolean isVersion(java.lang.String string)
Returns whether the givenstringdenotes a version.- Parameters:
string- the string to be tested- Returns:
trueifstringis a version,falseelse
-
getVersion
public java.lang.String 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:
java.lang.IndexOutOfBoundsException- ifindex<0 || index>=getSegmentCount()
-
compareTo
public int compareTo(Version version)
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 interfacejava.lang.Comparable<Version>- Parameters:
version- version to compare.- Returns:
- result in {-1, 0, 1}.
-
toString
public java.lang.String toString()
Returns a textual representation of this instance.- Overrides:
toStringin classjava.lang.Object- Returns:
- a textual representation
-
toString
public static java.lang.String toString(Version version)
Returns the textual version ofversion(null-safe).- Parameters:
version- the version to be converted into text- Returns:
- the textual representation
-
equals
public static boolean equals(Version version1, Version version2)
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
public static int compare(Version version1, Version version2)
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
public Version getIncrementedVersion() throws VersionFormatException
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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-