public final class NumberRange extends Range implements java.io.Serializable
NumberRange
represents an inclusive range of
Number
objects of the same type.
Constructor and Description |
---|
NumberRange(java.lang.Number num)
Constructs a new
NumberRange using the specified
number as both the minimum and maximum in this range. |
NumberRange(java.lang.Number num1,
java.lang.Number num2)
Constructs a new
NumberRange with the specified
minimum and maximum numbers (both inclusive). |
Modifier and Type | Method and Description |
---|---|
boolean |
containsNumber(java.lang.Number number)
Tests whether the specified
number occurs within
this range. |
boolean |
equals(java.lang.Object obj)
Compares this range to another object to test if they are equal.
|
java.lang.Number |
getMaximumNumber()
Returns the maximum number in this range.
|
java.lang.Number |
getMinimumNumber()
Returns the minimum number in this range.
|
int |
hashCode()
Gets a hashCode for the range.
|
java.lang.String |
toString()
Gets the range as a
String . |
containsDouble, containsDouble, containsFloat, containsFloat, containsInteger, containsInteger, containsLong, containsLong, containsRange, getMaximumDouble, getMaximumFloat, getMaximumInteger, getMaximumLong, getMinimumDouble, getMinimumFloat, getMinimumInteger, getMinimumLong, overlapsRange
public NumberRange(java.lang.Number num)
Constructs a new NumberRange
using the specified
number as both the minimum and maximum in this range.
num
- the number to use for this rangejava.lang.IllegalArgumentException
- if the number is null
java.lang.IllegalArgumentException
- if the number doesn't implement Comparable
java.lang.IllegalArgumentException
- if the number is Double.NaN
or Float.NaN
public NumberRange(java.lang.Number num1, java.lang.Number num2)
Constructs a new NumberRange
with the specified
minimum and maximum numbers (both inclusive).
The arguments may be passed in the order (min,max) or (max,min). The
getMinimumNumber()
and getMaximumNumber()
methods will return the
correct value.
This constructor is designed to be used with two Number
objects of the same type. If two objects of different types are passed in,
an exception is thrown.
num1
- first number that defines the edge of the range, inclusivenum2
- second number that defines the edge of the range, inclusivejava.lang.IllegalArgumentException
- if either number is null
java.lang.IllegalArgumentException
- if the numbers are of different typesjava.lang.IllegalArgumentException
- if the numbers don't implement Comparable
public java.lang.Number getMinimumNumber()
Returns the minimum number in this range.
getMinimumNumber
in class Range
public java.lang.Number getMaximumNumber()
Returns the maximum number in this range.
getMaximumNumber
in class Range
public boolean containsNumber(java.lang.Number number)
Tests whether the specified number
occurs within
this range.
null
is handled and returns false
.
containsNumber
in class Range
number
- the number to test, may be null
true
if the specified number occurs within this rangejava.lang.IllegalArgumentException
- if the number is of a different type to the rangepublic boolean equals(java.lang.Object obj)
Compares this range to another object to test if they are equal.
.To be equal, the class, minimum and maximum must be equal.
public int hashCode()
Gets a hashCode for the range.
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"