|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.lang.math.Range org.apache.commons.lang.math.NumberRange
public final class NumberRange
NumberRange
represents an inclusive range of
Number
objects of the same type.
Constructor Summary | |
---|---|
NumberRange(Number num)
Constructs a new NumberRange using the specified
number as both the minimum and maximum in this range. |
|
NumberRange(Number num1,
Number num2)
Constructs a new NumberRange with the specified
minimum and maximum numbers (both inclusive). |
Method Summary | |
---|---|
boolean |
containsNumber(Number number)
Tests whether the specified number occurs within
this range. |
boolean |
equals(Object obj)
Compares this range to another object to test if they are equal. |
Number |
getMaximumNumber()
Returns the maximum number in this range. |
Number |
getMinimumNumber()
Returns the minimum number in this range. |
int |
hashCode()
Gets a hashCode for the range. |
String |
toString()
Gets the range as a String . |
Methods inherited from class org.apache.commons.lang.math.Range |
---|
containsDouble, containsDouble, containsFloat, containsFloat, containsInteger, containsInteger, containsLong, containsLong, containsRange, getMaximumDouble, getMaximumFloat, getMaximumInteger, getMaximumLong, getMinimumDouble, getMinimumFloat, getMinimumInteger, getMinimumLong, overlapsRange |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NumberRange(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 range
IllegalArgumentException
- if the number is null
IllegalArgumentException
- if the number doesn't implement Comparable
IllegalArgumentException
- if the number is Double.NaN
or Float.NaN
public NumberRange(Number num1, 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, inclusive
IllegalArgumentException
- if either number is null
IllegalArgumentException
- if the numbers are of different types
IllegalArgumentException
- if the numbers don't implement Comparable
Method Detail |
---|
public Number getMinimumNumber()
Returns the minimum number in this range.
getMinimumNumber
in class Range
public Number getMaximumNumber()
Returns the maximum number in this range.
getMaximumNumber
in class Range
public boolean containsNumber(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 range
IllegalArgumentException
- if the number is of a different type to the rangepublic boolean equals(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.
equals
in class Range
obj
- the reference object with which to compare
true
if this object is equalpublic int hashCode()
Gets a hashCode for the range.
hashCode
in class Range
public String toString()
Gets the range as a String
.
The format of the String is 'Range[min,max]'.
toString
in class Range
String
representation of this range
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |