org.geotoolkit.util
Class NumberRange<T extends Number & Comparable<? super T>>

Object
  extended by Range
      extended by Range<T>
          extended by NumberRange<T>
Type Parameters:
T - The type of range elements as a subclass of Number.
All Implemented Interfaces:
Serializable, Formattable, CheckedContainer
Direct Known Subclasses:
MeasurementRange

Deprecated. moved to Apache SIS as NumberRange.

@Immutable
@Deprecated
public class NumberRange<T extends Number & Comparable<? super T>>
extends Range<T>

A range of numbers. Union and intersection are computed as usual, except that widening conversions will be applied as needed.

NumberRange has no units. For a range of physical measurements with units of measure, see MeasurementRange.

Since:
2.0
Version:
3.16
Author:
Martin Desruisseaux (IRD), Jody Garnett (Refractions)
See Also:
RangeFormat, Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Constructor Summary
NumberRange(Class<T> type, T minimum, boolean isMinIncluded, T maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of Number objects.
NumberRange(Class<T> type, T minimum, T maximum)
          Deprecated. Constructs an inclusive range of Number objects.
NumberRange(Class<T> type, ValueRange range)
          Deprecated. Creates a new range from the given annotation.
NumberRange(Range<T> range)
          Deprecated. Constructs a range with the same type and the same values than the specified range.
 
Method Summary
<N extends Number & Comparable<? super N>>
NumberRange<N>
castTo(Class<N> type)
          Deprecated. Casts this range to the specified type.
 boolean contains(Comparable value)
          Deprecated. Returns true if the specified value is within this range.
 boolean contains(Number value)
          Deprecated. Returns true if the specified value is within this range.
 boolean contains(Range<?> range)
          Deprecated. Returns true if the supplied range is fully contained within this range.
static NumberRange<Byte> create(byte minimum, boolean isMinIncluded, byte maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of byte values.
static NumberRange<Byte> create(byte minimum, byte maximum)
          Deprecated. Constructs an inclusive range of byte values.
static NumberRange<Double> create(double minimum, boolean isMinIncluded, double maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of double values.
static NumberRange<Double> create(double minimum, double maximum)
          Deprecated. Constructs an inclusive range of double values.
static NumberRange<Float> create(float minimum, boolean isMinIncluded, float maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of float values.
static NumberRange<Float> create(float minimum, float maximum)
          Deprecated. Constructs an inclusive range of float values.
static NumberRange<Integer> create(int minimum, boolean isMinIncluded, int maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of int values.
static NumberRange<Integer> create(int minimum, int maximum)
          Deprecated. Constructs an inclusive range of int values.
static NumberRange<Long> create(long minimum, boolean isMinIncluded, long maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of long values.
static NumberRange<Long> create(long minimum, long maximum)
          Deprecated. Constructs an inclusive range of long values.
static NumberRange<Short> create(short minimum, boolean isMinIncluded, short maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range of short values.
static NumberRange<Short> create(short minimum, short maximum)
          Deprecated. Constructs an inclusive range of short values.
static NumberRange<?> createBestFit(Number minimum, boolean isMinIncluded, Number maximum, boolean isMaxIncluded)
          Deprecated. Constructs a range using the smallest type of Number that can hold the given values.
 double getMaximum()
          Deprecated. Returns the maximum value as a double.
 double getMaximum(boolean inclusive)
          Deprecated. Returns the maximum value with the specified inclusive or exclusive state.
 double getMinimum()
          Deprecated. Returns the minimum value as a double.
 double getMinimum(boolean inclusive)
          Deprecated. Returns the minimum value with the specified inclusive or exclusive state.
 NumberRange<?> intersect(Range<?> range)
          Deprecated. Returns the intersection between this range and the provided range.
 boolean intersects(Range<?> range)
          Deprecated. Returns true if this range intersects the given range.
 NumberRange<?>[] subtract(Range<?> range)
          Deprecated. Returns the range of values that are in this range but not in the given range.
 NumberRange<?> union(Range<?> range)
          Deprecated. Returns the union of this range with the given range.
static
<N extends Number & Comparable<? super N>>
NumberRange<N>
wrap(Range<N> range)
          Deprecated. Wraps the specified Range in a NumberRange object.
 
Methods inherited from class Range
equals, getElementType, getMaxValue, getMinValue, hashCode, isMaxIncluded, isMinIncluded, toString
 
Methods inherited from class Range
contains, formatTo, intersect, intersects, isEmpty, subtract, union
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberRange

public NumberRange(Class<T> type,
                   T minimum,
                   T maximum)
Deprecated. 
Constructs an inclusive range of Number objects.

Parameters:
type - The element class, usually one of Byte, Short, Integer, Long, Float or Double.
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(Class<T> type,
                   T minimum,
                   boolean isMinIncluded,
                   T maximum,
                   boolean isMaxIncluded)
Deprecated. 
Constructs a range of Number objects.

Parameters:
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.

NumberRange

public NumberRange(Class<T> type,
                   ValueRange range)
Deprecated. 
Creates a new range from the given annotation.

Parameters:
type - The element class, usually one of Byte, Short, Integer, Long, Float or Double.
range - The range of value.
Since:
3.04

NumberRange

public NumberRange(Range<T> range)
Deprecated. 
Constructs a range with the same type and the same values than the specified range. This is a copy constructor.

Parameters:
range - The range to copy. The elements must be Number instances.
Since:
2.4
Method Detail

create

public static NumberRange<Byte> create(byte minimum,
                                       byte maximum)
Deprecated. 
Constructs an inclusive range of byte values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Byte> create(byte minimum,
                                       boolean isMinIncluded,
                                       byte maximum,
                                       boolean isMaxIncluded)
Deprecated. 
Constructs a range of byte values.

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.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Short> create(short minimum,
                                        short maximum)
Deprecated. 
Constructs an inclusive range of short values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Short> create(short minimum,
                                        boolean isMinIncluded,
                                        short maximum,
                                        boolean isMaxIncluded)
Deprecated. 
Constructs a range of short values.

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.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Integer> create(int minimum,
                                          int maximum)
Deprecated. 
Constructs an inclusive range of int values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Integer> create(int minimum,
                                          boolean isMinIncluded,
                                          int maximum,
                                          boolean isMaxIncluded)
Deprecated. 
Constructs a range of int values.

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.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Long> create(long minimum,
                                       long maximum)
Deprecated. 
Constructs an inclusive range of long values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Long> create(long minimum,
                                       boolean isMinIncluded,
                                       long maximum,
                                       boolean isMaxIncluded)
Deprecated. 
Constructs a range of long values.

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.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Float> create(float minimum,
                                        float maximum)
Deprecated. 
Constructs an inclusive range of float values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Float> create(float minimum,
                                        boolean isMinIncluded,
                                        float maximum,
                                        boolean isMaxIncluded)
Deprecated. 
Constructs a range of float values.

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.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Double> create(double minimum,
                                         double maximum)
Deprecated. 
Constructs an inclusive range of double values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.
Returns:
The new range.
Since:
2.5

create

public static NumberRange<Double> create(double minimum,
                                         boolean isMinIncluded,
                                         double maximum,
                                         boolean isMaxIncluded)
Deprecated. 
Constructs a range of double values.

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.
Returns:
The new range.
Since:
2.5

createBestFit

public static NumberRange<?> createBestFit(Number minimum,
                                           boolean isMinIncluded,
                                           Number maximum,
                                           boolean isMaxIncluded)
Deprecated. 
Constructs a range using the smallest type of Number that can hold the given values. The given numbers don't need to be of the same type since they will be casted as needed. More specifically:

Parameters:
minimum - The minimum value, or null for negative infinity.
isMinIncluded - Defines whether the minimum value is included in the range.
maximum - The maximum value, or null for positive infinity.
isMaxIncluded - Defines whether the maximum value is included in the range.
Returns:
The new range, or null if both minimum and maximum are null.
Since:
3.06

wrap

public static <N extends Number & Comparable<? super N>> NumberRange<N> wrap(Range<N> range)
Deprecated. 
Wraps the specified Range in a NumberRange object. If the specified range is already an instance of NumberRange, then it is returned unchanged.

Type Parameters:
N - The type of elements in the given range.
Parameters:
range - The range to wrap.
Returns:
The same range than range as a NumberRange object.

castTo

public <N extends Number & Comparable<? super N>> NumberRange<N> castTo(Class<N> type)
                                                            throws IllegalArgumentException
Deprecated. 
Casts this range to the specified type.

Type Parameters:
N - The class to cast to.
Parameters:
type - The class to cast to. Must be one of Byte, Short, Integer, Long, Float or Double.
Returns:
The casted range, or this if this range already uses the specified type.
Throws:
IllegalArgumentException - if the values are not convertible to the specified class.

contains

public boolean contains(Number value)
                 throws IllegalArgumentException
Deprecated. 
Returns true if the specified value is within this range.

Parameters:
value - The value to check for inclusion.
Returns:
true if the given value is within this range.
Throws:
IllegalArgumentException - if the given value is not comparable.

contains

public boolean contains(Comparable value)
                 throws IllegalArgumentException
Deprecated. 
Returns true if the specified value is within this range. The given value must be a subclass of Number.

Overrides:
contains in class Range<T extends Number & Comparable<? super T>>
Parameters:
value - The value to check for inclusion in this range.
Returns:
true if the given value is included in this range.
Throws:
IllegalArgumentException - if the given value is not a subclass of Number.

contains

public boolean contains(Range<?> range)
                 throws IllegalArgumentException
Deprecated. 
Returns true if the supplied range is fully contained within this range.

Overrides:
contains in class Range<T extends Number & Comparable<? super T>>
Parameters:
range - The range to check for inclusion in this range.
Returns:
true if the given range is included in this range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.

intersects

public boolean intersects(Range<?> range)
                   throws IllegalArgumentException
Deprecated. 
Returns true if this range intersects the given range.

Overrides:
intersects in class Range<T extends Number & Comparable<? super T>>
Parameters:
range - The range to check for intersection with this range.
Returns:
true if the given range intersects this range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
See Also:
Range.intersects(javax.media.jai.util.Range)

union

public NumberRange<?> union(Range<?> range)
                     throws IllegalArgumentException
Deprecated. 
Returns the union of this range with the given range. Widening conversions will be applied as needed.

Overrides:
union in class Range<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.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
See Also:
Range.union(javax.media.jai.util.Range)

intersect

public NumberRange<?> intersect(Range<?> range)
                         throws IllegalArgumentException
Deprecated. 
Returns the intersection between this range and the provided range. Widening conversions will be applied as needed.

Overrides:
intersect in class Range<T extends Number & Comparable<? super T>>
Parameters:
range - The range to intersect.
Returns:
The intersection of this range with the provided range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
See Also:
Range.intersect(javax.media.jai.util.Range)

subtract

public NumberRange<?>[] subtract(Range<?> range)
                          throws IllegalArgumentException
Deprecated. 
Returns the range of values that are in this range but not in the given range. This method returns an array of length 0, 1 or 2:

Overrides:
subtract in class Range<T extends Number & Comparable<? super T>>
Parameters:
range - The range to subtract.
Returns:
This range without the given range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
See Also:
Range.subtract(javax.media.jai.util.Range)

getMinimum

public double getMinimum()
Deprecated. 
Returns the minimum value as a double. If this range is unbounded, then Double.NEGATIVE_INFINITY is returned.

Returns:
The minimum value.

getMinimum

public double getMinimum(boolean inclusive)
Deprecated. 
Returns the minimum value with the specified inclusive or exclusive state. If this range is unbounded, then Double.NEGATIVE_INFINITY is returned.

Parameters:
inclusive - true for the minimum value inclusive, or false for the minimum value exclusive.
Returns:
The minimum value, inclusive or exclusive as requested.

getMaximum

public double getMaximum()
Deprecated. 
Returns the maximum value as a double. If this range is unbounded, then Double.POSITIVE_INFINITY is returned.

Returns:
The maximum value.

getMaximum

public double getMaximum(boolean inclusive)
Deprecated. 
Returns the maximum value with the specified inclusive or exclusive state. If this range is unbounded, then Double.POSITIVE_INFINITY is returned.

Parameters:
inclusive - true for the maximum value inclusive, or false for the maximum value exclusive.
Returns:
The maximum value, inclusive or exclusive as requested.


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.