Package groovy.lang
Class ObjectRange
- java.lang.Object
- 
- java.util.AbstractCollection<E>
- 
- java.util.AbstractList<Comparable>
- 
- groovy.lang.ObjectRange
 
 
 
- 
- All Implemented Interfaces:
- Range<Comparable>,- Iterable<Comparable>,- Collection<Comparable>,- List<Comparable>
 
 public class ObjectRange extends AbstractList<Comparable> implements Range<Comparable> 
- 
- 
Field Summary- 
Fields inherited from class java.util.AbstractListmodCount
 
- 
 - 
Constructor SummaryConstructors Constructor Description ObjectRange(Comparable from, Comparable to)Creates a newObjectRange.ObjectRange(Comparable smaller, Comparable larger, boolean reverse)Creates a newObjectRangeassumes smaller <= larger, else behavior is undefined.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckBoundaryCompatibility()throws IllegalArgumentException if to and from are incompatible, meaning they e.g.protected intcompareTo(Comparable first, Comparable second)booleancontains(Object value)Iterates over all values and returns true if one value matches.booleancontainsWithinBounds(Object value)Checks whether a value is between the from and to values of a Rangeprotected Objectdecrement(Object value)Decrements by onebooleanequals(ObjectRange that)Compares anObjectRangeto anotherObjectRange.booleanequals(Object that)Comparableget(int index)ComparablegetFrom()The lower value in the range.ComparablegetTo()The upper value in the range.protected Objectincrement(Object value)Increments by oneStringinspect()booleanisReverse()Indicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from valueIterator<Comparable>iterator()intsize()List<Comparable>step(int step)Forms a list by stepping through the range by the indicated interval.voidstep(int step, Closure closure)Steps through the range, calling a closure for each item.List<Comparable>subList(int fromIndex, int toIndex)StringtoString()- 
Methods inherited from class java.util.AbstractListadd, add, addAll, clear, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set
 - 
Methods inherited from class java.util.AbstractCollectionaddAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArray
 - 
Methods inherited from interface java.util.Listadd, add, addAll, addAll, clear, containsAll, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, toArray, toArray
 
- 
 
- 
- 
- 
Constructor Detail- 
ObjectRangepublic ObjectRange(Comparable from, Comparable to) - Parameters:
- from- the first value in the range.
- to- the last value in the range.
 
 - 
ObjectRangepublic ObjectRange(Comparable smaller, Comparable larger, boolean reverse) Creates a newObjectRangeassumes smaller <= larger, else behavior is undefined. Caution: Prefer the other constructor when in doubt.Optimized Constructor avoiding initial computation of comparison. 
 
- 
 - 
Method Detail- 
checkBoundaryCompatibilityprotected void checkBoundaryCompatibility() throws IllegalArgumentException if to and from are incompatible, meaning they e.g. (likely) produce infinite sequences. Called at construction time, subclasses may override cautiously (using only members to and from).
 - 
equalspublic boolean equals(Object that) - Specified by:
- equalsin interface- Collection<Comparable>
- Specified by:
- equalsin interface- List<Comparable>
- Overrides:
- equalsin class- AbstractList<Comparable>
 
 - 
equalspublic boolean equals(ObjectRange that) Compares anObjectRangeto anotherObjectRange.- Parameters:
- that- the object to check equality with
- Returns:
- trueif the ranges are equal
 
 - 
getFrompublic Comparable getFrom() Description copied from interface:RangeThe lower value in the range.- Specified by:
- getFromin interface- Range<Comparable>
- Returns:
- the lower value in the range.
 
 - 
getTopublic Comparable getTo() Description copied from interface:RangeThe upper value in the range.- Specified by:
- getToin interface- Range<Comparable>
- Returns:
- the upper value in the range
 
 - 
isReversepublic boolean isReverse() Description copied from interface:RangeIndicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from value- Specified by:
- isReversein interface- Range<Comparable>
- Returns:
- trueif this is a reverse range
 
 - 
getpublic Comparable get(int index) - Specified by:
- getin interface- List<Comparable>
- Specified by:
- getin class- AbstractList<Comparable>
 
 - 
containsWithinBoundspublic boolean containsWithinBounds(Object value) Checks whether a value is between the from and to values of a Range- Specified by:
- containsWithinBoundsin interface- Range<Comparable>
- Parameters:
- value- the value of interest
- Returns:
- true if the value is within the bounds
 
 - 
compareToprotected int compareTo(Comparable first, Comparable second) 
 - 
sizepublic int size() - Specified by:
- sizein interface- Collection<Comparable>
- Specified by:
- sizein interface- List<Comparable>
- Specified by:
- sizein class- AbstractCollection<Comparable>
 
 - 
subListpublic List<Comparable> subList(int fromIndex, int toIndex) - Specified by:
- subListin interface- List<Comparable>
- Overrides:
- subListin class- AbstractList<Comparable>
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- AbstractCollection<Comparable>
 
 - 
inspectpublic String inspect() 
 - 
containspublic boolean contains(Object value) Iterates over all values and returns true if one value matches.- Specified by:
- containsin interface- Collection<Comparable>
- Specified by:
- containsin interface- List<Comparable>
- Overrides:
- containsin class- AbstractCollection<Comparable>
- See Also:
- containsWithinBounds(Object)
 
 - 
steppublic void step(int step, Closure closure)Description copied from interface:RangeSteps through the range, calling a closure for each item.- Specified by:
- stepin interface- Range<Comparable>
- Parameters:
- step- the amount by which to step. If negative, steps through the range backwards.
- closure- the- Closureto call
 
 - 
iteratorpublic Iterator<Comparable> iterator() - Specified by:
- iteratorin interface- Collection<Comparable>
- Specified by:
- iteratorin interface- Iterable<Comparable>
- Specified by:
- iteratorin interface- List<Comparable>
- Overrides:
- iteratorin class- AbstractList<Comparable>
 
 - 
steppublic List<Comparable> step(int step) Description copied from interface:RangeForms a list by stepping through the range by the indicated interval.- Specified by:
- stepin interface- Range<Comparable>
- Parameters:
- step- the amount by which to step. If negative, steps through the range backwards.
- Returns:
- the list formed by stepping through the range by the indicated interval.
 
 - 
incrementprotected Object increment(Object value) Increments by one- Parameters:
- value- the value to increment
- Returns:
- the incremented value
 
 
- 
 
-