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
FieldsModifier and TypeFieldDescriptionprotected TThe value at which the range originates (may benull).Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAlways throwsUnsupportedOperationExceptionfor an empty range.booleanaddAll(int index, Collection<? extends T> c) Always throwsUnsupportedOperationExceptionfor an empty range.booleanaddAll(Collection<? extends T> c) Always throwsUnsupportedOperationExceptionfor an empty range.booleanNever true for an empty range.get(int index) Always throwsIndexOutOfBoundsExceptionfor an empty range.getFrom()The lower value in the range.getTo()The upper value in the range.inspect()booleanNever true for an empty range.remove(int index) Always throwsUnsupportedOperationExceptionfor an empty range.booleanAlways throwsUnsupportedOperationExceptionfor an empty range.booleanremoveAll(Collection<?> c) Always throwsUnsupportedOperationExceptionfor an empty range.booleanretainAll(Collection<?> c) Always throwsUnsupportedOperationExceptionfor an empty range.Always throwsUnsupportedOperationExceptionfor an empty range.intsize()Always 0 for an empty range.step(int step) Always returns an empty list for an empty range.voidAlways does nothing for an empty range.toString()Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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:
getFromin interfaceRange<T extends Comparable>- Returns:
- the lower value in the range.
-
getTo
The upper value in the range.- Specified by:
getToin interfaceRange<T extends Comparable>- Returns:
- the upper value in the range
-
isReverse
public boolean isReverse()Never true for an empty range.- Specified by:
isReversein interfaceRange<T extends Comparable>- Returns:
false
-
containsWithinBounds
Never true for an empty range.- Specified by:
containsWithinBoundsin interfaceRange<T extends Comparable>- Parameters:
o- the object to check against the boundaries of the range- Returns:
false
-
inspect
-
toString
- Overrides:
toStringin classAbstractCollection<T extends Comparable>
-
size
public int size()Always 0 for an empty range.- Specified by:
sizein interfaceCollection<T extends Comparable>- Specified by:
sizein interfaceList<T extends Comparable>- Specified by:
sizein classAbstractCollection<T extends Comparable>- Returns:
- 0
-
get
Always throwsIndexOutOfBoundsExceptionfor an empty range.- Specified by:
getin interfaceList<T extends Comparable>- Specified by:
getin classAbstractList<T extends Comparable>- Throws:
IndexOutOfBoundsException- always
-
add
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
addin interfaceCollection<T extends Comparable>- Specified by:
addin interfaceList<T extends Comparable>- Overrides:
addin classAbstractList<T extends Comparable>- Throws:
UnsupportedOperationException- always
-
addAll
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
addAllin interfaceList<T extends Comparable>- Overrides:
addAllin classAbstractList<T extends Comparable>- Throws:
UnsupportedOperationException
-
addAll
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
addAllin interfaceCollection<T extends Comparable>- Specified by:
addAllin interfaceList<T extends Comparable>- Overrides:
addAllin classAbstractCollection<T extends Comparable>- Throws:
UnsupportedOperationException
-
remove
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
removein interfaceCollection<T extends Comparable>- Specified by:
removein interfaceList<T extends Comparable>- Overrides:
removein classAbstractCollection<T extends Comparable>- Throws:
UnsupportedOperationException
-
remove
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
removein interfaceList<T extends Comparable>- Overrides:
removein classAbstractList<T extends Comparable>- Throws:
UnsupportedOperationException
-
removeAll
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
removeAllin interfaceCollection<T extends Comparable>- Specified by:
removeAllin interfaceList<T extends Comparable>- Overrides:
removeAllin classAbstractCollection<T extends Comparable>- Throws:
UnsupportedOperationException
-
retainAll
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
retainAllin interfaceCollection<T extends Comparable>- Specified by:
retainAllin interfaceList<T extends Comparable>- Overrides:
retainAllin classAbstractCollection<T extends Comparable>- Throws:
UnsupportedOperationException
-
set
Always throwsUnsupportedOperationExceptionfor an empty range.- Specified by:
setin interfaceList<T extends Comparable>- Overrides:
setin classAbstractList<T extends Comparable>- Throws:
UnsupportedOperationException
-
step
Always does nothing for an empty range.- Specified by:
stepin interfaceRange<T extends Comparable>- Parameters:
step- the amount by which to step. If negative, steps through the range backwards.closure- theClosureto call
-
step
Always returns an empty list for an empty range.- Specified by:
stepin 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.
-