|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectRange<T>
NumberRange<T>
MeasurementRange<T>
T
- The type of range elements as a subclass of Number
.public class MeasurementRange<T extends Number & Comparable<? super T>>
A range of numbers associated with a unit of measurement. Unit conversions are applied as needed by union and intersection operations.
Constructor Summary | |
---|---|
MeasurementRange(Class<T> type,
T minimum,
boolean isMinIncluded,
T maximum,
boolean isMaxIncluded,
Unit<?> units)
Constructs a range of Number objects. |
|
MeasurementRange(Range<T> range,
Unit<?> units)
Constructs a range with the same values than the specified range. |
Method Summary | ||
---|---|---|
|
castTo(Class<N> type)
Casts this range to the specified type. |
|
MeasurementRange |
convertTo(Unit<?> targetUnits)
Converts this range to the specified units. |
|
static MeasurementRange<Double> |
create(double minimum,
boolean isMinIncluded,
double maximum,
boolean isMaxIncluded,
Unit<?> units)
Constructs a range of double values. |
|
static MeasurementRange<Double> |
create(double minimum,
double maximum,
Unit<?> units)
Constructs an inclusive range of double values. |
|
static MeasurementRange<Float> |
create(float minimum,
boolean isMinIncluded,
float maximum,
boolean isMaxIncluded,
Unit<?> units)
Constructs a range of float values. |
|
static MeasurementRange<Float> |
create(float minimum,
float maximum,
Unit<?> units)
Constructs an inclusive range of float values. |
|
boolean |
equals(Object object)
Compares this range with the specified object for equality. |
|
Unit<?> |
getUnits()
Returns the units of measurement, or null if unknown. |
|
MeasurementRange |
intersect(Range range)
Returns the intersection of this range with the given range. |
|
MeasurementRange[] |
subtract(Range range)
Returns the range of values that are in this range but not in the given range. |
|
MeasurementRange |
union(Range range)
Returns the union of this range with the given range. |
Methods inherited from class NumberRange |
---|
contains, contains, contains, create, create, create, create, create, create, create, create, create, create, create, create, getMaximum, getMaximum, getMinimum, getMinimum, intersects, wrap |
Methods inherited from class Range |
---|
getElementClass, getMaxValue, getMinValue, hashCode, isEmpty, isMaxIncluded, isMinIncluded, toString |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MeasurementRange(Class<T> type, T minimum, boolean isMinIncluded, T maximum, boolean isMaxIncluded, Unit<?> units)
Number
objects.
type
- The element class, usually one of Byte
, Short
,
Integer
, Long
, Float
or Double
.minimum
- The minimum value.isMinIncluded
- Defines whether the minimum value is included in the Range.maximum
- The maximum value.isMaxIncluded
- Defines whether the maximum value is included in the Range.units
- The units of measurement, or null
if unknown.public MeasurementRange(Range<T> range, Unit<?> units)
range
- The range to copy. The elements must be Number
instances.units
- The units of measurement, or null
if unknown.Method Detail |
---|
public static MeasurementRange<Float> create(float minimum, float maximum, Unit<?> units)
float
values.
minimum
- The minimum value, inclusive.maximum
- The maximum value, inclusive.units
- The units of measurement, or null
if unknown.
public static MeasurementRange<Float> create(float minimum, boolean isMinIncluded, float maximum, boolean isMaxIncluded, Unit<?> units)
float
values.
minimum
- The minimum value.isMinIncluded
- Defines whether the minimum value is included in the Range.maximum
- The maximum value.isMaxIncluded
- Defines whether the maximum value is included in the Range.units
- The units of measurement, or null
if unknown.
public static MeasurementRange<Double> create(double minimum, double maximum, Unit<?> units)
double
values.
minimum
- The minimum value, inclusive.maximum
- The maximum value, inclusive.units
- The units of measurement, or null
if unknown.
public static MeasurementRange<Double> create(double minimum, boolean isMinIncluded, double maximum, boolean isMaxIncluded, Unit<?> units)
double
values.
minimum
- The minimum value.isMinIncluded
- Defines whether the minimum value is included in the Range.maximum
- The maximum value.isMaxIncluded
- Defines whether the maximum value is included in the Range.units
- The units of measurement, or null
if unknown.
public Unit<?> getUnits()
null
if unknown.
null
.public MeasurementRange convertTo(Unit<?> targetUnits) throws ConversionException
targetUnits
- the target units.
this
if no conversion is needed.
ConversionException
- if the target units are not compatible with
this range units.public <N extends Number & Comparable<? super N>> MeasurementRange<N> castTo(Class<N> type)
castTo
in class NumberRange<T extends Number & Comparable<? super T>>
N
- The class to cast to.type
- The class to cast to. Must be one of Byte
, Short
,
Integer
, Long
, Float
or Double
.
this
if this range already uses the specified type.public MeasurementRange union(Range range)
union
in class NumberRange<T extends Number & Comparable<? super T>>
range
- The range to add to this range.
Range.union(javax.media.jai.util.Range)
public MeasurementRange intersect(Range range)
intersect
in class NumberRange<T extends Number & Comparable<? super T>>
range
- The range to intersect.
Range.intersect(javax.media.jai.util.Range)
public MeasurementRange[] subtract(Range range)
subtract
in class NumberRange<T extends Number & Comparable<? super T>>
range
- The range to substract.
Range.subtract(javax.media.jai.util.Range)
public boolean equals(Object object)
equals
in class Range<T extends Number & Comparable<? super T>>
object
- The object to compare with this range for equality.
true
if the given object is equals to this range.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |