Top Description Fields Constructors Methods
org.apache.commons.lang3

public final Class DoubleRange

extends NumberRange<Double>
Class Inheritance

Specializes NumberRange for Doubles.

This class is not designed to interoperate with other NumberRanges

Since
3.13.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
private
DoubleRange(final Double
the first element, not null
number1
,
final Double
the second element, not null
number2
)

Creates an instance.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

the minimum, the element, or the maximum depending on the element's location relative to the range.
fit
(final double
the element to test.
element
)

Overrides org.apache.commons.lang3.Range.fit.

Fits the given value into this range by returning the given value or, if out of bounds, the range minimum if below, or the range maximum if above.

public static DoubleRange

Returns:

the range object, not null.
of
(final double
the first value that defines the edge of the range, inclusive.
fromInclusive
,
final double
the second value that defines the edge of the range, inclusive.
toInclusive
)

Hides org.apache.commons.lang3.Range.of.

Creates a range with the specified minimum and maximum values (both inclusive).

public static DoubleRange

Returns:

the range object, not null.
of
(final Double
the first value that defines the edge of the range, inclusive.
fromInclusive
,
final Double
the second value that defines the edge of the range, inclusive.
toInclusive
)

Hides org.apache.commons.lang3.Range.of.

Creates a range with the specified minimum and maximum values (both inclusive).

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.lang3.NumberRange.serialVersionUID.

Constructor Detail

DoubleRangeback to summary
private DoubleRange(final Double number1, final Double number2)

Creates an instance.

Parameters
number1:Double

the first element, not null

number2:Double

the second element, not null

Exceptions
NullPointerException:
  • when element1 is null.
  • when element2 is null.

Method Detail

fitback to summary
public double fit(final double element)

Overrides org.apache.commons.lang3.Range.fit.

Fits the given value into this range by returning the given value or, if out of bounds, the range minimum if below, or the range maximum if above.

LongRange range = LongRange.of(16, 64);
range.fit(-9) -->  16
range.fit(0)  -->  16
range.fit(15) -->  16
range.fit(16) -->  16
range.fit(17) -->  17
...
range.fit(63) -->  63
range.fit(64) -->  64
range.fit(99) -->  64
Parameters
element:double

the element to test.

Returns:double

the minimum, the element, or the maximum depending on the element's location relative to the range.

Since
3.19.0
ofback to summary
public static DoubleRange of(final double fromInclusive, final double toInclusive)

Hides org.apache.commons.lang3.Range.of.

Creates a range with the specified minimum and maximum values (both inclusive).

The range uses the natural ordering of the elements to determine where values lie in the range.

The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.

Parameters
fromInclusive:double

the first value that defines the edge of the range, inclusive.

toInclusive:double

the second value that defines the edge of the range, inclusive.

Returns:DoubleRange

the range object, not null.

ofback to summary
public static DoubleRange of(final Double fromInclusive, final Double toInclusive)

Hides org.apache.commons.lang3.Range.of.

Creates a range with the specified minimum and maximum values (both inclusive).

The range uses the natural ordering of the elements to determine where values lie in the range.

The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.

Parameters
fromInclusive:Double

the first value that defines the edge of the range, inclusive.

toInclusive:Double

the second value that defines the edge of the range, inclusive.

Returns:DoubleRange

the range object, not null.

Exceptions
IllegalArgumentException:
if either element is null.