Package groovy.lang
Class EmptyRange<T extends java.lang.Comparable>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
groovy.lang.EmptyRange<T>
- All Implemented Interfaces:
Range<T>
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.List<T>
public class EmptyRange<T extends java.lang.Comparable> extends java.util.AbstractList<T> implements Range<T>
Constructing Ranges like 0..<0
-
Field Summary
Fields Modifier and Type Field Description protected T
at
The value at which the range originates (may benull
).Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors Constructor Description EmptyRange(T at)
Creates a newEmptyRange
. -
Method Summary
Modifier and Type Method Description boolean
add(T o)
Always throwsUnsupportedOperationException
for an empty range.boolean
addAll(int index, java.util.Collection<? extends T> c)
Always throwsUnsupportedOperationException
for an empty range.boolean
addAll(java.util.Collection<? extends T> c)
Always throwsUnsupportedOperationException
for an empty range.boolean
containsWithinBounds(java.lang.Object o)
Never true for an empty range.T
get(int index)
Always throwsIndexOutOfBoundsException
for an empty range.T
getFrom()
The lower value in the range.T
getTo()
The upper value in the range.java.lang.String
inspect()
boolean
isReverse()
Never true for an empty range.T
remove(int index)
Always throwsUnsupportedOperationException
for an empty range.boolean
remove(java.lang.Object o)
Always throwsUnsupportedOperationException
for an empty range.boolean
removeAll(java.util.Collection<?> c)
Always throwsUnsupportedOperationException
for an empty range.boolean
retainAll(java.util.Collection<?> c)
Always throwsUnsupportedOperationException
for an empty range.T
set(int index, T element)
Always throwsUnsupportedOperationException
for an empty range.int
size()
Always 0 for an empty range.java.util.List<T>
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.java.lang.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.lang.Iterable
forEach
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. -
getTo
The upper value in the range. -
isReverse
public boolean isReverse()Never true for an empty range. -
containsWithinBounds
public boolean containsWithinBounds(java.lang.Object o)Never true for an empty range.- Specified by:
containsWithinBounds
in interfaceRange<T extends java.lang.Comparable>
- Parameters:
o
- the object to check against the boundaries of the range- Returns:
false
-
inspect
public java.lang.String inspect() -
toString
public java.lang.String toString()- Overrides:
toString
in classjava.util.AbstractCollection<T extends java.lang.Comparable>
-
size
public int size()Always 0 for an empty range. -
get
Always throwsIndexOutOfBoundsException
for an empty range. -
add
Always throwsUnsupportedOperationException
for an empty range. -
addAll
Always throwsUnsupportedOperationException
for an empty range. -
addAll
Always throwsUnsupportedOperationException
for an empty range.- Specified by:
addAll
in interfacejava.util.Collection<T extends java.lang.Comparable>
- Specified by:
addAll
in interfacejava.util.List<T extends java.lang.Comparable>
- Overrides:
addAll
in classjava.util.AbstractCollection<T extends java.lang.Comparable>
- Throws:
java.lang.UnsupportedOperationException
-
remove
public boolean remove(java.lang.Object o)Always throwsUnsupportedOperationException
for an empty range.- Specified by:
remove
in interfacejava.util.Collection<T extends java.lang.Comparable>
- Specified by:
remove
in interfacejava.util.List<T extends java.lang.Comparable>
- Overrides:
remove
in classjava.util.AbstractCollection<T extends java.lang.Comparable>
- Throws:
java.lang.UnsupportedOperationException
-
remove
Always throwsUnsupportedOperationException
for an empty range. -
removeAll
public boolean removeAll(java.util.Collection<?> c)Always throwsUnsupportedOperationException
for an empty range.- Specified by:
removeAll
in interfacejava.util.Collection<T extends java.lang.Comparable>
- Specified by:
removeAll
in interfacejava.util.List<T extends java.lang.Comparable>
- Overrides:
removeAll
in classjava.util.AbstractCollection<T extends java.lang.Comparable>
- Throws:
java.lang.UnsupportedOperationException
-
retainAll
public boolean retainAll(java.util.Collection<?> c)Always throwsUnsupportedOperationException
for an empty range.- Specified by:
retainAll
in interfacejava.util.Collection<T extends java.lang.Comparable>
- Specified by:
retainAll
in interfacejava.util.List<T extends java.lang.Comparable>
- Overrides:
retainAll
in classjava.util.AbstractCollection<T extends java.lang.Comparable>
- Throws:
java.lang.UnsupportedOperationException
-
set
Always throwsUnsupportedOperationException
for an empty range. -
step
Always does nothing for an empty range. -
step
Always returns an empty list for an empty range.
-