java.lang.Object
net.ssehub.easy.basics.modelManagement.Version
All Implemented Interfaces:
Comparable<Version>

public class Version extends Object implements Comparable<Version>
Represents the version of an import.
Author:
Marcel Lueder, Holger Eichelberger, Pastusch
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Version
     
    private static final Pattern
     
    private int[]
     
    private static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Represents the null-Version (not given).
     
    Version(int... version)
    Constructor of the version class.
     
    Version(String version)
    Creates a new version by parsing a string.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    int
    compareTo(Version version)
    Compares two versions and results in: -1 : this is smaller <=> given version and this is bigger.
    boolean
     
    static boolean
    equals(Version version1, Version version2)
    Returns whether two versions are equal.
    Returns a version that is one higher in the first segment than the actual version.
    int
    getSegment(int index)
    Returns the version segment specified by index.
    int
    Returns the number of the segments.
    Returns the version in a textual form.
    int
     
    static final boolean
    isVersion(String string)
    Returns whether the given string denotes a version.
    Returns a textual representation of this instance.
    static String
    toString(Version version)
    Returns the textual version of version (null-safe).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NULL_VALUE

      public static final Version NULL_VALUE
    • PATTERN

      private static final Pattern PATTERN
    • SEPARATOR

      private static final String SEPARATOR
      See Also:
    • segments

      private int[] segments
  • Constructor Details

    • Version

      private Version()
      Represents the null-Version (not given).
    • Version

      public Version(String version) throws VersionFormatException
      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

      public static final boolean isVersion(String string)
      Returns whether the given string denotes a version.
      Parameters:
      string - the string to be tested
      Returns:
      trueif string is a version, false else
    • getVersion

      public 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 by index.
      Parameters:
      index - a 0-based index specifying the segment to be returned
      Returns:
      the specified segment
      Throws:
      IndexOutOfBoundsException - if index<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:
      compareTo in interface Comparable<Version>
      Parameters:
      version - version to compare.
      Returns:
      result in {-1, 0, 1}.
    • toString

      public String toString()
      Returns a textual representation of this instance.
      Overrides:
      toString in class Object
      Returns:
      a textual representation
    • toString

      public static String toString(Version version)
      Returns the textual version of version (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:
      true if version1 equals version2, false else
    • 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:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object