public final class NumberRange extends Range implements java.io.Serializable
NumberRange represents an inclusive range of
Number objects of the same type.
| Modifier and Type | Field and Description |
|---|---|
private int |
hashCode
Cached output hashCode (class is immutable).
|
private java.lang.Number |
max
The maximum number in this range.
|
private java.lang.Number |
min
The minimum number in this range.
|
private static long |
serialVersionUID
Required for serialization support.
|
private java.lang.String |
toString
Cached output toString (class is immutable).
|
| 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, overlapsRangeprivate static final long serialVersionUID
Serializable,
Constant Field Valuesprivate final java.lang.Number min
private final java.lang.Number max
private transient int hashCode
private transient java.lang.String toString
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 nulljava.lang.IllegalArgumentException - if the number doesn't implement Comparablejava.lang.IllegalArgumentException - if the number is Double.NaN or Float.NaNpublic 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 nulljava.lang.IllegalArgumentException - if the numbers are of different typesjava.lang.IllegalArgumentException - if the numbers don't implement Comparablepublic java.lang.Number getMinimumNumber()
Returns the minimum number in this range.
getMinimumNumber in class Rangepublic java.lang.Number getMaximumNumber()
Returns the maximum number in this range.
getMaximumNumber in class Rangepublic boolean containsNumber(java.lang.Number number)
Tests whether the specified number occurs within
this range.
null is handled and returns false.
containsNumber in class Rangenumber - the number to test, may be nulltrue 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.