Class Version

java.lang.Object
org.forgerock.openig.tools.am.Version
All Implemented Interfaces:
Comparable<Version>
Direct Known Subclasses:
AmVersion

public class Version extends Object implements Comparable<Version>
Supports version with the following format: major[.minor[.micro]].

Components described as follows:

  • major: positive integer, mandatory, the major version number (such as 5 or 13)
  • minor: positive integer, optional, the minor version number
  • micro: positive integer, optional, the micro version number

This class implements the Comparable interface in order to ease natural ordering of versions. Note that qualifier is not part of the comparison.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Version(int major, int minor, int micro)
    Constructs a new Version from its given components.
  • Method Summary

    Modifier and Type
    Method
    Description
    between(Version minInclusive, Version maxInclusive)
    Returns a predicate that verifies if this version is in between the given minInclusive and maxInclusive versions (inclusive).
    int
     
    boolean
     
    equalTo(Version version)
    Returns a predicate that verifies strict equality.
    Returns a predicate that verifies if this version is strictly greater than the given version.
    Returns a predicate that verifies if this version is greater or equal to the given version.
    int
     
    boolean
    is(Predicate<Version> predicate)
    Returns true if this version satisfy the given predicate.
    lowerThan(Version version)
    Returns a predicate that verifies if this version is strictly lower than the given version.
    Returns a predicate that verifies if this version is lower or equal to the given version.
    int
    Returns major component of the version.
    int
    Returns micro component of the version.
    int
    Returns minor component of the version.
    static Version
    of(String in)
    Parse an input string, decomposing it in its base elements (major, minor, micro).
    strictlyBetween(Version minExclusive, Version maxExclusive)
    Returns a predicate that verifies if this version is in between the given minExclusive and maxExclusive versions (exclusive).
     
    static Version
    v(int major)
    Builds a version from its components (minor set to 0, micro set to 0, no qualifier).
    static Version
    v(int major, int minor)
    Builds a version from its components (micro set to 0, no qualifier).
    static Version
    v(int major, int minor, int micro)
    Builds a version from its components.

    Methods inherited from class java.lang.Object

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

    • Version

      protected Version(int major, int minor, int micro)
      Constructs a new Version from its given components.
      Parameters:
      major - major version number
      minor - minor version number
      micro - micro version number
  • Method Details

    • of

      public static Version of(String in)
      Parse an input string, decomposing it in its base elements (major, minor, micro).
      Parameters:
      in - version as a string
      Returns:
      the corresponding version
    • v

      public static Version v(int major)
      Builds a version from its components (minor set to 0, micro set to 0, no qualifier).
      Parameters:
      major - major version number
      Returns:
      a version
    • v

      public static Version v(int major, int minor)
      Builds a version from its components (micro set to 0, no qualifier).
      Parameters:
      major - major version number
      minor - minor version number
      Returns:
      a version
    • v

      public static Version v(int major, int minor, int micro)
      Builds a version from its components.
      Parameters:
      major - major version number
      minor - minor version number
      micro - micro version number
      Returns:
      a version
    • major

      public int major()
      Returns major component of the version.
      Returns:
      major component of the version.
    • minor

      public int minor()
      Returns minor component of the version.
      Returns:
      minor component of the version.
    • micro

      public int micro()
      Returns micro component of the version.
      Returns:
      micro component of the version.
    • is

      public boolean is(Predicate<Version> predicate)
      Returns true if this version satisfy the given predicate.
      Parameters:
      predicate - the assertion tested against this version
      Returns:
      true if the assertion is satisfied, false otherwise
    • equalTo

      public static Predicate<Version> equalTo(Version version)
      Returns a predicate that verifies strict equality.
      Parameters:
      version - expected version
      Returns:
      a predicate that verifies strict equality.
    • greaterThan

      public static Predicate<Version> greaterThan(Version version)
      Returns a predicate that verifies if this version is strictly greater than the given version.
      Parameters:
      version - expected version
      Returns:
      a predicate that verifies if this version is strictly greater than the given version.
    • greaterThanOrEqualTo

      public static Predicate<Version> greaterThanOrEqualTo(Version version)
      Returns a predicate that verifies if this version is greater or equal to the given version.
      Parameters:
      version - expected version
      Returns:
      a predicate that verifies if this version is greater or equal to the given version.
    • lowerThan

      public static Predicate<Version> lowerThan(Version version)
      Returns a predicate that verifies if this version is strictly lower than the given version.
      Parameters:
      version - expected version
      Returns:
      a predicate that verifies if this version is strictly lower than the given version.
    • lowerThanOrEqualTo

      public static Predicate<Version> lowerThanOrEqualTo(Version version)
      Returns a predicate that verifies if this version is lower or equal to the given version.
      Parameters:
      version - expected version
      Returns:
      a predicate that verifies if this version is lower or equal to the given version.
    • between

      public static Predicate<Version> between(Version minInclusive, Version maxInclusive)
      Returns a predicate that verifies if this version is in between the given minInclusive and maxInclusive versions (inclusive).
      Parameters:
      minInclusive - minimum version
      maxInclusive - maximum version
      Returns:
      a predicate that verifies if this version is in between the given versions (inclusive)
    • strictlyBetween

      public static Predicate<Version> strictlyBetween(Version minExclusive, Version maxExclusive)
      Returns a predicate that verifies if this version is in between the given minExclusive and maxExclusive versions (exclusive).
      Parameters:
      minExclusive - minimum version
      maxExclusive - maximum version
      Returns:
      a predicate that verifies if this version is in between the given versions (exclusive)
    • compareTo

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

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

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

      public int hashCode()
      Overrides:
      hashCode in class Object