public final class Range<T extends Comparable<T>> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Range.Bound<T extends Comparable<T>>
Value object representing a boundary.
|
static class |
Range.RangeBuilder<T extends Comparable<T>>
Builder for
Range allowing to specify the upper boundary. |
Constructor and Description |
---|
Range(T lowerBound,
T upperBound)
Deprecated.
since 2.0 in favor of
of(Bound, Bound) . |
Range(T lowerBound,
T upperBound,
boolean lowerInclusive,
boolean upperInclusive)
Deprecated.
since 2.0. Use
of(Bound, Bound) and Range.Bound factory methods:
Range.Bound.inclusive(Comparable) , Range.Bound.exclusive(Comparable) /Range.Bound.unbounded() . |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(T value)
Returns whether the
Range contains the given value. |
boolean |
equals(Object o) |
static <T extends Comparable<T>> |
from(Range.Bound<T> lower)
Create a
Range.RangeBuilder given the lower Range.Bound . |
@NonNull Range.Bound<T> |
getLowerBound()
The lower bound of the range.
|
@NonNull Range.Bound<T> |
getUpperBound()
The upper bound of the range.
|
int |
hashCode() |
boolean |
isLowerInclusive()
Deprecated.
since 2.0, use
getLowerBound() and Range.Bound.isInclusive() . |
boolean |
isUpperInclusive()
Deprecated.
since 2.0, use
getUpperBound() and Range.Bound.isInclusive() . |
static <T extends Comparable<T>> |
of(Range.Bound<T> lowerBound,
Range.Bound<T> upperBound)
Creates a new
Range with the given lower and upper bound. |
String |
toString() |
static <T extends Comparable<T>> |
unbounded()
Returns an unbounded
Range . |
@Deprecated public Range(T lowerBound, T upperBound)
of(Bound, Bound)
.Range
with the given lower and upper bound. Treats the given values as inclusive bounds. Use
Range(Comparable, Comparable, boolean, boolean)
to configure different bound behavior.lowerBound
- can be null in case upperBound is not null.upperBound
- can be null in case lowerBound is not null.of(Bound, Bound)
@Deprecated public Range(T lowerBound, T upperBound, boolean lowerInclusive, boolean upperInclusive)
of(Bound, Bound)
and Range.Bound
factory methods:
Range.Bound.inclusive(Comparable)
, Range.Bound.exclusive(Comparable)
/Range.Bound.unbounded()
.Range
with the given lower and upper bound as well as the given inclusive/exclusive
semantics.lowerBound
- can be null.upperBound
- can be null.lowerInclusive
- upperInclusive
- public static <T extends Comparable<T>> Range<T> unbounded()
Range
.public static <T extends Comparable<T>> Range.RangeBuilder<T> from(Range.Bound<T> lower)
Range.RangeBuilder
given the lower Range.Bound
.lower
- must not be null.public static <T extends Comparable<T>> Range<T> of(Range.Bound<T> lowerBound, Range.Bound<T> upperBound)
Range
with the given lower and upper bound.lowerBound
- must not be null.upperBound
- must not be null.@Deprecated public boolean isLowerInclusive()
getLowerBound()
and Range.Bound.isInclusive()
.@Deprecated public boolean isUpperInclusive()
getUpperBound()
and Range.Bound.isInclusive()
.public boolean contains(T value)
Range
contains the given value.value
- must not be null.@NonNull public @NonNull Range.Bound<T> getLowerBound()
@NonNull public @NonNull Range.Bound<T> getUpperBound()
Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.