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 Comparable
at
The 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 boolean
add(Object o)
Always throwsUnsupportedOperationException
for an empty range.boolean
addAll(int index, Collection c)
Always throwsUnsupportedOperationException
for an empty range.boolean
addAll(Collection c)
Always throwsUnsupportedOperationException
for an empty range.boolean
containsWithinBounds(Object o)
Never true for an empty range.Object
get(int index)
Always throwsIndexOutOfBoundsException
for an empty range.Comparable
getFrom()
The lower value in the range.Comparable
getTo()
The upper value in the range.String
inspect()
boolean
isReverse()
Never true for an empty range.Object
remove(int index)
Always throwsUnsupportedOperationException
for an empty range.boolean
remove(Object o)
Always throwsUnsupportedOperationException
for an empty range.boolean
removeAll(Collection c)
Always throwsUnsupportedOperationException
for an empty range.boolean
retainAll(Collection c)
Always throwsUnsupportedOperationException
for an empty range.Object
set(int index, Object element)
Always throwsUnsupportedOperationException
for an empty range.int
size()
Always 0 for an empty range.List
step(int step)
Always returns an empty list for an empty range.void
step(int step, Closure closure)
Always does nothing for an empty range.String
toString()
-
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:
containsWithinBounds
in interfaceRange
- Parameters:
o
- the object to check against the boundaries of the range- Returns:
false
-
inspect
public String inspect()
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection
-
size
public int size()
Always 0 for an empty range.- Specified by:
size
in interfaceCollection
- Specified by:
size
in interfaceList
- Specified by:
size
in classAbstractCollection
- Returns:
- 0
-
get
public Object get(int index)
Always throwsIndexOutOfBoundsException
for an empty range.- Specified by:
get
in interfaceList
- Specified by:
get
in classAbstractList
- Throws:
IndexOutOfBoundsException
- always
-
add
public boolean add(Object o)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceList
- Overrides:
add
in classAbstractList
- Throws:
UnsupportedOperationException
- always
-
addAll
public boolean addAll(int index, Collection c)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
addAll
in interfaceList
- Overrides:
addAll
in classAbstractList
- Throws:
UnsupportedOperationException
-
addAll
public boolean addAll(Collection c)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
addAll
in interfaceCollection
- Specified by:
addAll
in interfaceList
- Overrides:
addAll
in classAbstractCollection
- Throws:
UnsupportedOperationException
-
remove
public boolean remove(Object o)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
remove
in interfaceCollection
- Specified by:
remove
in interfaceList
- Overrides:
remove
in classAbstractCollection
- Throws:
UnsupportedOperationException
-
remove
public Object remove(int index)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
remove
in interfaceList
- Overrides:
remove
in classAbstractList
- Throws:
UnsupportedOperationException
-
removeAll
public boolean removeAll(Collection c)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceList
- Overrides:
removeAll
in classAbstractCollection
- Throws:
UnsupportedOperationException
-
retainAll
public boolean retainAll(Collection c)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceList
- Overrides:
retainAll
in classAbstractCollection
- Throws:
UnsupportedOperationException
-
set
public Object set(int index, Object element)
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
set
in interfaceList
- Overrides:
set
in classAbstractList
- Throws:
UnsupportedOperationException
-
step
public void step(int step, Closure closure)
Always does nothing for an empty range.
-
-