| java.lang.Object org.apache.commons.lang.math.Range org.apache.commons.lang.math.NumberRange
NumberRange | final public class NumberRange extends Range implements Serializable(Code) | | NumberRange represents an inclusive range of
java.lang.Number objects of the same type.
author: Christopher Elkins author: Stephen Colebourne since: 2.0 (previously in org.apache.commons.lang) version: $Id: NumberRange.java 437554 2006-08-28 06:21:41Z bayard $ |
Constructor Summary | |
public | NumberRange(Number num) | 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). |
NumberRange | public NumberRange(Number num1, Number num2)(Code) | | 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
NumberRange.getMinimumNumber() and
NumberRange.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.
Parameters: num1 - first number that defines the edge of the range, inclusive Parameters: num2 - second number that defines the edge of the range, inclusive throws: IllegalArgumentException - if either number is null throws: IllegalArgumentException - if the numbers are of different types throws: IllegalArgumentException - if the numbers don't implement Comparable |
containsNumber | public boolean containsNumber(Number number)(Code) | | Tests whether the specified number occurs within
this range.
null is handled and returns false .
Parameters: number - the number to test, may be null true if the specified number occurs within this range throws: IllegalArgumentException - if the number is of a different type to the range |
equals | public boolean equals(Object obj)(Code) | | Compares this range to another object to test if they are equal. .
To be equal, the class, minimum and maximum must be equal.
Parameters: obj - the reference object with which to compare true if this object is equal |
getMaximumNumber | public Number getMaximumNumber()(Code) | | Returns the maximum number in this range.
the maximum number in this range |
getMinimumNumber | public Number getMinimumNumber()(Code) | | Returns the minimum number in this range.
the minimum number in this range |
hashCode | public int hashCode()(Code) | | Gets a hashCode for the range.
a hash code value for this object |
toString | public String toString()(Code) | | Gets the range as a String .
The format of the String is 'Range[min,max]'.
the String representation of this range |
|
|