Package org.springframework.data.domain
Class Range<T extends Comparable<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
Modifier and TypeClassDescriptionstatic final class
Range.Bound<T extends Comparable<T>>
Value object representing a boundary.static class
Range.RangeBuilder<T extends Comparable<T>>
Builder forRange
allowing to specify the upper boundary. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
Range<T>closed
(T from, T to) Creates a newRange
with inclusive bounds for both values.boolean
Returns whether theRange
contains the given value.boolean
static <T extends Comparable<T>>
Range.RangeBuilder<T>from
(Range.Bound<T> lower) Create aRange.RangeBuilder
given the lowerRange.Bound
.int
hashCode()
static <T extends Comparable<T>>
Range<T>just
(T value) Creates a new Range with the given value as sole member.static <T extends Comparable<T>>
Range<T>leftOpen
(T from, T to) Creates a new left-openRange
, i.e. left exclusive, right inclusive.static <T extends Comparable<T>>
Range<T>leftUnbounded
(Range.Bound<T> to) Creates a left-unboundedRange
(the left bound set toRange.Bound.unbounded()
) with the given right bound.static <T extends Comparable<T>>
Range<T>of
(Range.Bound<T> lowerBound, Range.Bound<T> upperBound) Creates a newRange
with the given lower and upper bound.static <T extends Comparable<T>>
Range<T>open
(T from, T to) Creates a newRange
with exclusive bounds for both values.static <T extends Comparable<T>>
Range<T>rightOpen
(T from, T to) Creates a new right-openRange
, i.e. left inclusive, right exclusive.static <T extends Comparable<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 extends Comparable<T>>
Range<T>Returns an unboundedRange
.
-
Method Details
-
unbounded
Returns an unboundedRange
.- Returns:
- Since:
- 2.0
-
closed
Creates a newRange
with 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 newRange
with 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.RangeBuilder
given the lowerRange.Bound
.- Parameters:
lower
- must not be null.- Returns:
- Since:
- 2.0
-
of
public static <T extends Comparable<T>> Range<T> of(Range.Bound<T> lowerBound, Range.Bound<T> upperBound) Creates a newRange
with 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 theRange
contains the given value.- Parameters:
value
- must not be null.- Returns:
-
toString
-
getLowerBound
-
getUpperBound
-
equals
-
hashCode
public int hashCode()
-