Class Version

java.lang.Object
com.aquima.interactions.foundation.Version
All Implemented Interfaces:
Serializable, Comparable<Version>
Direct Known Subclasses:
CodeVersion

public class Version extends Object implements Serializable, Comparable<Version>
Simple class that holds a version identifier.

A version may consist three separate parts:

  • A major version Major version numbers are usually increased when substantial new functionality is added, or when a new version is not backward compatible with the previous.
  • A minor version The minor version is used to identify the revision of a certain product. Usually the minor version get updated when new Functionality is added, but the old functionality remains compatible with the previous version.
  • The patch version The patch version may hold any string, and is usually used to indicate a trivial change to the previous version. Patch versions get updated when small changes or bug fixes occur that have no impact on compatibility.
Since:
5.0
Author:
o.kerpershoek
See Also:
  • Field Details

    • ANY

      public static final Version ANY
    • DEFAULT

      public static final Version DEFAULT
  • Constructor Details

    • Version

      public Version(int major, int minor, String patch, String label)
      Constructs a version object from a major, minor and patch identifier. The patch identifier is optional, and as such the value null is allowed.
      Parameters:
      major - The major version number.
      minor - The minor version number.
      patch - Identifier of the patch for the specified major and minor version.
      label - Optional label for the version which may be used as display text.
  • Method Details

    • valueOf

      public static Version valueOf(String strVersion)
      This method will try to convert the passed version string to a Version object.

      There are three possible results of this method:

      • A null value when the passed string was null or empty.
      • An IllegalArgumentExceptionwhen the passed string does not conform to the version syntax.
      • A valid Version object containing the version string information.

      This method will ignore (strip) excessive whitespace characters at the start and end.

      Parameters:
      strVersion - string containing the version information.
      Returns:
      A valid Version object, or null when the passed version string was empty.
    • valueOf

      public static Version valueOf(String strVersion, String label)
      This method will try to convert the passed version string to a Version object.

      There are three possible results of this method:

      • A null value when the passed string was null or empty.
      • An IllegalArgumentExceptionwhen the passed string does not conform to the version syntax.
      • A valid Version object containing the version string information.

      This method will ignore (strip) excessive whitespace characters at the start and end.

      Parameters:
      strVersion - string containing the version information.
      label - Optional label for the version which may be used as display text.
      Returns:
      A valid Version object, or null when the passed version string was empty.
    • formatPatch

      protected String formatPatch(String patch)
    • getMajor

      public int getMajor()
      This method returns the major number of the version.
      Returns:
      the major number of the version.
    • getMinor

      public int getMinor()
      This method returns the minor number of the version.
      Returns:
      the minor number of the version.
    • getPatch

      public String getPatch()
      This method returns the patch identifier of the version.
      Returns:
      the patch identifier of the version.
    • getLabel

      public String getLabel()
      This method returns the (optional) label of the version. A label may be used as a display value for the version. The label could for instance contain a name instead of the (cryptic) version number.
      Returns:
      The label for the version, or null if no label was defined.
    • hashCode

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

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

      public int compareTo(Version other)
      Specified by:
      compareTo in interface Comparable<Version>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getString

      public String getString()
      The getString method will print the version in a nice readable format. The major and minor version are always printed using a dot as seperator. When the patch number is available, it will be appended. Depending on the format of the patch, an additional dot may be added between the minor version and the patch version.

      Examples:

      • 5.0
      • 1.0-b
      • 2.3.12
      • 5.0.1-alpha
      Returns:
      String containing a formatted version