Package groovy.lang
Class EmptyRange<T extends Comparable>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
groovy.lang.EmptyRange<T>
- All Implemented Interfaces:
Range<T>
,Iterable<T>
,Collection<T>
,List<T>
Constructing Ranges like 0..<0
-
Field Summary
Modifier and TypeFieldDescriptionprotected T
The value at which the range originates (may benull
).Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Always throwsUnsupportedOperationException
for an empty range.boolean
addAll
(int index, Collection<? extends T> c) Always throwsUnsupportedOperationException
for an empty range.boolean
addAll
(Collection<? extends T> c) Always throwsUnsupportedOperationException
for an empty range.boolean
Never true for an empty range.get
(int index) Always throwsIndexOutOfBoundsException
for an empty range.getFrom()
The lower value in the range.getTo()
The upper value in the range.inspect()
boolean
Never true for an empty range.remove
(int index) Always throwsUnsupportedOperationException
for an empty range.boolean
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.Always throwsUnsupportedOperationException
for an empty range.int
size()
Always 0 for an empty range.step
(int step) Always returns an empty list for an empty range.void
Always does nothing for an empty range.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 Details
-
at
The value at which the range originates (may benull
).
-
-
Constructor Details
-
EmptyRange
Creates a newEmptyRange
.- Parameters:
at
- the value at which the range starts (may benull
).
-
-
Method Details
-
getFrom
The lower value in the range.- Specified by:
getFrom
in interfaceRange<T extends Comparable>
- Returns:
- the lower value in the range.
-
getTo
The upper value in the range.- Specified by:
getTo
in interfaceRange<T extends Comparable>
- Returns:
- the upper value in the range
-
isReverse
public boolean isReverse()Never true for an empty range.- Specified by:
isReverse
in interfaceRange<T extends Comparable>
- Returns:
false
-
containsWithinBounds
Never true for an empty range.- Specified by:
containsWithinBounds
in interfaceRange<T extends Comparable>
- Parameters:
o
- the object to check against the boundaries of the range- Returns:
false
-
inspect
-
toString
- Overrides:
toString
in classAbstractCollection<T extends Comparable>
-
size
public int size()Always 0 for an empty range.- Specified by:
size
in interfaceCollection<T extends Comparable>
- Specified by:
size
in interfaceList<T extends Comparable>
- Specified by:
size
in classAbstractCollection<T extends Comparable>
- Returns:
- 0
-
get
Always throwsIndexOutOfBoundsException
for an empty range.- Specified by:
get
in interfaceList<T extends Comparable>
- Specified by:
get
in classAbstractList<T extends Comparable>
- Throws:
IndexOutOfBoundsException
- always
-
add
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
add
in interfaceCollection<T extends Comparable>
- Specified by:
add
in interfaceList<T extends Comparable>
- Overrides:
add
in classAbstractList<T extends Comparable>
- Throws:
UnsupportedOperationException
- always
-
addAll
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
addAll
in interfaceList<T extends Comparable>
- Overrides:
addAll
in classAbstractList<T extends Comparable>
- Throws:
UnsupportedOperationException
-
addAll
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
addAll
in interfaceCollection<T extends Comparable>
- Specified by:
addAll
in interfaceList<T extends Comparable>
- Overrides:
addAll
in classAbstractCollection<T extends Comparable>
- Throws:
UnsupportedOperationException
-
remove
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
remove
in interfaceCollection<T extends Comparable>
- Specified by:
remove
in interfaceList<T extends Comparable>
- Overrides:
remove
in classAbstractCollection<T extends Comparable>
- Throws:
UnsupportedOperationException
-
remove
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
remove
in interfaceList<T extends Comparable>
- Overrides:
remove
in classAbstractList<T extends Comparable>
- Throws:
UnsupportedOperationException
-
removeAll
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
removeAll
in interfaceCollection<T extends Comparable>
- Specified by:
removeAll
in interfaceList<T extends Comparable>
- Overrides:
removeAll
in classAbstractCollection<T extends Comparable>
- Throws:
UnsupportedOperationException
-
retainAll
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
retainAll
in interfaceCollection<T extends Comparable>
- Specified by:
retainAll
in interfaceList<T extends Comparable>
- Overrides:
retainAll
in classAbstractCollection<T extends Comparable>
- Throws:
UnsupportedOperationException
-
set
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
set
in interfaceList<T extends Comparable>
- Overrides:
set
in classAbstractList<T extends Comparable>
- Throws:
UnsupportedOperationException
-
step
Always does nothing for an empty range.- Specified by:
step
in interfaceRange<T extends Comparable>
- Parameters:
step
- the amount by which to step. If negative, steps through the range backwards.closure
- theClosure
to call
-
step
Always returns an empty list for an empty range.- Specified by:
step
in interfaceRange<T extends 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.
-