public class EmptyRange<T extends Comparable> extends AbstractList<T> implements Range<T>
Modifier and Type | Field and Description |
---|---|
protected T |
at
The value at which the range originates (may be
null ). |
modCount
Constructor and Description |
---|
EmptyRange(T at)
Creates a new
EmptyRange . |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T o)
Always throws
UnsupportedOperationException for an empty range. |
boolean |
addAll(Collection<? extends T> c)
Always throws
UnsupportedOperationException for an empty range. |
boolean |
addAll(int index,
Collection<? extends T> c)
Always throws
UnsupportedOperationException for an empty range. |
boolean |
containsWithinBounds(Object o)
Never true for an empty range.
|
T |
get(int index)
Always throws
IndexOutOfBoundsException for an empty range. |
T |
getFrom()
The lower value in the range.
|
T |
getTo()
The upper value in the range.
|
String |
inspect() |
boolean |
isReverse()
Never true for an empty range.
|
T |
remove(int index)
Always throws
UnsupportedOperationException for an empty range. |
boolean |
remove(Object o)
Always throws
UnsupportedOperationException for an empty range. |
boolean |
removeAll(Collection<?> c)
Always throws
UnsupportedOperationException for an empty range. |
boolean |
retainAll(Collection<?> c)
Always throws
UnsupportedOperationException for an empty range. |
T |
set(int index,
T element)
Always throws
UnsupportedOperationException for an empty range. |
int |
size()
Always 0 for an empty range.
|
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.
|
String |
toString() |
add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
contains, containsAll, isEmpty, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
protected T extends Comparable at
null
).public EmptyRange(T at)
EmptyRange
.at
- the value at which the range starts (may be null
).public T getFrom()
getFrom
in interface Range<T extends Comparable>
public T getTo()
getTo
in interface Range<T extends Comparable>
public boolean isReverse()
isReverse
in interface Range<T extends Comparable>
false
public boolean containsWithinBounds(Object o)
containsWithinBounds
in interface Range<T extends Comparable>
o
- the object to check against the boundaries of the rangefalse
public String inspect()
public String toString()
toString
in class AbstractCollection<T extends Comparable>
public int size()
size
in interface Collection<T extends Comparable>
size
in interface List<T extends Comparable>
size
in class AbstractCollection<T extends Comparable>
public T get(int index)
IndexOutOfBoundsException
for an empty range.get
in interface List<T extends Comparable>
get
in class AbstractList<T extends Comparable>
IndexOutOfBoundsException
- alwayspublic boolean add(T o)
UnsupportedOperationException
for an empty range.add
in interface Collection<T extends Comparable>
add
in interface List<T extends Comparable>
add
in class AbstractList<T extends Comparable>
UnsupportedOperationException
- alwayspublic boolean addAll(int index, Collection<? extends T> c)
UnsupportedOperationException
for an empty range.addAll
in interface List<T extends Comparable>
addAll
in class AbstractList<T extends Comparable>
UnsupportedOperationException
public boolean addAll(Collection<? extends T> c)
UnsupportedOperationException
for an empty range.addAll
in interface Collection<T extends Comparable>
addAll
in interface List<T extends Comparable>
addAll
in class AbstractCollection<T extends Comparable>
UnsupportedOperationException
public boolean remove(Object o)
UnsupportedOperationException
for an empty range.remove
in interface Collection<T extends Comparable>
remove
in interface List<T extends Comparable>
remove
in class AbstractCollection<T extends Comparable>
UnsupportedOperationException
public T remove(int index)
UnsupportedOperationException
for an empty range.remove
in interface List<T extends Comparable>
remove
in class AbstractList<T extends Comparable>
UnsupportedOperationException
public boolean removeAll(Collection<?> c)
UnsupportedOperationException
for an empty range.removeAll
in interface Collection<T extends Comparable>
removeAll
in interface List<T extends Comparable>
removeAll
in class AbstractCollection<T extends Comparable>
UnsupportedOperationException
public boolean retainAll(Collection<?> c)
UnsupportedOperationException
for an empty range.retainAll
in interface Collection<T extends Comparable>
retainAll
in interface List<T extends Comparable>
retainAll
in class AbstractCollection<T extends Comparable>
UnsupportedOperationException
public T set(int index, T element)
UnsupportedOperationException
for an empty range.set
in interface List<T extends Comparable>
set
in class AbstractList<T extends Comparable>
UnsupportedOperationException
public void step(int step, Closure closure)
step
in interface Range<T extends Comparable>
step
- the amount by which to step. If negative, steps through the range backwards.closure
- the Closure
to callpublic List<T> step(int step)
step
in interface Range<T extends Comparable>
step
- the amount by which to step. If negative, steps through the range backwards.