Class Version

java.lang.Object
org.europa.together.domain.Version
All Implemented Interfaces:
Comparable<Version>

public class Version extends Object implements 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)
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 Details

  • 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

      public String 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

      public String getVersion()
      Return the whole version number as String.
      Returns:
      version as String
    • compareTo

      public int compareTo(Version o)
      Specified by:
      compareTo in interface Comparable<Version>
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object