public class ObjectRange extends AbstractList implements Range
Represents an inclusive list of objects from a value to a value using comparators.
Note: This class is similar to IntRange. If you make any changes to this class, you might consider making parallel changes to IntRange.
Constructor and description |
---|
ObjectRange(Comparable from, Comparable to) Creates a new ObjectRange. |
ObjectRange(Comparable smaller, Comparable larger, boolean reverse) Creates a new ObjectRange assumes smaller <= larger, else behavior is undefined. |
Type Params | Return Type | Name and description |
---|---|---|
|
public boolean |
contains(Object value) Iterates over all values and returns true if one value matches. |
|
public boolean |
containsWithinBounds(Object value) Checks whether a value is between the from and to values of a Range |
|
public boolean |
equals(Object that) |
|
public boolean |
equals(ObjectRange that) Compares an ObjectRange to another ObjectRange. |
|
public Comparable |
get(int index) |
|
public Comparable |
getFrom() |
|
public Comparable |
getTo() |
|
public String |
inspect() |
|
public boolean |
isReverse() |
|
public Iterator<Comparable> |
iterator() {@inheritDoc} |
|
public int |
size() |
|
public void |
step(int step, Closure closure) |
|
public List<Comparable> |
step(int step) |
|
public List<Comparable> |
subList(int fromIndex, int toIndex) |
|
public String |
toString() |
Methods inherited from class | Name |
---|---|
class AbstractList |
add, add, remove, get, equals, hashCode, indexOf, clear, lastIndexOf, subList, iterator, addAll, set, listIterator, listIterator, remove, toString, isEmpty, size, toArray, toArray, contains, addAll, removeAll, retainAll, containsAll, wait, wait, wait, getClass, notify, notifyAll, toArray, stream, spliterator, removeIf, parallelStream, forEach, replaceAll, sort |
Creates a new ObjectRange. Creates a reversed range if
from
< to
.
from
- the first value in the range.to
- the last value in the range.Creates a new ObjectRange assumes smaller <= larger, else behavior is undefined. Caution: Prefer the other constructor when in doubt.
Optimized Constructor avoiding initial computation of comparison.
Iterates over all values and returns true if one value matches.
Checks whether a value is between the from and to values of a Range
value
- the value of interestCompares an ObjectRange to another ObjectRange.
that
- the object to check equality withtrue
if the ranges are equal{@inheritDoc}
Copyright © 2003-2022 The Apache Software Foundation. All rights reserved.