Class Range

  • Direct Known Subclasses:
    DoubleRange, FloatRange, IntRange, LongRange, NumberRange

    @Deprecated(since="2021-04-30")
    public abstract class Range
    extends java.lang.Object
    Deprecated.
    Commons Lang 2 is in maintenance mode. Commons Lang 3 should be used instead.

    Range represents a range of numbers of the same type.

    Specific subclasses hold the range values as different types. Each subclass should be immutable and Serializable if possible.

    Since:
    2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      Range()
      Deprecated.
      Constructs a new range.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean containsDouble​(double value)
      Deprecated.
      Tests whether the specified double occurs within this range using double comparison.
      boolean containsDouble​(java.lang.Number value)
      Deprecated.
      Tests whether the specified Number occurs within this range using double comparison..
      boolean containsFloat​(float value)
      Deprecated.
      Tests whether the specified float occurs within this range using float comparison.
      boolean containsFloat​(java.lang.Number value)
      Deprecated.
      Tests whether the specified Number occurs within this range using float comparison.
      boolean containsInteger​(int value)
      Deprecated.
      Tests whether the specified int occurs within this range using int comparison.
      boolean containsInteger​(java.lang.Number value)
      Deprecated.
      Tests whether the specified Number occurs within this range using int comparison..
      boolean containsLong​(long value)
      Deprecated.
      Tests whether the specified long occurs within this range using long comparison.
      boolean containsLong​(java.lang.Number value)
      Deprecated.
      Tests whether the specified Number occurs within this range using long comparison..
      abstract boolean containsNumber​(java.lang.Number number)
      Deprecated.
      Tests whether the specified Number occurs within this range.
      boolean containsRange​(Range range)
      Deprecated.
      Tests whether the specified range occurs entirely within this range.
      boolean equals​(java.lang.Object obj)
      Deprecated.
      Compares this range to another object to test if they are equal.
      double getMaximumDouble()
      Deprecated.
      Gets the maximum number in this range as a double.
      float getMaximumFloat()
      Deprecated.
      Gets the maximum number in this range as a float.
      int getMaximumInteger()
      Deprecated.
      Gets the maximum number in this range as a int.
      long getMaximumLong()
      Deprecated.
      Gets the maximum number in this range as a long.
      abstract java.lang.Number getMaximumNumber()
      Deprecated.
      Gets the maximum number in this range.
      double getMinimumDouble()
      Deprecated.
      Gets the minimum number in this range as a double.
      float getMinimumFloat()
      Deprecated.
      Gets the minimum number in this range as a float.
      int getMinimumInteger()
      Deprecated.
      Gets the minimum number in this range as a int.
      long getMinimumLong()
      Deprecated.
      Gets the minimum number in this range as a long.
      abstract java.lang.Number getMinimumNumber()
      Deprecated.
      Gets the minimum number in this range.
      int hashCode()
      Deprecated.
      Gets a hashCode for the range.
      boolean overlapsRange​(Range range)
      Deprecated.
      Tests whether the specified range overlaps with this range.
      java.lang.String toString()
      Deprecated.
      Gets the range as a String.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Range

        public Range()
        Deprecated.

        Constructs a new range.

    • Method Detail

      • getMinimumNumber

        public abstract java.lang.Number getMinimumNumber()
        Deprecated.

        Gets the minimum number in this range.

        Returns:
        the minimum number in this range
      • getMinimumLong

        public long getMinimumLong()
        Deprecated.

        Gets the minimum number in this range as a long.

        This implementation uses the getMinimumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the minimum number in this range
      • getMinimumInteger

        public int getMinimumInteger()
        Deprecated.

        Gets the minimum number in this range as a int.

        This implementation uses the getMinimumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the minimum number in this range
      • getMinimumDouble

        public double getMinimumDouble()
        Deprecated.

        Gets the minimum number in this range as a double.

        This implementation uses the getMinimumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the minimum number in this range
      • getMinimumFloat

        public float getMinimumFloat()
        Deprecated.

        Gets the minimum number in this range as a float.

        This implementation uses the getMinimumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the minimum number in this range
      • getMaximumNumber

        public abstract java.lang.Number getMaximumNumber()
        Deprecated.

        Gets the maximum number in this range.

        Returns:
        the maximum number in this range
      • getMaximumLong

        public long getMaximumLong()
        Deprecated.

        Gets the maximum number in this range as a long.

        This implementation uses the getMaximumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the maximum number in this range
      • getMaximumInteger

        public int getMaximumInteger()
        Deprecated.

        Gets the maximum number in this range as a int.

        This implementation uses the getMaximumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the maximum number in this range
      • getMaximumDouble

        public double getMaximumDouble()
        Deprecated.

        Gets the maximum number in this range as a double.

        This implementation uses the getMaximumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the maximum number in this range
      • getMaximumFloat

        public float getMaximumFloat()
        Deprecated.

        Gets the maximum number in this range as a float.

        This implementation uses the getMaximumNumber() method. Subclasses may be able to optimise this.

        Returns:
        the maximum number in this range
      • containsNumber

        public abstract boolean containsNumber​(java.lang.Number number)
        Deprecated.

        Tests whether the specified Number occurs within this range.

        The exact comparison implementation varies by subclass. It is intended that an int specific subclass will compare using int comparison.

        null is handled and returns false.

        Parameters:
        number - the number to test, may be null
        Returns:
        true if the specified number occurs within this range
        Throws:
        java.lang.IllegalArgumentException - if the Number cannot be compared
      • containsLong

        public boolean containsLong​(java.lang.Number value)
        Deprecated.

        Tests whether the specified Number occurs within this range using long comparison..

        null is handled and returns false.

        This implementation forwards to the containsLong(long) method.

        Parameters:
        value - the long to test, may be null
        Returns:
        true if the specified number occurs within this range by long comparison
      • containsLong

        public boolean containsLong​(long value)
        Deprecated.

        Tests whether the specified long occurs within this range using long comparison.

        This implementation uses the getMinimumLong() and getMaximumLong() methods and should be good for most uses.

        Parameters:
        value - the long to test
        Returns:
        true if the specified number occurs within this range by long comparison
      • containsInteger

        public boolean containsInteger​(java.lang.Number value)
        Deprecated.

        Tests whether the specified Number occurs within this range using int comparison..

        null is handled and returns false.

        This implementation forwards to the containsInteger(int) method.

        Parameters:
        value - the integer to test, may be null
        Returns:
        true if the specified number occurs within this range by int comparison
      • containsInteger

        public boolean containsInteger​(int value)
        Deprecated.

        Tests whether the specified int occurs within this range using int comparison.

        This implementation uses the getMinimumInteger() and getMaximumInteger() methods and should be good for most uses.

        Parameters:
        value - the int to test
        Returns:
        true if the specified number occurs within this range by int comparison
      • containsDouble

        public boolean containsDouble​(java.lang.Number value)
        Deprecated.

        Tests whether the specified Number occurs within this range using double comparison..

        null is handled and returns false.

        This implementation forwards to the containsDouble(double) method.

        Parameters:
        value - the double to test, may be null
        Returns:
        true if the specified number occurs within this range by double comparison
      • containsDouble

        public boolean containsDouble​(double value)
        Deprecated.

        Tests whether the specified double occurs within this range using double comparison.

        This implementation uses the getMinimumDouble() and getMaximumDouble() methods and should be good for most uses.

        Parameters:
        value - the double to test
        Returns:
        true if the specified number occurs within this range by double comparison
      • containsFloat

        public boolean containsFloat​(java.lang.Number value)
        Deprecated.

        Tests whether the specified Number occurs within this range using float comparison.

        null is handled and returns false.

        This implementation forwards to the containsFloat(float) method.

        Parameters:
        value - the float to test, may be null
        Returns:
        true if the specified number occurs within this range by float comparison
      • containsFloat

        public boolean containsFloat​(float value)
        Deprecated.

        Tests whether the specified float occurs within this range using float comparison.

        This implementation uses the getMinimumFloat() and getMaximumFloat() methods and should be good for most uses.

        Parameters:
        value - the float to test
        Returns:
        true if the specified number occurs within this range by float comparison
      • containsRange

        public boolean containsRange​(Range range)
        Deprecated.

        Tests whether the specified range occurs entirely within this range.

        The exact comparison implementation varies by subclass. It is intended that an int specific subclass will compare using int comparison.

        null is handled and returns false.

        This implementation uses the containsNumber(Number) method. Subclasses may be able to optimise this.

        Parameters:
        range - the range to test, may be null
        Returns:
        true if the specified range occurs entirely within this range; otherwise, false
        Throws:
        java.lang.IllegalArgumentException - if the Range cannot be compared
      • overlapsRange

        public boolean overlapsRange​(Range range)
        Deprecated.

        Tests whether the specified range overlaps with this range.

        The exact comparison implementation varies by subclass. It is intended that an int specific subclass will compare using int comparison.

        null is handled and returns false.

        This implementation uses the containsNumber(Number) and containsRange(Range) methods. Subclasses may be able to optimise this.

        Parameters:
        range - the range to test, may be null
        Returns:
        true if the specified range overlaps with this range; otherwise, false
        Throws:
        java.lang.IllegalArgumentException - if the Range cannot be compared
      • equals

        public boolean equals​(java.lang.Object obj)
        Deprecated.

        Compares this range to another object to test if they are equal.

        .

        To be equal, the class, minimum and maximum must be equal.

        This implementation uses the getMinimumNumber() and getMaximumNumber() methods. Subclasses may be able to optimise this.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the reference object with which to compare
        Returns:
        true if this object is equal
      • hashCode

        public int hashCode()
        Deprecated.

        Gets a hashCode for the range.

        This implementation uses the getMinimumNumber() and getMaximumNumber() methods. Subclasses may be able to optimise this.

        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object
      • toString

        public java.lang.String toString()
        Deprecated.

        Gets the range as a String.

        The format of the String is 'Range[min,max]'.

        This implementation uses the getMinimumNumber() and getMaximumNumber() methods. Subclasses may be able to optimise this.

        Overrides:
        toString in class java.lang.Object
        Returns:
        the String representation of this range