|
|||||||||||
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
NumberRange
represents an inclusive range of
Number
objects of the same type.
Constructor Summary | |
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). |
Method Summary | |
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 . |
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(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 range
java.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, inclusive
java.lang.IllegalArgumentException
- if either number is null
java.lang.IllegalArgumentException
- if the numbers are of different types
java.lang.IllegalArgumentException
- if the numbers don't implement Comparable
Method Detail |
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 range
java.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.
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 java.lang.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 |