Package groovy.lang
Class EmptyRange
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList
-
- groovy.lang.EmptyRange
-
- All Implemented Interfaces:
Range,Iterable,Collection,List
public class EmptyRange extends AbstractList implements Range
Constructing Ranges like 0..<0
-
-
Field Summary
Fields Modifier and Type Field Description protected ComparableatThe value at which the range originates (may benull).-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description EmptyRange(Comparable at)Creates a newEmptyRange.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Object o)Always throwsUnsupportedOperationExceptionfor an empty range.booleanaddAll(int index, Collection c)Always throwsUnsupportedOperationExceptionfor an empty range.booleanaddAll(Collection c)Always throwsUnsupportedOperationExceptionfor an empty range.booleancontainsWithinBounds(Object o)Never true for an empty range.Objectget(int index)Always throwsIndexOutOfBoundsExceptionfor an empty range.ComparablegetFrom()The lower value in the range.ComparablegetTo()The upper value in the range.Stringinspect()booleanisReverse()Never true for an empty range.Objectremove(int index)Always throwsUnsupportedOperationExceptionfor an empty range.booleanremove(Object o)Always throwsUnsupportedOperationExceptionfor an empty range.booleanremoveAll(Collection c)Always throwsUnsupportedOperationExceptionfor an empty range.booleanretainAll(Collection c)Always throwsUnsupportedOperationExceptionfor an empty range.Objectset(int index, Object element)Always throwsUnsupportedOperationExceptionfor an empty range.intsize()Always 0 for an empty range.Liststep(int step)Always returns an empty list for an empty range.voidstep(int step, Closure closure)Always does nothing for an empty range.StringtoString()-
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, subList, toArray, toArray
-
-
-
-
Field Detail
-
at
protected Comparable at
The value at which the range originates (may benull).
-
-
Constructor Detail
-
EmptyRange
public EmptyRange(Comparable at)
Creates a newEmptyRange.- Parameters:
at- the value at which the range starts (may benull).
-
-
Method Detail
-
getFrom
public Comparable getFrom()
The lower value in the range.
-
getTo
public Comparable getTo()
The upper value in the range.
-
isReverse
public boolean isReverse()
Never true for an empty range.
-
containsWithinBounds
public boolean containsWithinBounds(Object o)
Never true for an empty range.- Specified by:
containsWithinBoundsin interfaceRange- Parameters:
o- the object to check against the boundaries of the range- Returns:
false
-
inspect
public String inspect()
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection
-
size
public int size()
Always 0 for an empty range.- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- Specified by:
sizein classAbstractCollection- Returns:
- 0
-
get
public Object get(int index)
Always throwsIndexOutOfBoundsExceptionfor an empty range.- Specified by:
getin interfaceList- Specified by:
getin classAbstractList- Throws:
IndexOutOfBoundsException- always
-
add
public boolean add(Object o)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList- Overrides:
addin classAbstractList- Throws:
UnsupportedOperationException- always
-
addAll
public boolean addAll(int index, Collection c)Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
addAllin interfaceList- Overrides:
addAllin classAbstractList- Throws:
UnsupportedOperationException
-
addAll
public boolean addAll(Collection c)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList- Overrides:
addAllin classAbstractCollection- Throws:
UnsupportedOperationException
-
remove
public boolean remove(Object o)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList- Overrides:
removein classAbstractCollection- Throws:
UnsupportedOperationException
-
remove
public Object remove(int index)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
removein interfaceList- Overrides:
removein classAbstractList- Throws:
UnsupportedOperationException
-
removeAll
public boolean removeAll(Collection c)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList- Overrides:
removeAllin classAbstractCollection- Throws:
UnsupportedOperationException
-
retainAll
public boolean retainAll(Collection c)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList- Overrides:
retainAllin classAbstractCollection- Throws:
UnsupportedOperationException
-
set
public Object set(int index, Object element)
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
setin interfaceList- Overrides:
setin classAbstractList- Throws:
UnsupportedOperationException
-
step
public void step(int step, Closure closure)Always does nothing for an empty range.
-
-