Class FloatRange
- java.lang.Object
-
- org.apache.commons.lang.math.Range
-
- org.apache.commons.lang.math.FloatRange
-
- All Implemented Interfaces:
java.io.Serializable
public final class FloatRange extends Range implements java.io.Serializable
FloatRangerepresents an inclusive range offloats.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FloatRange(float number)Constructs a newFloatRangeusing the specified number as both the minimum and maximum in this range.FloatRange(float number1, float number2)Constructs a newFloatRangewith the specified minimum and maximum numbers (both inclusive).FloatRange(java.lang.Number number)Constructs a newFloatRangeusing the specified number as both the minimum and maximum in this range.FloatRange(java.lang.Number number1, java.lang.Number number2)Constructs a newFloatRangewith the specified minimum and maximum numbers (both inclusive).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsFloat(float value)Tests whether the specifiedfloatoccurs within this range usingfloatcomparison.booleancontainsNumber(java.lang.Number number)Tests whether the specifiednumberoccurs within this range usingfloatcomparison.booleancontainsRange(Range range)Tests whether the specified range occurs entirely within this range usingfloatcomparison.booleanequals(java.lang.Object obj)Compares this range to another object to test if they are equal.doublegetMaximumDouble()Gets the maximum number in this range as adouble.floatgetMaximumFloat()Gets the maximum number in this range as afloat.intgetMaximumInteger()Gets the maximum number in this range as aint.longgetMaximumLong()Gets the maximum number in this range as along.java.lang.NumbergetMaximumNumber()Returns the maximum number in this range.doublegetMinimumDouble()Gets the minimum number in this range as adouble.floatgetMinimumFloat()Gets the minimum number in this range as afloat.intgetMinimumInteger()Gets the minimum number in this range as aint.longgetMinimumLong()Gets the minimum number in this range as along.java.lang.NumbergetMinimumNumber()Returns the minimum number in this range.inthashCode()Gets a hashCode for the range.booleanoverlapsRange(Range range)Tests whether the specified range overlaps with this range usingfloatcomparison.java.lang.StringtoString()Gets the range as aString.-
Methods inherited from class org.apache.commons.lang.math.Range
containsDouble, containsDouble, containsFloat, containsInteger, containsInteger, containsLong, containsLong
-
-
-
-
Constructor Detail
-
FloatRange
public FloatRange(float number)
Constructs a new
FloatRangeusing the specified number as both the minimum and maximum in this range.- Parameters:
number- the number to use for this range- Throws:
java.lang.IllegalArgumentException- if the number isNaN
-
FloatRange
public FloatRange(java.lang.Number number)
Constructs a new
FloatRangeusing the specified number as both the minimum and maximum in this range.- Parameters:
number- the number to use for this range, must not benull- Throws:
java.lang.IllegalArgumentException- if the number isnulljava.lang.IllegalArgumentException- if the number isNaN
-
FloatRange
public FloatRange(float number1, float number2)Constructs a new
FloatRangewith the specified minimum and maximum numbers (both inclusive).The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
- Parameters:
number1- first number that defines the edge of the range, inclusivenumber2- second number that defines the edge of the range, inclusive- Throws:
java.lang.IllegalArgumentException- if either number isNaN
-
FloatRange
public FloatRange(java.lang.Number number1, java.lang.Number number2)Constructs a new
FloatRangewith the specified minimum and maximum numbers (both inclusive).The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
- Parameters:
number1- first number that defines the edge of the range, inclusivenumber2- second number that defines the edge of the range, inclusive- Throws:
java.lang.IllegalArgumentException- if either number isnulljava.lang.IllegalArgumentException- if either number isNaN
-
-
Method Detail
-
getMinimumNumber
public java.lang.Number getMinimumNumber()
Returns the minimum number in this range.
- Specified by:
getMinimumNumberin classRange- Returns:
- the minimum number in this range
-
getMinimumLong
public long getMinimumLong()
Gets the minimum number in this range as a
long.This conversion can lose information for large values or decimals.
- Overrides:
getMinimumLongin classRange- Returns:
- the minimum number in this range
-
getMinimumInteger
public int getMinimumInteger()
Gets the minimum number in this range as a
int.This conversion can lose information for large values or decimals.
- Overrides:
getMinimumIntegerin classRange- Returns:
- the minimum number in this range
-
getMinimumDouble
public double getMinimumDouble()
Gets the minimum number in this range as a
double.- Overrides:
getMinimumDoublein classRange- Returns:
- the minimum number in this range
-
getMinimumFloat
public float getMinimumFloat()
Gets the minimum number in this range as a
float.- Overrides:
getMinimumFloatin classRange- Returns:
- the minimum number in this range
-
getMaximumNumber
public java.lang.Number getMaximumNumber()
Returns the maximum number in this range.
- Specified by:
getMaximumNumberin classRange- Returns:
- the maximum number in this range
-
getMaximumLong
public long getMaximumLong()
Gets the maximum number in this range as a
long.This conversion can lose information for large values or decimals.
- Overrides:
getMaximumLongin classRange- Returns:
- the maximum number in this range
-
getMaximumInteger
public int getMaximumInteger()
Gets the maximum number in this range as a
int.This conversion can lose information for large values or decimals.
- Overrides:
getMaximumIntegerin classRange- Returns:
- the maximum number in this range
-
getMaximumDouble
public double getMaximumDouble()
Gets the maximum number in this range as a
double.- Overrides:
getMaximumDoublein classRange- Returns:
- the maximum number in this range
-
getMaximumFloat
public float getMaximumFloat()
Gets the maximum number in this range as a
float.- Overrides:
getMaximumFloatin classRange- Returns:
- the maximum number in this range
-
containsNumber
public boolean containsNumber(java.lang.Number number)
Tests whether the specified
numberoccurs within this range usingfloatcomparison.nullis handled and returnsfalse.- Specified by:
containsNumberin classRange- Parameters:
number- the number to test, may benull- Returns:
trueif the specified number occurs within this range
-
containsFloat
public boolean containsFloat(float value)
Tests whether the specified
floatoccurs within this range usingfloatcomparison.This implementation overrides the superclass for performance as it is the most common case.
- Overrides:
containsFloatin classRange- Parameters:
value- the float to test- Returns:
trueif the specified number occurs within this range byfloatcomparison
-
containsRange
public boolean containsRange(Range range)
Tests whether the specified range occurs entirely within this range using
floatcomparison.nullis handled and returnsfalse.- Overrides:
containsRangein classRange- Parameters:
range- the range to test, may benull- Returns:
trueif the specified range occurs entirely within this range- Throws:
java.lang.IllegalArgumentException- if the range is not of this type
-
overlapsRange
public boolean overlapsRange(Range range)
Tests whether the specified range overlaps with this range using
floatcomparison.nullis handled and returnsfalse.- Overrides:
overlapsRangein classRange- Parameters:
range- the range to test, may benull- Returns:
trueif the specified range overlaps with this range
-
equals
public 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.
-
hashCode
public int hashCode()
Gets a hashCode for the range.
-
-