Package org.springframework.data.domain
Class Range<T>
java.lang.Object
org.springframework.data.domain.Range<T>
Simple value object to work with ranges and boundaries.
- Since:
- 1.10
- Author:
- Oliver Gierke, Mark Paluch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classValue object representing a boundary.static classBuilder forRangeallowing to specify the upper boundary. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Range<T>closed(T from, T to) Creates a newRangewith inclusive bounds for both values.booleancontains(Comparable<T> value) Returns whether theRangecontains the given value.booleancontains(T value, Comparator<T> comparator) Returns whether theRangecontains the given value.booleanstatic <T> Range.RangeBuilder<T>from(Range.Bound<T> lower) Create aRange.RangeBuildergiven the lowerRange.Bound.inthashCode()static <T> Range<T>just(T value) Creates a new Range with the given value as sole member.static <T> Range<T>leftOpen(T from, T to) Creates a new left-openRange, i.e. left exclusive, right inclusive.static <T> Range<T>leftUnbounded(Range.Bound<T> to) Creates a left-unboundedRange(the left bound set toRange.Bound.unbounded()) with the given right bound.<R> Range<R>Apply a mappingFunctionto the lower and upper boundary values.static <T> Range<T>of(Range.Bound<T> lowerBound, Range.Bound<T> upperBound) Creates a newRangewith the given lower and upper bound.static <T> Range<T>open(T from, T to) Creates a newRangewith exclusive bounds for both values.static <T> Range<T>rightOpen(T from, T to) Creates a new right-openRange, i.e. left inclusive, right exclusive.static <T> Range<T>rightUnbounded(Range.Bound<T> from) Creates a right-unboundedRange(the right bound set toRange.Bound.unbounded()) with the given left bound.toString()static <T> Range<T>Returns an unboundedRange.
-
Method Details
-
unbounded
Returns an unboundedRange.- Returns:
- Since:
- 2.0
-
closed
Creates a newRangewith inclusive bounds for both values.- Type Parameters:
T-- Parameters:
from- must not be null.to- must not be null.- Returns:
- Since:
- 2.2
-
open
Creates a newRangewith exclusive bounds for both values.- Type Parameters:
T-- Parameters:
from- must not be null.to- must not be null.- Returns:
- Since:
- 2.2
-
leftOpen
Creates a new left-openRange, i.e. left exclusive, right inclusive.- Type Parameters:
T-- Parameters:
from- must not be null.to- must not be null.- Returns:
- Since:
- 2.2
-
rightOpen
Creates a new right-openRange, i.e. left inclusive, right exclusive.- Type Parameters:
T-- Parameters:
from- must not be null.to- must not be null.- Returns:
- Since:
- 2.2
-
leftUnbounded
Creates a left-unboundedRange(the left bound set toRange.Bound.unbounded()) with the given right bound.- Type Parameters:
T-- Parameters:
to- the rightRange.Bound, must not be null.- Returns:
- Since:
- 2.2
-
rightUnbounded
Creates a right-unboundedRange(the right bound set toRange.Bound.unbounded()) with the given left bound.- Type Parameters:
T-- Parameters:
from- the leftRange.Bound, must not be null.- Returns:
- Since:
- 2.2
-
from
Create aRange.RangeBuildergiven the lowerRange.Bound.- Parameters:
lower- must not be null.- Returns:
- Since:
- 2.0
-
of
Creates a newRangewith the given lower and upper bound. Preferfrom(Bound)for a more builder style API.- Parameters:
lowerBound- must not be null.upperBound- must not be null.- Since:
- 2.0
- See Also:
-
just
Creates a new Range with the given value as sole member.- Type Parameters:
T-- Parameters:
value- must not be null.- Returns:
- See Also:
-
contains
Returns whether theRangecontains the given value.- Parameters:
value- must not be null.- Returns:
-
contains
Returns whether theRangecontains the given value.- Parameters:
value- must not be null.- Returns:
- Since:
- 3.0
-
map
Apply a mappingFunctionto the lower and upper boundary values.- Type Parameters:
R-- Parameters:
mapper- must not be null. If the mapper returnsnull, then the corresponding boundary value represents anRange.Bound.unbounded()boundary.- Returns:
- a new
Rangeafter applying the value to the mapper. - Since:
- 3.0
-
toString
-
getLowerBound
-
getUpperBound
-
equals
-
hashCode
public int hashCode()
-