Class VersionRange

java.lang.Object
org.identityconnectors.common.VersionRange

public class VersionRange extends Object
A version range is an interval describing a set of versions.

A range has a left (lower) endpoint and a right (upper) endpoint. Each endpoint can be open (excluded from the set) or closed (included in the set).

VersionRange objects are immutable.

Since:
1.4
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The left endpoint is closed and is included in the range.
    static final char
    The left endpoint is open and is excluded from the range.
    static final char
    The right endpoint is closed and is included in the range.
    static final char
    The right endpoint is open and is excluded from the range.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VersionRange(Version low, boolean isLowInclusive, Version high, boolean isHighInclusive)
    Construct a version range from components.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Return the highest version supported by the range.
    Return the lowest version supported by this range.
    int
     
    boolean
    Return whether the highest supported version is part of the range.
    boolean
    Returns whether this version range is empty.
    boolean
    Returns whether this version range contains only a single version.
    boolean
    Return whether the lowest supported version is part of the range.
    boolean
    isInRange(Version version)
    Return whether a given version is covered by this range.
    parse(String range)
    Creates a version range from the specified string.
     

    Methods inherited from class java.lang.Object

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

    • LEFT_OPEN

      public static final char LEFT_OPEN
      The left endpoint is open and is excluded from the range.

      The value of LEFT_OPEN is '('.

      See Also:
    • LEFT_CLOSED

      public static final char LEFT_CLOSED
      The left endpoint is closed and is included in the range.

      The value of LEFT_CLOSED is '['.

      See Also:
    • RIGHT_OPEN

      public static final char RIGHT_OPEN
      The right endpoint is open and is excluded from the range.

      The value of RIGHT_OPEN is ')'.

      See Also:
    • RIGHT_CLOSED

      public static final char RIGHT_CLOSED
      The right endpoint is closed and is included in the range.

      The value of RIGHT_CLOSED is ']'.

      See Also:
  • Constructor Details

    • VersionRange

      public VersionRange(Version low, boolean isLowInclusive, Version high, boolean isHighInclusive)
      Construct a version range from components.
      Parameters:
      low - the lowest version the range should support
      isLowInclusive - whether the low version is part of the range or just beyond the lower bound
      high - the highest version the range should support
      isHighInclusive - whether the high version is part of the range or just outside the upper bound
  • Method Details

    • parse

      public static VersionRange parse(String range)
      Creates a version range from the specified string.

      Version range string grammar:

       range ::= interval | at least
       interval ::= ( '[' | '(' ) left ',' right ( ']' | ')' )
       left ::= version
       right ::= version
       at least ::= version
       
      Parameters:
      range - String representation of the version range. The versions in the range must contain no whitespace. Other whitespace in the range string is ignored.
      Returns:
      a VersionRange parsed from the range string
      Throws:
      IllegalArgumentException - If range is improperly formatted.
    • getFloor

      public Version getFloor()
      Return the lowest version supported by this range. Version returned may be inclusive or exclusive.
      Returns:
      lowest supported version
    • isFloorInclusive

      public boolean isFloorInclusive()
      Return whether the lowest supported version is part of the range.
      Returns:
      true iff lowest supported version is part of the range
    • getCeiling

      public Version getCeiling()
      Return the highest version supported by the range. Version returned may be inclusive or exclusive.
      Returns:
      highest supported version
    • isCeilingInclusive

      public boolean isCeilingInclusive()
      Return whether the highest supported version is part of the range.
      Returns:
      true iff highest supported version is part of the range
    • isInRange

      public boolean isInRange(Version version)
      Return whether a given version is covered by this range.
      Parameters:
      version - the version to test
      Returns:
      true iff the version is covered by this range
    • isExact

      public boolean isExact()
      Returns whether this version range contains only a single version.
      Returns:
      true if this version range contains only a single version; false otherwise.
    • isEmpty

      public boolean isEmpty()
      Returns whether this version range is empty. A version range is empty if the set of versions defined by the interval is empty.
      Returns:
      true if this version range is empty; false otherwise.
    • 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