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 SummaryNested ClassesModifier and TypeClassDescriptionstatic final classValue object representing a boundary.static classBuilder forRangeallowing to specify the upper boundary.
- 
Method SummaryModifier 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- 
unboundedReturns an unboundedRange.- Returns:
- Since:
- 2.0
 
- 
closedCreates 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
 
- 
openCreates 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
 
- 
leftOpenCreates 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
 
- 
rightOpenCreates 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
 
- 
leftUnboundedCreates a left-unboundedRange(the left bound set toRange.Bound.unbounded()) with the given right bound.- Type Parameters:
- T-
- Parameters:
- to- the right- Range.Bound, must not be null.
- Returns:
- Since:
- 2.2
 
- 
rightUnboundedCreates a right-unboundedRange(the right bound set toRange.Bound.unbounded()) with the given left bound.- Type Parameters:
- T-
- Parameters:
- from- the left- Range.Bound, must not be null.
- Returns:
- Since:
- 2.2
 
- 
fromCreate aRange.RangeBuildergiven the lowerRange.Bound.- Parameters:
- lower- must not be null.
- Returns:
- Since:
- 2.0
 
- 
ofCreates 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:
 
- 
justCreates a new Range with the given value as sole member.- Type Parameters:
- T-
- Parameters:
- value- must not be null.
- Returns:
- See Also:
 
- 
containsReturns whether theRangecontains the given value.- Parameters:
- value- must not be null.
- Returns:
 
- 
containsReturns whether theRangecontains the given value.- Parameters:
- value- must not be null.
- Returns:
- Since:
- 3.0
 
- 
mapApply a mappingFunctionto the lower and upper boundary values.- Type Parameters:
- R-
- Parameters:
- mapper- must not be null. If the mapper returns- null, then the corresponding boundary value represents an- Range.Bound.unbounded()boundary.
- Returns:
- a new Rangeafter applying the value to the mapper.
- Since:
- 3.0
 
- 
toString
- 
getLowerBound
- 
getUpperBound
- 
equals
- 
hashCodepublic int hashCode()
 
-