Package com.google.common.collect
Class GeneralRange<T>
- java.lang.Object
-
- com.google.common.collect.GeneralRange<T>
-
- All Implemented Interfaces:
java.io.Serializable
@GwtCompatible(serializable=true) final class GeneralRange<T> extends java.lang.Object implements java.io.Serializable
A generalized interval on any ordering, for internal use. Supportsnull
. UnlikeRange
, this allows the use of an arbitrary comparator. This is designed for use in the implementation of subcollections of sorted collection types.Whenever possible, use
Range
instead, which is better supported.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>
comparator
private boolean
hasLowerBound
private boolean
hasUpperBound
private BoundType
lowerBoundType
private T
lowerEndpoint
private GeneralRange<T>
reverse
private BoundType
upperBoundType
private T
upperEndpoint
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <T> GeneralRange<T>
all(java.util.Comparator<? super T> comparator)
Returns the whole range relative to the specified comparator.(package private) java.util.Comparator<? super T>
comparator()
(package private) boolean
contains(T t)
(package private) static <T> GeneralRange<T>
downTo(java.util.Comparator<? super T> comparator, T endpoint, BoundType boundType)
Returns everything above the endpoint relative to the specified comparator, with the specified endpoint behavior.boolean
equals(java.lang.Object obj)
(package private) static <T extends java.lang.Comparable>
GeneralRange<T>from(Range<T> range)
Converts a Range to a GeneralRange.(package private) BoundType
getLowerBoundType()
(package private) T
getLowerEndpoint()
(package private) BoundType
getUpperBoundType()
(package private) T
getUpperEndpoint()
int
hashCode()
(package private) boolean
hasLowerBound()
(package private) boolean
hasUpperBound()
(package private) GeneralRange<T>
intersect(GeneralRange<T> other)
Returns the intersection of the two ranges, or an empty range if their intersection is empty.(package private) boolean
isEmpty()
(package private) static <T> GeneralRange<T>
range(java.util.Comparator<? super T> comparator, T lower, BoundType lowerType, T upper, BoundType upperType)
Returns everything between the endpoints relative to the specified comparator, with the specified endpoint behavior.(package private) GeneralRange<T>
reverse()
Returns the same range relative to the reversed comparator.(package private) boolean
tooHigh(T t)
(package private) boolean
tooLow(T t)
java.lang.String
toString()
(package private) static <T> GeneralRange<T>
upTo(java.util.Comparator<? super T> comparator, T endpoint, BoundType boundType)
Returns everything below the endpoint relative to the specified comparator, with the specified endpoint behavior.
-
-
-
Field Detail
-
comparator
private final java.util.Comparator<? super T> comparator
-
hasLowerBound
private final boolean hasLowerBound
-
lowerEndpoint
@Nullable private final T lowerEndpoint
-
lowerBoundType
private final BoundType lowerBoundType
-
hasUpperBound
private final boolean hasUpperBound
-
upperEndpoint
@Nullable private final T upperEndpoint
-
upperBoundType
private final BoundType upperBoundType
-
reverse
private transient GeneralRange<T> reverse
-
-
Method Detail
-
from
static <T extends java.lang.Comparable> GeneralRange<T> from(Range<T> range)
Converts a Range to a GeneralRange.
-
all
static <T> GeneralRange<T> all(java.util.Comparator<? super T> comparator)
Returns the whole range relative to the specified comparator.
-
downTo
static <T> GeneralRange<T> downTo(java.util.Comparator<? super T> comparator, @Nullable T endpoint, BoundType boundType)
Returns everything above the endpoint relative to the specified comparator, with the specified endpoint behavior.
-
upTo
static <T> GeneralRange<T> upTo(java.util.Comparator<? super T> comparator, @Nullable T endpoint, BoundType boundType)
Returns everything below the endpoint relative to the specified comparator, with the specified endpoint behavior.
-
range
static <T> GeneralRange<T> range(java.util.Comparator<? super T> comparator, @Nullable T lower, BoundType lowerType, @Nullable T upper, BoundType upperType)
Returns everything between the endpoints relative to the specified comparator, with the specified endpoint behavior.
-
comparator
java.util.Comparator<? super T> comparator()
-
hasLowerBound
boolean hasLowerBound()
-
hasUpperBound
boolean hasUpperBound()
-
isEmpty
boolean isEmpty()
-
tooLow
boolean tooLow(@Nullable T t)
-
tooHigh
boolean tooHigh(@Nullable T t)
-
contains
boolean contains(@Nullable T t)
-
intersect
GeneralRange<T> intersect(GeneralRange<T> other)
Returns the intersection of the two ranges, or an empty range if their intersection is empty.
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
reverse
GeneralRange<T> reverse()
Returns the same range relative to the reversed comparator.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLowerEndpoint
T getLowerEndpoint()
-
getLowerBoundType
BoundType getLowerBoundType()
-
getUpperEndpoint
T getUpperEndpoint()
-
getUpperBoundType
BoundType getUpperBoundType()
-
-