Package org.geotools.util
Class MeasurementRange<T extends Number & Comparable<? super T>>
Object
Range<T>
NumberRange<T>
MeasurementRange<T>
- Type Parameters:
T- The type of range elements as a subclass ofNumber.
- All Implemented Interfaces:
Serializable
A range of numbers associated with a unit of measurement. Unit conversions are applied as needed by
union and intersection operations.
- Since:
- 2.4
- Author:
- Martin Desruisseaux
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMeasurementRange(Class<T> type, T minimum, boolean isMinIncluded, T maximum, boolean isMaxIncluded, Unit<?> units) Constructs a range ofNumberobjects.MeasurementRange(Range<T> range, Unit<?> units) Constructs a range with the same values than the specified range. -
Method Summary
Modifier and TypeMethodDescription<N extends Number & Comparable<? super N>>
MeasurementRange<N>Casts this range to the specified type.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 ofdoublevalues.static MeasurementRange<Double>create(double minimum, double maximum, Unit<?> units) Constructs an inclusive range ofdoublevalues.static MeasurementRange<Float>create(float minimum, boolean isMinIncluded, float maximum, boolean isMaxIncluded, Unit<?> units) Constructs a range offloatvalues.static MeasurementRange<Float>create(float minimum, float maximum, Unit<?> units) Constructs an inclusive range offloatvalues.booleanCompares this range with the specified object for equality.Unit<?>getUnits()Returns the units of measurement, ornullif unknown.inthashCode()Returns a hash code value for this range.Returns the intersection of this range with the given range.Returns the range of values that are in this range but not in the given 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, wrapMethods inherited from class Range
getElementClass, getMaxValue, getMinValue, isEmpty, isMaxIncluded, isMinIncluded, toString
-
Constructor Details
-
MeasurementRange
public MeasurementRange(Class<T> type, T minimum, boolean isMinIncluded, T maximum, boolean isMaxIncluded, Unit<?> units) Constructs a range ofNumberobjects.- Parameters:
type- The element class, usually one ofByte,Short,Integer,Long,FloatorDouble.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, ornullif unknown.
-
MeasurementRange
Constructs a range with the same values than the specified range.- Parameters:
range- The range to copy. The elements must beNumberinstances.units- The units of measurement, ornullif unknown.
-
-
Method Details
-
create
Constructs an inclusive range offloatvalues.- Parameters:
minimum- The minimum value, inclusive.maximum- The maximum value, inclusive.units- The units of measurement, ornullif unknown.- Returns:
- The measurement range.
- Since:
- 2.5
-
create
public static MeasurementRange<Float> create(float minimum, boolean isMinIncluded, float maximum, boolean isMaxIncluded, Unit<?> units) Constructs a range offloatvalues.- Parameters:
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, ornullif unknown.- Returns:
- The measurement range.
- Since:
- 2.5
-
create
Constructs an inclusive range ofdoublevalues.- Parameters:
minimum- The minimum value, inclusive.maximum- The maximum value, inclusive.units- The units of measurement, ornullif unknown.- Returns:
- The measurement range.
-
create
public static MeasurementRange<Double> create(double minimum, boolean isMinIncluded, double maximum, boolean isMaxIncluded, Unit<?> units) Constructs a range ofdoublevalues.- Parameters:
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, ornullif unknown.- Returns:
- The measurement range.
-
getUnits
public Unit<?> getUnits()Returns the units of measurement, ornullif unknown.- Returns:
- The units of measurement, or
null.
-
convertTo
Converts this range to the specified units. If this measurement range has null units, then the specified target units are simply assigned to the returned range with no other changes.- Parameters:
targetUnits- the target units.- Returns:
- The converted range, or
thisif no conversion is needed. - Throws:
IllegalArgumentException- if the target units are not compatible with this range units.
-
castTo
Casts this range to the specified type.- Overrides:
castToin classNumberRange<T extends Number & Comparable<? super T>>- Type Parameters:
N- The class to cast to.- Parameters:
type- The class to cast to. Must be one ofByte,Short,Integer,Long,FloatorDouble.- Returns:
- The casted range, or
thisif this range already uses the specified type.
-
union
Returns the union of this range with the given range. Widening conversions will be applied as needed.- Overrides:
unionin classNumberRange<T extends Number & Comparable<? super T>>- Parameters:
range- The range to add to this range.- Returns:
- The union of this range with the given range.
- See Also:
-
Range.union(org.eclipse.imagen.util.Range)
-
intersect
Returns the intersection of this range with the given range. Widening conversions will be applied as needed.- Overrides:
intersectin classNumberRange<T extends Number & Comparable<? super T>>- Parameters:
range- The range to intersect.- Returns:
- The intersection of this range with the provided range.
- See Also:
-
Range.intersect(org.eclipse.imagen.util.Range)
-
subtract
Returns the range of values that are in this range but not in the given range.- Overrides:
subtractin classNumberRange<T extends Number & Comparable<? super T>>- Parameters:
range- The range to substract.- Returns:
- This range without the given range.
- See Also:
-
Range.subtract(org.eclipse.imagen.util.Range)
-
equals
Compares this range with the specified object for equality. -
hashCode
public int hashCode()Description copied from class:RangeReturns a hash code value for this range.
-