Class Version

java.lang.Object
sonia.scm.version.Version
All Implemented Interfaces:
Comparable<Version>

public final class Version extends Object implements Comparable<Version>
Version object for comparing and parsing versions.
  • Method Details

    • parse

      public static Version parse(String versionString)
      Creates a new version of the given string.
      Parameters:
      versionString - string representation of the version
      Returns:
      version object
    • compareTo

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

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

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

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

      public int getMajor()
      Returns the major part of the version.
    • getMinor

      public int getMinor()
      Returns the minor part of the version.
    • getParsedVersion

      public String getParsedVersion()
      Returns the string representation of the parsed version.
    • getPatch

      public int getPatch()
      Returns the patch part of the version.
    • getType

      public VersionType getType()
      Returns the version type (alpha, beta, milestone, etc.) of the version.
      Returns:
      version type
    • getTypeVersion

      public int getTypeVersion()
      Returns the version of the type e.g. beta-1 would return 1.
      Returns:
      version of the type
    • getUnparsedVersion

      public String getUnparsedVersion()
      Returns the unparsed string representation of the version.
    • isNewer

      public boolean isNewer(Version o)
      Returns true if the given version is newer.
    • isNewer

      public boolean isNewer(String versionString)
      Returns true if the given version is newer.
    • isNewerOrEqual

      public boolean isNewerOrEqual(String versionString)
      Returns true if the given version is newer or equal.
      Since:
      2.4.0
    • isNewerOrEqual

      public boolean isNewerOrEqual(Version o)
      Returns true if the given version is newer or equal.
      Since:
      2.4.0
    • isOlder

      public boolean isOlder(Version o)
      Returns true if the given version is older.
    • isOlder

      public boolean isOlder(String versionString)
      Returns true if the given version is older.
    • isOlderOrEqual

      public boolean isOlderOrEqual(String versionString)
      Returns true if the given version is older or equal.
      Since:
      2.4.0
    • isOlderOrEqual

      public boolean isOlderOrEqual(Version o)
      Returns true if the given version is older or equal.
      Since:
      2.4.0
    • isSnapshot

      public boolean isSnapshot()
      Returns true if the version is a snapshot.