Class Range<T extends java.lang.Comparable<T>>

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

    @StableMinor(version="17.0",
                 sinceVersion="9.0")
    public class Range<T extends java.lang.Comparable<T>>
    extends java.lang.Object
    implements java.io.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: 26587 $ $Date: 2024-08-26 21:09:17 -0300 (Mon, 26 Aug 2024) $
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Range​(T from, T to)
      Creates a new range.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      T getFrom()
      Returns the from.
      T getTo()
      Returns the to.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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:
        java.lang.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
      • toString

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object