Class Range<T extends Comparable<T>>

  • Type Parameters:
    T - the type of range values.
    All Implemented Interfaces:
    Serializable

    @StableMinor(version="14.1",
                 sinceVersion="9.0")
    public class Range<T extends Comparable<T>>
    extends Object
    implements Serializable
    Represents a range of values by having a from and a to value.

    Both from and to may be null, but not at the same time. A null value means an unbounded limit. For example, the range (null, 100) represents all numbers less than or equal to 100, while the range (100, null) represents all numbers greater than or equal to 100.
    If both from and to were null at the same time, it would represent the whole universe of possible values.

    Since:
    9.0.0
    Version:
    $Revision: 24683 $ $Date: 2021-08-23 18:55:58 -0300 (Mon, 23 Aug 2021) $
    See Also:
    Serialized Form
    • Constructor Detail

      • Range

        public Range​(T from,
                     T to)
        Creates a new range.
        Parameters:
        from - the lower range limit.
        to - the upper range limit.
        Throws:
        IllegalArgumentException - if both from and to are null or to is less than from.
        Since:
        9.0.0
    • Method Detail

      • getFrom

        public T getFrom()
        Returns the from.
        Returns:
        the from
        Since:
        9.0.0
      • getTo

        public T getTo()
        Returns the to.
        Returns:
        the to
        Since:
        9.0.0
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object