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. |
Modifier and Type | Method and Description |
---|---|
static <T extends Comparable<T>> |
closed(T from,
T to)
Creates a new
Range with inclusive bounds for both values. |
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 . |
Range.Bound<T> |
getLowerBound() |
Range.Bound<T> |
getUpperBound() |
int |
hashCode() |
static <T extends Comparable<T>> |
just(T value)
Creates a new Range with the given value as sole member.
|
static <T extends Comparable<T>> |
leftOpen(T from,
T to)
Creates a new left-open
Range , i.e. left exclusive, right inclusive. |
static <T extends Comparable<T>> |
leftUnbounded(Range.Bound<T> to)
Creates a left-unbounded
Range (the left bound set to Range.Bound.unbounded() ) with the given right
bound. |
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. |
static <T extends Comparable<T>> |
open(T from,
T to)
Creates a new
Range with exclusive bounds for both values. |
static <T extends Comparable<T>> |
rightOpen(T from,
T to)
Creates a new right-open
Range , i.e. left inclusive, right exclusive. |
static <T extends Comparable<T>> |
rightUnbounded(Range.Bound<T> from)
Creates a right-unbounded
Range (the right bound set to Range.Bound.unbounded() ) with the given left
bound. |
String |
toString() |
static <T extends Comparable<T>> |
unbounded()
Returns an unbounded
Range . |
public static <T extends Comparable<T>> Range<T> unbounded()
Range
.public static <T extends Comparable<T>> Range<T> closed(T from, T to)
Range
with inclusive bounds for both values.T
- from
- must not be null.to
- must not be null.public static <T extends Comparable<T>> Range<T> open(T from, T to)
Range
with exclusive bounds for both values.T
- from
- must not be null.to
- must not be null.public static <T extends Comparable<T>> Range<T> leftOpen(T from, T to)
Range
, i.e. left exclusive, right inclusive.T
- from
- must not be null.to
- must not be null.public static <T extends Comparable<T>> Range<T> rightOpen(T from, T to)
Range
, i.e. left inclusive, right exclusive.T
- from
- must not be null.to
- must not be null.public static <T extends Comparable<T>> Range<T> leftUnbounded(Range.Bound<T> to)
Range
(the left bound set to Range.Bound.unbounded()
) with the given right
bound.T
- to
- the right Range.Bound
, must not be null.public static <T extends Comparable<T>> Range<T> rightUnbounded(Range.Bound<T> from)
Range
(the right bound set to Range.Bound.unbounded()
) with the given left
bound.T
- from
- the left Range.Bound
, must not be null.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. Prefer from(Bound)
for a more builder
style API.lowerBound
- must not be null.upperBound
- must not be null.from(Bound)
public static <T extends Comparable<T>> Range<T> just(T value)
T
- value
- must not be null.closed(Comparable, Comparable)
public boolean contains(T value)
Range
contains the given value.value
- must not be null.public Range.Bound<T> getLowerBound()
public Range.Bound<T> getUpperBound()
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.