Package org.europa.together.domain
Class Version
java.lang.Object
org.europa.together.domain.Version
- All Implemented Interfaces:
Comparable<Version>
Data class for program version numbers, based on semantic versioning. This
implementation allwos to compare and sort version numbers.
Pattern: Major.Minor.Patch-Label (Patch and Label are optional)
A version of a software artifact is always uniqe. Artifacts can have different versions (1:n relation). That means when an artifact a exist two times and both are not identical, the first artifact has a different version than the second artifact. Both artifacts can not have the same version. If both artifacts with the same name have the same version it is impossible to distinguish them.
Pattern: Major.Minor.Patch-Label (Patch and Label are optional)
true: equals(1.2.3-SNAPSHOT : 1.2.3-SNAPSHOT);
true: equals(1.2.3-LABLE : 1.2.3-SNAPSHOT);
true: equals(1.0 : 1.0.0);
false: equals(1.0 : 1.0.1);
false: equals(1.0-LABEL : 1.0);
A greater B: compareTo(2.0 : 1.0);
A greater B: compareTo(1.1 : 1.0);
A greater B: compareTo(1.0.1 : 1.0.0);
A greater B: compareTo(2.1 : 1.1);
A equal B: compareTo(2.1.1 : 2.1.1-SNAPSHOT);
The only recomennded label is SNAPSHOT, because labels are not part
of comparing.
Definition:A version of a software artifact is always uniqe. Artifacts can have different versions (1:n relation). That means when an artifact a exist two times and both are not identical, the first artifact has a different version than the second artifact. Both artifacts can not have the same version. If both artifacts with the same name have the same version it is impossible to distinguish them.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
getLabel()
Return the Label section of a version number as String.int
getMajor()
Return the Major section of a version number as int.int
getMinor()
Return the Minor section of a version number as int.int
getPatch()
Return the Patch level section of a version number as int.Return the whole version number as String.int
hashCode()
toString()
-
Constructor Details
-
Version
Constructor.- Parameters:
version
- as String- Throws:
MisconfigurationException
-
-
Method Details
-
getMajor
public int getMajor()Return the Major section of a version number as int. MANDANTORY.- Returns:
- Major as int
-
getMinor
public int getMinor()Return the Minor section of a version number as int. MANDANTORY.- Returns:
- Minor as int
-
getPatch
public int getPatch()Return the Patch level section of a version number as int. OPTIONAL. If the patch level not exist the method return -1.- Returns:
- Patch as int
-
getLabel
Return the Label section of a version number as String. OPTIONAL. If the label not exist the method return an empty String.- Returns:
- Label as String
-
getVersion
Return the whole version number as String.- Returns:
- version as String
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Version>
-
equals
-
hashCode
public int hashCode() -
toString
-