Class 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
    Author:
    Laszlo Hordos
    • Field Detail

      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
    • Constructor Detail

      • VersionRange

        public VersionRange​(Version low,
                            boolean isLowInclusive,
                            Version high,
                            boolean isHighInclusive)
    • Method Detail

      • 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.
        Throws:
        IllegalArgumentException - If range is improperly formatted.
      • getFloor

        public Version getFloor()
      • isFloorInclusive

        public boolean isFloorInclusive()
      • getCeiling

        public Version getCeiling()
      • isCeilingInclusive

        public boolean isCeilingInclusive()
      • isInRange

        public boolean isInRange​(Version version)
      • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object