Range
.@Deprecated @GwtCompatible @Beta public final class Ranges extends Object
Range
instances. Each of the
nine types of ranges
can be constructed with a corresponding
factory method:
(a..b)
open(C, C)
[a..b]
closed(C, C)
[a..b)
closedOpen(C, C)
(a..b]
openClosed(C, C)
(a..+∞)
greaterThan(C)
[a..+∞)
atLeast(C)
(-∞..b)
lessThan(C)
(-∞..b]
atMost(C)
(-∞..+∞)
all()
Additionally, Range
instances can be constructed by passing the
bound types
explicitly.
range(C, com.google.common.collect.BoundType, C, com.google.common.collect.BoundType)
(a..+∞)
or (a..+∞)
)
downTo(C, com.google.common.collect.BoundType)
(-∞..b)
or (-∞..b]
)
upTo(C, com.google.common.collect.BoundType)
See the Guava User Guide article on
Range
.
Modifier and Type | Method and Description |
---|---|
static <C extends Comparable<?>> |
all()
Deprecated.
Returns a range that contains every value of type
C . |
static <C extends Comparable<?>> |
atLeast(C endpoint)
Deprecated.
Returns a range that contains all values greater than or equal to
endpoint . |
static <C extends Comparable<?>> |
atMost(C endpoint)
Deprecated.
Returns a range that contains all values less than or equal to
endpoint . |
static <C extends Comparable<?>> |
closed(C lower,
C upper)
Deprecated.
Returns a range that contains all values greater than or equal to
lower and less than or equal to upper . |
static <C extends Comparable<?>> |
closedOpen(C lower,
C upper)
Deprecated.
Returns a range that contains all values greater than or equal to
lower and strictly less than upper . |
static <C extends Comparable<?>> |
downTo(C endpoint,
BoundType boundType)
Deprecated.
Returns a range from the given endpoint, which may be either inclusive
(closed) or exclusive (open), with no upper bound.
|
static <C extends Comparable<?>> |
encloseAll(Iterable<C> values)
Deprecated.
Returns the minimal range that
contains all of the given values.
|
static <C extends Comparable<?>> |
greaterThan(C endpoint)
Deprecated.
Returns a range that contains all values strictly greater than
endpoint . |
static <C extends Comparable<?>> |
lessThan(C endpoint)
Deprecated.
Returns a range that contains all values strictly less than
endpoint . |
static <C extends Comparable<?>> |
open(C lower,
C upper)
Deprecated.
Returns a range that contains all values strictly greater than
lower and strictly less than upper . |
static <C extends Comparable<?>> |
openClosed(C lower,
C upper)
Deprecated.
Returns a range that contains all values strictly greater than
lower and less than or equal to upper . |
static <C extends Comparable<?>> |
range(C lower,
BoundType lowerType,
C upper,
BoundType upperType)
Deprecated.
Returns a range that contains any value from
lower to upper , where each endpoint may be either inclusive (closed) or exclusive
(open). |
static <C extends Comparable<?>> |
singleton(C value)
Deprecated.
Returns a range that contains only
the given value.
|
static <C extends Comparable<?>> |
upTo(C endpoint,
BoundType boundType)
Deprecated.
Returns a range with no lower bound up to the given endpoint, which may be
either inclusive (closed) or exclusive (open).
|
public static <C extends Comparable<?>> Range<C> open(C lower, C upper)
lower
and strictly less than upper
.IllegalArgumentException
- if lower
is greater than or
equal to upper
public static <C extends Comparable<?>> Range<C> closed(C lower, C upper)
lower
and less than or equal to upper
.IllegalArgumentException
- if lower
is greater than upper
public static <C extends Comparable<?>> Range<C> closedOpen(C lower, C upper)
lower
and strictly less than upper
.IllegalArgumentException
- if lower
is greater than upper
public static <C extends Comparable<?>> Range<C> openClosed(C lower, C upper)
lower
and less than or equal to upper
.IllegalArgumentException
- if lower
is greater than upper
public static <C extends Comparable<?>> Range<C> range(C lower, BoundType lowerType, C upper, BoundType upperType)
lower
to upper
, where each endpoint may be either inclusive (closed) or exclusive
(open).IllegalArgumentException
- if lower
is greater than upper
public static <C extends Comparable<?>> Range<C> lessThan(C endpoint)
endpoint
.public static <C extends Comparable<?>> Range<C> atMost(C endpoint)
endpoint
.public static <C extends Comparable<?>> Range<C> upTo(C endpoint, BoundType boundType)
public static <C extends Comparable<?>> Range<C> greaterThan(C endpoint)
endpoint
.public static <C extends Comparable<?>> Range<C> atLeast(C endpoint)
endpoint
.public static <C extends Comparable<?>> Range<C> downTo(C endpoint, BoundType boundType)
public static <C extends Comparable<?>> Range<C> all()
C
.public static <C extends Comparable<?>> Range<C> singleton(C value)
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values)
ClassCastException
- if the parameters are not mutually
comparableNoSuchElementException
- if values
is emptyNullPointerException
- if any of values
is nullCopyright © 2010-2013. All Rights Reserved.