Class Range<T>
java.lang.Object
org.hibernate.search.util.common.data.Range<T>
- Type Parameters:
T
- The type of values in this range.
A representation of a range that can be used with any type.
Because there are no restrictions on type of values that can be used with this Range
class,
it is not able to "understand" values that are passed to its various factory methods.
As a result, only minimal consistency checks are performed: null-checks, mostly.
In particular, this class does not check that the lower bound is actually lower than the upper bound,
because it has no idea what ordering to use.
Checking the relative order of bounds is the responsibility of callers of the lowerBoundValue()
and upperBoundValue()
methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Range<T>
all()
static <T> Range<T>
atLeast
(T lowerBoundValue) static <T> Range<T>
atMost
(T upperBoundValue) static <T> Range<T>
between
(T lowerBoundValue, RangeBoundInclusion lowerBoundInclusion, T upperBoundValue, RangeBoundInclusion upperBoundInclusion) static <T> Range<T>
between
(T lowerBoundValue, T upperBoundValue) static <T> Range<T>
canonical
(T lowerBoundValue, T upperBoundValue) Create a canonical range, i.e.boolean
static <T> Range<T>
greaterThan
(T lowerBoundValue) int
hashCode()
static <T> Range<T>
lessThan
(T upperBoundValue) <R> Range<R>
toString()
-
Method Details
-
canonical
Create a canonical range, i.e. a range in the form[lowerBoundValue, upperBoundValue)
(lower bound included, upper bound excluded), or[lowerBoundValue, +Infinity]
(both bounds included) if the upper bound is+Infinity
.This is mostly useful when creating multiple, contiguous ranges, like for example in range aggregations.
- Type Parameters:
T
- The type of range bounds.- Parameters:
lowerBoundValue
- The lower bound of the range. May benull
to represent-Infinity
(no lower bound),upperBoundValue
- The upper bound of the range. May benull
to represent+Infinity
(no upper bound).- Returns:
- The range
[lowerBoundValue, upperBoundValue)
(lower bound included, upper bound excluded), or[lowerBoundValue, +Infinity]
(both bounds included) if the upper bound is+Infinity
.
-
all
- Type Parameters:
T
- The type of range bounds.- Returns:
- The range
[-Infinity, +Infinity]
(both bounds included).
-
between
- Type Parameters:
T
- The type of range bounds.- Parameters:
lowerBoundValue
- The lower bound of the range. May benull
to represent-Infinity
(no lower bound),upperBoundValue
- The upper bound of the range. May benull
to represent+Infinity
(no upper bound).- Returns:
- The range
[lowerBoundValue, upperBoundValue]
(both bounds included).
-
between
public static <T> Range<T> between(T lowerBoundValue, RangeBoundInclusion lowerBoundInclusion, T upperBoundValue, RangeBoundInclusion upperBoundInclusion) - Type Parameters:
T
- The type of range bounds.- Parameters:
lowerBoundValue
- The value of the lower bound of the range. May benull
to represent-Infinity
(no lower bound).lowerBoundInclusion
- Whether the lower bound is included in the range or excluded.upperBoundValue
- The value of the upper bound of the range. May benull
to represent+Infinity
(no upper bound).upperBoundInclusion
- Whether the upper bound is included in the range or excluded.- Returns:
- A
Range
.
-
atLeast
- Type Parameters:
T
- The type of range bounds.- Parameters:
lowerBoundValue
- The value of the lower bound of the range. Must not benull
.- Returns:
- The range
[lowerBoundValue, +Infinity]
(both bounds included).
-
greaterThan
- Type Parameters:
T
- The type of range bounds.- Parameters:
lowerBoundValue
- The value of the lower bound of the range. Must not benull
.- Returns:
- The range
(lowerBoundValue, +Infinity]
(lower bound excluded, upper bound included).
-
atMost
- Type Parameters:
T
- The type of range bounds.- Parameters:
upperBoundValue
- The value of the upper bound of the range. Must not benull
.- Returns:
- The range
[-Infinity, upperBoundValue]
(both bounds included).
-
lessThan
- Type Parameters:
T
- The type of range bounds.- Parameters:
upperBoundValue
- The value of the upper bound of the range. Must not benull
.- Returns:
- The range
[-Infinity, upperBoundValue)
(lower bound included, upper bound excluded).
-
toString
-
equals
-
hashCode
public int hashCode() -
lowerBoundValue
- Returns:
- The value of the lower bound, or an empty optional to represent {-Infinity} (no lower bound).
-
lowerBoundInclusion
- Returns:
- Whether the lower bound is included in the range or excluded.
Always
RangeBoundInclusion.EXCLUDED
if there is no lower bound.
-
upperBoundValue
- Returns:
- The value of the lower bound, or an empty optional to represent {+Infinity} (no upper bound).
-
upperBoundInclusion
- Returns:
- Whether the upper bound is included in the range or excluded.
Always
RangeBoundInclusion.EXCLUDED
if there is no upper bound.
-
map
-