groovy.lang
Class ObjectRange
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
groovy.lang.ObjectRange
- All Implemented Interfaces:
- java.util.Collection, java.util.List, Range
- public class ObjectRange
- extends java.util.AbstractList
- implements Range
Represents an inclusive list of objects from a value to a value using
comparators
- Version:
- $Revision: 1.14 $
- Author:
- James Strachan
Nested classes inherited from class java.util.AbstractList |
|
Field Summary |
private java.lang.Comparable |
from
|
private boolean |
reverse
|
private int |
size
|
private java.lang.Comparable |
to
|
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary |
ObjectRange(java.lang.Comparable from,
java.lang.Comparable to)
|
ObjectRange(java.lang.Comparable from,
java.lang.Comparable to,
boolean reverse)
|
Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set |
Methods inherited from class java.util.AbstractCollection |
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
add, add, addAll, addAll, clear, contains, containsAll, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, toArray, toArray |
from
private java.lang.Comparable from
to
private java.lang.Comparable to
size
private int size
reverse
private final boolean reverse
ObjectRange
public ObjectRange(java.lang.Comparable from,
java.lang.Comparable to)
ObjectRange
public ObjectRange(java.lang.Comparable from,
java.lang.Comparable to,
boolean reverse)
constructorHelper
private void constructorHelper(java.lang.Comparable from,
java.lang.Comparable to)
hashCode
public int hashCode()
- Specified by:
hashCode
in interface java.util.List
equals
public boolean equals(java.lang.Object that)
- Specified by:
equals
in interface java.util.List
equals
public boolean equals(ObjectRange that)
equals
public boolean equals(java.util.List that)
getFrom
public java.lang.Comparable getFrom()
- Specified by:
getFrom
in interface Range
- Returns:
- the lower value in the range
getTo
public java.lang.Comparable getTo()
- Specified by:
getTo
in interface Range
- Returns:
- the upper value in the range
isReverse
public boolean isReverse()
- Specified by:
isReverse
in interface Range
- Returns:
- true if this is a reverse range, iterating backwards
starting from the to value and ending on the from value
get
public java.lang.Object get(int index)
- Specified by:
get
in interface java.util.List
iterator
public java.util.Iterator iterator()
- Specified by:
iterator
in interface java.util.List
size
public int size()
- Specified by:
size
in interface java.util.List
subList
public java.util.List subList(int fromIndex,
int toIndex)
- Specified by:
subList
in interface java.util.List
toString
public java.lang.String toString()
inspect
public java.lang.String inspect()
- Specified by:
inspect
in interface Range
- Returns:
- the verbose String representation of this Range as would be typed into a console
to create the Range instance
contains
public boolean contains(java.lang.Comparable value)
step
public void step(int step,
Closure closure)
step
public java.util.List step(int step)
increment
protected java.lang.Object increment(java.lang.Object value)
decrement
protected java.lang.Object decrement(java.lang.Object value)
normaliseType
private static java.lang.Comparable normaliseType(java.lang.Comparable operand)
Copyright © 2003-2005 The Codehaus. All Rights Reserved.