Class ObjectRange
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
groovy.lang.ObjectRange
- All Implemented Interfaces:
Range, Iterable, Collection, List, SequencedCollection
Represents an inclusive list of objects from a value to a value using
comparators.
This class is similar to
IntRange. If you make any changes to this
class, you might consider making parallel changes to IntRange.- Version:
- $Revision$
- Author:
- James Strachan
-
Field Summary
Fields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionObjectRange(Comparable from, Comparable to) Creates a newObjectRange.ObjectRange(Comparable from, Comparable to, boolean reverse) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleancontainsWithinBounds(Object value) Checks whether a value is between the from and to values of a Rangeprotected ObjectDecrements by onebooleanequals(ObjectRange that) Compares anObjectRangeto anotherObjectRange.booleanget(int index) getFrom()The lower value in the range.getTo()The upper value in the range.protected ObjectIncrements by oneinspect()booleanIndicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from valueiterator()intsize()step(int step) Forms a list by stepping through the range by the indicated interval.voidSteps through the range, calling a closure for each number.subList(int fromIndex, int toIndex) toString()Methods inherited from class AbstractList
add, add, addAll, clear, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, setMethods inherited from class AbstractCollection
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
add, add, addAll, addAll, addFirst, addLast, clear, containsAll, getFirst, getLast, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, sort, spliterator, toArray, toArray
-
Constructor Details
-
ObjectRange
- Parameters:
from- the first value in the range.to- the last value in the range.
-
ObjectRange
-
-
Method Details
-
equals
- Specified by:
equalsin interfaceCollection- Specified by:
equalsin interfaceList- Overrides:
equalsin classAbstractList
-
equals
Compares anObjectRangeto anotherObjectRange.- Parameters:
that- the object to check equality with- Returns:
trueif the ranges are equal
-
getFrom
The lower value in the range. -
getTo
The upper value in the range. -
isReverse
-
get
- Specified by:
getin interfaceList- Specified by:
getin classAbstractList
-
iterator
- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Specified by:
iteratorin interfaceList- Overrides:
iteratorin classAbstractList
-
containsWithinBounds
Checks whether a value is between the from and to values of a Range- Specified by:
containsWithinBoundsin interfaceRange- Parameters:
value- the value of interest- Returns:
- true if the value is within the bounds
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- Specified by:
sizein classAbstractCollection
-
subList
- Specified by:
subListin interfaceList- Overrides:
subListin classAbstractList
-
toString
- Overrides:
toStringin classAbstractCollection
-
inspect
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList- Overrides:
containsin classAbstractCollection
-
step
-
step
Forms a list by stepping through the range by the indicated interval. -
increment
-
decrement
-