org.apache.commons.lang.math
Class NumberRange
- Serializable
public final class NumberRange
implements Serializable
NumberRange
represents an inclusive range of
Number
objects of the same type.
$Id: NumberRange.java 161243 2005-04-14 04:30:28Z ggregory $- 2.0 (previously in org.apache.commons.lang)
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).
|
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 .
|
containsDouble , containsDouble , containsFloat , containsFloat , containsInteger , containsInteger , containsLong , containsLong , containsNumber , containsRange , equals , getMaximumDouble , getMaximumFloat , getMaximumInteger , getMaximumLong , getMaximumNumber , getMinimumDouble , getMinimumFloat , getMinimumInteger , getMinimumLong , getMinimumNumber , hashCode , overlapsRange , toString |
NumberRange
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
NumberRange
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
containsNumber
public boolean containsNumber(Number number)
Tests whether the specified
number
occurs within
this range.
null
is handled and returns
false
.
- containsNumber in interface Range
number
- the number to test, may be null
true
if the specified number occurs within this range
equals
public 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 interface Range
obj
- the reference object with which to compare
true
if this object is equal
getMaximumNumber
public Number getMaximumNumber()
Returns the maximum number in this range.
- getMaximumNumber in interface Range
- the maximum number in this range
getMinimumNumber
public Number getMinimumNumber()
Returns the minimum number in this range.
- getMinimumNumber in interface Range
- the minimum number in this range
hashCode
public int hashCode()
Gets a hashCode for the range.
- hashCode in interface Range
- a hash code value for this object
toString
public String toString()
Gets the range as a
String
.
The format of the String is 'Range[
min,
max]'.
- toString in interface Range
- the
String
representation of this range
Copyright © 2001-2005 - Apache Software Foundation