public final class DoubleRange extends NumberRange<Double>
NumberRange for Doubles.
This class is not designed to interoperate with other NumberRanges
| Modifier and Type | Method and Description |
|---|---|
double |
fit(double element)
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.
|
static DoubleRange |
of(double fromInclusive,
double toInclusive)
Creates a range with the specified minimum and maximum values (both inclusive).
|
static DoubleRange |
of(Double fromInclusive,
Double toInclusive)
Creates a range with the specified minimum and maximum values (both inclusive).
|
between, between, contains, containsRange, elementCompareTo, equals, fit, getComparator, getMaximum, getMinimum, hashCode, intersectionWith, is, is, isAfter, isAfterRange, isBefore, isBeforeRange, isEndedBy, isNaturalOrdering, isOverlappedBy, isStartedBy, of, toString, toStringpublic static DoubleRange of(double fromInclusive, double toInclusive)
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.
fromInclusive - the first value that defines the edge of the range, inclusive.toInclusive - the second value that defines the edge of the range, inclusive.public static DoubleRange of(Double fromInclusive, Double toInclusive)
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.
fromInclusive - the first value that defines the edge of the range, inclusive.toInclusive - the second value that defines the edge of the range, inclusive.IllegalArgumentException - if either element is null.public double fit(double element)
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
element - the element to test.Copyright © 2001–2026 The Apache Software Foundation. All rights reserved.