| Modifier and Type | Field and Description |
|---|---|
static ResettableIterator |
EMPTY_ITERATOR
An iterator over no elements.
|
static ResettableListIterator |
EMPTY_LIST_ITERATOR
A list iterator over no elements.
|
static MapIterator |
EMPTY_MAP_ITERATOR
A map iterator over no elements.
|
static OrderedIterator |
EMPTY_ORDERED_ITERATOR
An ordered iterator over no elements.
|
static OrderedMapIterator |
EMPTY_ORDERED_MAP_ITERATOR
An ordered map iterator over no elements.
|
| Modifier and Type | Method and Description |
|---|---|
static <E> ResettableIterator |
arrayIterator(E... array)
Gets an iterator over an object array.
|
static <E> ResettableIterator |
arrayIterator(E[] array, int start)
Gets an iterator over the end part of an object array.
|
static <E> ResettableIterator |
arrayIterator(E[] array, int start, int end)
Gets an iterator over part of an object array.
|
static <E> ResettableIterator |
arrayIterator(Object
Gets an iterator over an object or primitive array.
|
static <E> ResettableIterator |
arrayIterator(Object
Gets an iterator over the end part of an object or primitive array.
|
static <E> ResettableIterator |
arrayIterator(Object
Gets an iterator over part of an object or primitive array.
|
static <E> ResettableListIterator |
arrayListIterator(E... array)
Gets a list iterator over an object array.
|
static <E> ResettableListIterator |
arrayListIterator(E[] array, int start)
Gets a list iterator over the end part of an object array.
|
static <E> ResettableListIterator |
arrayListIterator(E[] array, int start, int end)
Gets a list iterator over part of an object array.
|
static <E> ResettableListIterator |
arrayListIterator(Object
Gets a list iterator over an object or primitive array.
|
static <E> ResettableListIterator |
arrayListIterator(Object
Gets a list iterator over the end part of an object or primitive array.
|
static <E> ResettableListIterator |
arrayListIterator(Object
Gets a list iterator over part of an object or primitive array.
|
static <E> Enumeration |
asEnumeration(Iterator
Gets an enumeration that wraps an iterator.
|
static <E> Iterable |
asIterable(Iterator
Gets an
Iterable that wraps an iterator.
|
static <E> Iterator |
asIterator(Enumeration
Gets an iterator that provides an iterator view of the given enumeration.
|
static <E> Iterator |
asIterator(Enumeration
Gets an iterator that provides an iterator view of the given enumeration that will remove elements from the specified collection.
|
static <E> Iterable |
asMultipleUseIterable(Iterator
Gets an iterable that wraps an iterator.
|
static <E> BoundedIterator |
boundedIterator(Iterator
Decorates the specified iterator to return at most the given number of elements.
|
static <E> BoundedIterator |
boundedIterator(Iterator
Decorates the specified iterator to return at most the given number of elements, skipping all elements until the iterator reaches the position at
offset.
|
static <E> Iterator |
chainedIterator(Collection
Gets an iterator that iterates through a collections of
Iterators one after another.
|
static <E> Iterator |
chainedIterator(Iterator
Gets an iterator that iterates through an array of
Iterators one after another.
|
static <E> Iterator |
chainedIterator(Iterator
Gets an iterator that iterates through two
Iterators one after another.
|
static <E> Iterator |
collatedIterator(Comparator
Gets an iterator that provides an ordered iteration over the elements contained in a collection of
Iterators.
|
static <E> Iterator |
collatedIterator(Comparator
Gets an iterator that provides an ordered iteration over the elements contained in an array of
Iterators.
|
static <E> Iterator |
collatedIterator(Comparator
Gets an iterator that provides an ordered iteration over the elements contained in a collection of ordered
Iterators.
|
static <E> boolean |
contains(Iterator
Checks if the object is contained in the given iterator.
|
static <E> ResettableIterator |
emptyIterator()
Gets an empty iterator.
|
static <E> ResettableListIterator |
emptyListIterator()
Gets an empty list iterator.
|
static <K |
emptyMapIterator()
Gets an empty map iterator.
|
static <E> OrderedIterator |
emptyOrderedIterator()
Gets an empty ordered iterator.
|
static <K |
emptyOrderedMapIterator()
Gets an empty ordered map iterator.
|
static <E> Iterator |
filteredIterator(Iterator
Gets an iterator that filters another iterator.
|
static <E> ListIterator |
filteredListIterator(ListIterator
Gets a list iterator that filters another list iterator.
|
static <E> E |
find(Iterator
Finds the first element in the given iterator which matches the given predicate.
|
static <E> void |
forEach(Iterator
Applies the closure to each element of the provided iterator.
|
static <E> E |
forEachButLast(Iterator
Executes the given closure on each but the last element in the iterator.
|
static <E> E |
get(Iterator
Returns the
index-th value in
Iterator, throwing
IndexOutOfBoundsException if there is no such element.
|
static Iterator |
getIterator(Object
Gets a suitable Iterator for the given object.
|
static <E> int |
indexOf(Iterator
Returns the index of the first element in the specified iterator that matches the given predicate.
|
static boolean |
isEmpty(Iterator
Checks if the given iterator is empty.
|
static <E> ResettableIterator |
loopingIterator(Collection
Gets an iterator that loops continuously over the supplied collection.
|
static <E> ResettableListIterator |
loopingListIterator(List
Gets an iterator that loops continuously over the supplied list.
|
static <E> boolean |
matchesAll(Iterator
Answers true if a predicate is true for every element of an iterator.
|
static <E> boolean |
matchesAny(Iterator
Answers true if a predicate is true for any element of the iterator.
|
static NodeListIterator |
nodeListIterator(Node
Gets an
Iterator that wraps the specified node's childNodes.
|
static NodeListIterator |
nodeListIterator(NodeList
|
static <E> Iterator |
objectGraphIterator(E root, Transformer
Gets an iterator that operates over an object graph.
|
static <E> Iterator |
peekingIterator(Iterator
Gets an iterator that supports one-element lookahead.
|
static <E> Iterator |
pushbackIterator(Iterator
Gets an iterator that supports pushback of elements.
|
static <E> ResettableIterator |
singletonIterator(E object)
Gets a singleton iterator.
|
static <E> ListIterator |
singletonListIterator(E object)
Gets a singleton list iterator.
|
static int |
size(Iterator
Returns the number of elements contained in the given iterator.
|
static <E> SkippingIterator |
skippingIterator(Iterator
Decorates the specified iterator to skip the first N elements.
|
static Object |
toArray(Iterator
Gets an array based on an iterator.
|
static <E> E[] |
toArray(Iterator
Gets an array based on an iterator.
|
static <E> List |
toList(Iterator
Gets a list based on an iterator.
|
static <E> List |
toList(Iterator
Gets a list based on an iterator.
|
static <E> ListIterator |
toListIterator(Iterator
Gets a list iterator based on a simple iterator.
|
static <E> String |
toString(Iterator
Returns a string representation of the elements of the specified iterator.
|
static <E> String |
toString(Iterator
Returns a string representation of the elements of the specified iterator.
|
static <E> String |
toString(Iterator
Returns a string representation of the elements of the specified iterator.
|
static <I |
transformedIterator(Iterator
Gets an iterator that transforms the elements of another iterator.
|
static <E> Iterator |
unmodifiableIterator(Iterator
Gets an immutable version of an
Iterator.
|
static <E> ListIterator |
unmodifiableListIterator(ListIterator
Gets an immutable version of a
ListIterator.
|
static <K |
unmodifiableMapIterator(MapIterator
Gets an immutable version of a
MapIterator.
|
static <E> ZippingIterator |
zippingIterator(Iterator
Returns an iterator that interleaves elements from the decorated iterators.
|
static <E> ZippingIterator |
zippingIterator(Iterator
Returns an iterator that interleaves elements from the decorated iterators.
|
static <E> ZippingIterator |
zippingIterator(Iterator
Returns an iterator that interleaves elements from the decorated iterators.
|
public static final ResettableIteratorEMPTY_ITERATOR
public static final ResettableListIteratorEMPTY_LIST_ITERATOR
public static final OrderedIteratorEMPTY_ORDERED_ITERATOR
public static final MapIteratorEMPTY_MAP_ITERATOR
public static final OrderedMapIteratorEMPTY_ORDERED_MAP_ITERATOR
public static <E> ResettableIterator<E> emptyIterator()
This iterator is a valid iterator object that will iterate over nothing.
E - the element type
public static <E> ResettableListIterator<E> emptyListIterator()
This iterator is a valid list iterator object that will iterate over nothing.
E - the element type
public static <E> OrderedIterator<E> emptyOrderedIterator()
This iterator is a valid iterator object that will iterate over nothing.
E - the element type
public static <K,V> MapIterator <K ,V> emptyMapIterator()
This iterator is a valid map iterator object that will iterate over nothing.
K - the key type
V - the value type
public static <K,V> OrderedMapIterator <K ,V> emptyOrderedMapIterator()
This iterator is a valid map iterator object that will iterate over nothing.
K - the key type
V - the value type
public static <E> ResettableIterator<E> singletonIterator(E object)
This iterator is a valid iterator object that will iterate over the specified object.
E - the element type
object - the single object over which to iterate
public static <E> ListIterator<E> singletonListIterator(E object)
This iterator is a valid list iterator object that will iterate over the specified object.
E - the element type
object - the single object over which to iterate
public static <E> ResettableIterator<E> arrayIterator(E... array)
E - the element type
array - the array over which to iterate
NullPointerException - if array is null
public static <E> ResettableIterator<E> arrayIterator(Object array)
This method will handle primitive arrays as well as object arrays. The primitives will be wrapped in the appropriate wrapper class.
E - the element type
array - the array over which to iterate
IllegalArgumentException - if the array is not an array
NullPointerException - if array is null
public static <E> ResettableIterator<E> arrayIterator(E[] array, int start)
E - the element type
array - the array over which to iterate
start - the index to start iterating at
IndexOutOfBoundsException - if start is less than zero or greater than the length of the array
NullPointerException - if array is null
public static <E> ResettableIterator<E> arrayIterator(Object array, int start)
This method will handle primitive arrays as well as object arrays. The primitives will be wrapped in the appropriate wrapper class.
E - the element type
array - the array over which to iterate
start - the index to start iterating at
IllegalArgumentException - if the array is not an array
IndexOutOfBoundsException - if start is less than zero or greater than the length of the array
NullPointerException - if array is null
public static <E> ResettableIterator<E> arrayIterator(E[] array, int start, int end)
E - the element type
array - the array over which to iterate
start - the index to start iterating at
end - the index to finish iterating at
IndexOutOfBoundsException - if array bounds are invalid
IllegalArgumentException - if end is before start
NullPointerException - if array is null
public static <E> ResettableIterator<E> arrayIterator(Object array, int start, int end)
This method will handle primitive arrays as well as object arrays. The primitives will be wrapped in the appropriate wrapper class.
E - the element type
array - the array over which to iterate
start - the index to start iterating at
end - the index to finish iterating at
IllegalArgumentException - if the array is not an array or end is before start
IndexOutOfBoundsException - if array bounds are invalid
NullPointerException - if array is null
public static <E> ResettableListIterator<E> arrayListIterator(E... array)
E - the element type
array - the array over which to iterate
NullPointerException - if array is null
public static <E> ResettableListIterator<E> arrayListIterator(Object array)
This method will handle primitive arrays as well as object arrays. The primitives will be wrapped in the appropriate wrapper class.
E - the element type
array - the array over which to iterate
IllegalArgumentException - if the array is not an array
NullPointerException - if array is null
public static <E> ResettableListIterator<E> arrayListIterator(E[] array, int start)
E - the element type
array - the array over which to iterate
start - the index to start iterating at
IndexOutOfBoundsException - if start is less than zero
NullPointerException - if array is null
public static <E> ResettableListIterator<E> arrayListIterator(Object array, int start)
This method will handle primitive arrays as well as object arrays. The primitives will be wrapped in the appropriate wrapper class.
E - the element type
array - the array over which to iterate
start - the index to start iterating at
IllegalArgumentException - if the array is not an array
IndexOutOfBoundsException - if start is less than zero
NullPointerException - if array is null
public static <E> ResettableListIterator<E> arrayListIterator(E[] array, int start, int end)
E - the element type
array - the array over which to iterate
start - the index to start iterating at
end - the index to finish iterating at
IndexOutOfBoundsException - if array bounds are invalid
IllegalArgumentException - if end is before start
NullPointerException - if array is null
public static <E> ResettableListIterator<E> arrayListIterator(Object array, int start, int end)
This method will handle primitive arrays as well as object arrays. The primitives will be wrapped in the appropriate wrapper class.
E - the element type
array - the array over which to iterate
start - the index to start iterating at
end - the index to finish iterating at
IllegalArgumentException - if the array is not an array or end is before start
IndexOutOfBoundsException - if array bounds are invalid
NullPointerException - if array is null
public static <E> BoundedIterator<E> boundedIterator(Iterator <? extends E> iterator, long max)
E - the element type
iterator - the iterator to decorate
max - the maximum number of elements returned by this iterator
NullPointerException - if the iterator is null
IllegalArgumentException - if max is negative
public static <E> BoundedIterator<E> boundedIterator(Iterator <? extends E> iterator, long offset, long max)
offset.
The iterator is immediately advanced until it reaches the position at offset, incurring O(n) time.
E - the element type
iterator - the iterator to decorate
offset - the index of the first element of the decorated iterator to return
max - the maximum number of elements returned by this iterator
NullPointerException - if the iterator is null
IllegalArgumentException - if either offset or max is negative
public static <E> Iterator<E> unmodifiableIterator(Iterator <E> iterator)
Iterator. The returned object will always throw an
UnsupportedOperationException for the
Iterator.remove() method.
E - the element type
iterator - the iterator to make immutable
public static <E> ListIterator<E> unmodifiableListIterator(ListIterator <E> listIterator)
ListIterator. The returned object will always throw an
UnsupportedOperationException for the
Iterator.remove() ,
ListIterator.add(E) and
ListIterator.set(E) methods.
E - the element type
listIterator - the iterator to make immutable
public static <K,V> MapIterator <K ,V> unmodifiableMapIterator(MapIterator <K ,V> mapIterator)
MapIterator. The returned object will always throw an
UnsupportedOperationException for the
Iterator.remove() ,
MapIterator.setValue(Object) methods.
K - the key type
V - the value type
mapIterator - the iterator to make immutable
public static <E> Iterator<E> chainedIterator(Iterator <? extends E> iterator1, Iterator <? extends E> iterator2)
Iterators one after another.
E - the element type
iterator1 - the first iterator to use, not null
iterator2 - the second iterator to use, not null
NullPointerException - if either iterator is null
public static <E> Iterator<E> chainedIterator(Iterator <? extends E>... iterators)
Iterators one after another.
E - the element type
iterators - the iterators to use, not null or empty or contain nulls
NullPointerException - if iterators array is null or contains a null
public static <E> Iterator<E> chainedIterator(Collection <Iterator <? extends E>> iterators)
Iterators one after another.
E - the element type
iterators - the iterators to use, not null or empty or contain nulls
NullPointerException - if iterators collection is null or contains a null
ClassCastException - if the iterators collection contains the wrong object type
public static <E> Iterator<E> collatedIterator(Comparator <? super E> comparator, Iterator <? extends E> iterator1, Iterator <? extends E> iterator2)
Iterators.
Given two ordered Iterators A and B, the Iterator method will return the lesser of A.next() and B.next().
The comparator is optional. If null is specified then natural order is used.
E - the element type
comparator - the comparator to use, may be null for natural order
iterator1 - the first iterators to use, not null
iterator2 - the first iterators to use, not null
NullPointerException - if either iterator is null
public static <E> Iterator<E> collatedIterator(Comparator <? super E> comparator, Iterator <? extends E>... iterators)
Iterators.
Given two ordered Iterators A and B, the Iterator method will return the lesser of A.next() and B.next() and so on.
The comparator is optional. If null is specified then natural order is used.
E - the element type
comparator - the comparator to use, may be null for natural order
iterators - the iterators to use, not null or empty or contain nulls
NullPointerException - if iterators array is null or contains a null value
public static <E> Iterator<E> collatedIterator(Comparator <? super E> comparator, Collection <Iterator <? extends E>> iterators)
Iterators.
Given two ordered Iterators A and B, the Iterator method will return the lesser of A.next() and B.next() and so on.
The comparator is optional. If null is specified then natural order is used.
E - the element type
comparator - the comparator to use, may be null for natural order
iterators - the iterators to use, not null or empty or contain nulls
NullPointerException - if iterators collection is null or contains a null
ClassCastException - if the iterators collection contains the wrong object type
public static <E> Iterator<E> objectGraphIterator(E root, Transformer <? super E ,? extends E> transformer)
This iterator can extract multiple objects from a complex tree-like object graph. The iteration starts from a single root object. It uses a Transformer to extract the iterators and elements. Its main benefit is that no intermediate List is created.
For example, consider an object graph:
|- Branch -- Leaf
| \- Leaf
|- Tree | /- Leaf
| |- Branch -- Leaf
Forest | \- Leaf
| |- Branch -- Leaf
| | \- Leaf
|- Tree | /- Leaf
|- Branch -- Leaf
|- Branch -- Leaf The following
Transformer, used in this class, will extract all the Leaf objects without creating a combined intermediate list:
public Object transform(Object input) {
if (input instanceof Forest) {
return ((Forest) input).treeIterator();
}
if (input instanceof Tree) {
return ((Tree) input).branchIterator();
}
if (input instanceof Branch) {
return ((Branch) input).leafIterator();
}
if (input instanceof Leaf) {
return input;
}
throw new ClassCastException();
}
Internally, iteration starts from the root object. When next is called, the transformer is called to examine the object. The transformer will return either an iterator or an object. If the object is an Iterator, the next element from that iterator is obtained and the process repeats. If the element is an object it is returned.
Under many circumstances, linking Iterators together in this manner is more efficient (and convenient) than using nested for loops to extract a list.
E - the element type
root - the root object to start iterating from, null results in an empty iterator
transformer - the transformer to use, see above, null uses no effect transformer
public static <I,O> Iterator <O> transformedIterator(Iterator <? extends I> iterator, Transformer <? super I ,? extends O> transform)
The transformation occurs during the next() method and the underlying iterator is unaffected by the transformation.
I - the input type
O - the output type
iterator - the iterator to use, not null
transform - the transform to use, not null
NullPointerException - if either parameter is null
public static <E> Iterator<E> filteredIterator(Iterator <? extends E> iterator, Predicate <? super E> predicate)
The returned iterator will only return objects that match the specified filtering predicate.
E - the element type
iterator - the iterator to use, not null
predicate - the predicate to use as a filter, not null
NullPointerException - if either parameter is null
public static <E> ListIterator<E> filteredListIterator(ListIterator <? extends E> listIterator, Predicate <? super E> predicate)
The returned iterator will only return objects that match the specified filtering predicate.
E - the element type
listIterator - the list iterator to use, not null
predicate - the predicate to use as a filter, not null
NullPointerException - if either parameter is null
public static <E> ResettableIterator<E> loopingIterator(Collection <? extends E> coll)
The iterator will only stop looping if the remove method is called enough times to empty the collection, or if the collection is empty to start with.
E - the element type
coll - the collection to iterate over, not null
NullPointerException - if the collection is null
public static <E> ResettableListIterator<E> loopingListIterator(List <E> list)
The iterator will only stop looping if the remove method is called enough times to empty the list, or if the list is empty to start with.
E - the element type
list - the list to iterate over, not null
NullPointerException - if the list is null
public static NodeListIteratornodeListIterator(NodeList nodeList)
Iterator that wraps the specified
NodeList. The returned
Iterator can be used for a single iteration.
nodeList - the node list to use, may not be null
Iterator
NullPointerException - if nodeList is null
public static NodeListIteratornodeListIterator(Node node)
Iterator that wraps the specified node's childNodes. The returned
Iterator can be used for a single iteration.
Convenience method, allows easy iteration over NodeLists:
Iterator<Node> iterator = IteratorUtils.nodeListIterator(node);
for(Node childNode : IteratorUtils.asIterable(iterator)) {
...
}
node - the node to use, may not be null
Iterator
NullPointerException - if node is null
public static <E> Iterator<E> peekingIterator(Iterator <? extends E> iterator)
E - the element type
iterator - the iterator to decorate, not null
NullPointerException - if the iterator is null
public static <E> Iterator<E> pushbackIterator(Iterator <? extends E> iterator)
E - the element type
iterator - the iterator to decorate, not null
NullPointerException - if the iterator is null
public static <E> SkippingIterator<E> skippingIterator(Iterator <E> iterator, long offset)
E - the element type
iterator - the iterator to decorate
offset - the first number of elements to skip
NullPointerException - if the iterator is null
IllegalArgumentException - if offset is negative
public static <E> ZippingIterator<E> zippingIterator(Iterator <? extends E> a, Iterator <? extends E> b)
E - the element type
a - the first iterator to interleave
b - the second iterator to interleave
NullPointerException - if any iterator is null
public static <E> ZippingIterator<E> zippingIterator(Iterator <? extends E> a, Iterator <? extends E> b, Iterator <? extends E> c)
E - the element type
a - the first iterator to interleave
b - the second iterator to interleave
c - the third iterator to interleave
NullPointerException - if any iterator is null
public static <E> ZippingIterator<E> zippingIterator(Iterator <? extends E>... iterators)
E - the element type
iterators - the array of iterators to interleave
NullPointerException - if any iterator is null
public static <E> Iterator<E> asIterator(Enumeration <? extends E> enumeration)
E - the element type
enumeration - the enumeration to use, may not be null
NullPointerException - if enumeration is null
public static <E> Iterator<E> asIterator(Enumeration <? extends E> enumeration, Collection <? super E> removeCollection)
E - the element type
enumeration - the enumeration to use, may not be null
removeCollection - the collection to remove elements from, may not be null
NullPointerException - if enumeration or removeCollection is null
public static <E> Enumeration<E> asEnumeration(Iterator <? extends E> iterator)
E - the element type
iterator - the iterator to use, may not be null
NullPointerException - if iterator is null
public static <E> Iterable<E> asIterable(Iterator <? extends E> iterator)
E - the element type
iterator - the iterator to use, may not be null
Iterable
NullPointerException - if iterator is null
public static <E> Iterable<E> asMultipleUseIterable(Iterator <? extends E> iterator)
E - the element type
iterator - the iterator to use, may not be null
NullPointerException - if iterator is null
public static <E> ListIterator<E> toListIterator(Iterator <? extends E> iterator)
As the wrapped Iterator is traversed, a LinkedList of its values is cached, permitting all required operations of ListIterator.
E - the element type
iterator - the iterator to use, may not be null
NullPointerException - if iterator parameter is null
public static Object[] toArray(Iterator <?> iterator)
As the wrapped Iterator is traversed, an ArrayList of its values is created. At the end, this is converted to an array.
iterator - the iterator to use, not null
NullPointerException - if iterator parameter is null
public static <E> E[] toArray(Iterator<? extends E> iterator, Class <E> arrayClass)
As the wrapped Iterator is traversed, an ArrayList of its values is created. At the end, this is converted to an array.
E - the element type
iterator - the iterator to use, not null
arrayClass - the class of array to create
NullPointerException - if iterator parameter or arrayClass is null
ArrayStoreException - if the arrayClass is invalid
public static <E> List<E> toList(Iterator <? extends E> iterator)
As the wrapped Iterator is traversed, an ArrayList of its values is created. At the end, the list is returned.
E - the element type
iterator - the iterator to use, not null
NullPointerException - if iterator parameter is null
public static <E> List<E> toList(Iterator <? extends E> iterator, int estimatedSize)
As the wrapped Iterator is traversed, an ArrayList of its values is created. At the end, the list is returned.
E - the element type
iterator - the iterator to use, not null
estimatedSize - the initial size of the ArrayList
NullPointerException - if iterator parameter is null
IllegalArgumentException - if the size is less than 1
public static Iterator<?> getIterator(Object obj)
This method can handle objects as follows
obj - the object to convert to an iterator
public static <E> void forEach(Iterator<E> iterator, Closure <? super E> closure)
E - the element type
iterator - the iterator to use, may be null
closure - the closure to apply to each element, may not be null
NullPointerException - if closure is null
public static <E> E forEachButLast(Iterator<E> iterator, Closure <? super E> closure)
If the input iterator is null no change is made.
E - the type of object the
Iterator contains
iterator - the iterator to get the input from, may be null
closure - the closure to perform, may not be null
NullPointerException - if closure is null
public static <E> E find(Iterator<E> iterator, Predicate <? super E> predicate)
A null or empty iterator returns null.
E - the element type
iterator - the iterator to search, may be null
predicate - the predicate to use, may not be null
NullPointerException - if predicate is null
public static <E> int indexOf(Iterator<E> iterator, Predicate <? super E> predicate)
A null or empty iterator returns -1.
E - the element type
iterator - the iterator to search, may be null
predicate - the predicate to use, may not be null
NullPointerException - if predicate is null
public static <E> boolean matchesAny(Iterator<E> iterator, Predicate <? super E> predicate)
A null or empty iterator returns false.
E - the type of object the
Iterator contains
iterator - the
Iterator to use, may be null
predicate - the predicate to use, may not be null
NullPointerException - if predicate is null
public static <E> boolean matchesAll(Iterator<E> iterator, Predicate <? super E> predicate)
A null or empty iterator returns true.
E - the type of object the
Iterator contains
iterator - the
Iterator to use, may be null
predicate - the predicate to use, may not be null
NullPointerException - if predicate is null
public static boolean isEmpty(Iterator<?> iterator)
A null or empty iterator returns true.
iterator - the
Iterator to use, may be null
public static <E> boolean contains(Iterator<E> iterator, Object object)
A null or empty iterator returns false.
E - the type of object the
Iterator contains
iterator - the iterator to check, may be null
object - the object to check
public static <E> E get(Iterator<E> iterator, int index)
index-th value in
Iterator, throwing
IndexOutOfBoundsException if there is no such element.
The Iterator is advanced to index (or to the end, if index exceeds the number of entries) as a side effect of this method.
E - the type of object in the
Iterator
iterator - the iterator to get a value from
index - the index to get
IndexOutOfBoundsException - if the index is invalid
public static int size(Iterator<?> iterator)
A null or empty iterator returns 0.
iterator - the iterator to check, may be null
public static <E> StringtoString(Iterator <E> iterator)
The string representation consists of a list of the iterator's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(Object).
E - the element type
iterator - the iterator to convert to a string, may be null
iterator
public static <E> StringtoString(Iterator <E> iterator, Transformer <? super E ,String > transformer)
The string representation consists of a list of the iterable's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by using the provided transformer.
E - the element type
iterator - the iterator to convert to a string, may be null
transformer - the transformer used to get a string representation of an element
iterator
NullPointerException - if
transformer is null
public static <E> StringtoString(Iterator <E> iterator, Transformer <? super E ,String > transformer, String delimiter, String prefix, String suffix)
The string representation consists of a list of the iterator's elements, enclosed by the provided prefix and suffix. Adjacent elements are separated by the provided delimiter. Elements are converted to strings as by using the provided transformer.
E - the element type
iterator - the iterator to convert to a string, may be null
transformer - the transformer used to get a string representation of an element
delimiter - the string to delimit elements
prefix - the prefix, prepended to the string representation
suffix - the suffix, appended to the string representation
iterator
NullPointerException - if either transformer, delimiter, prefix or suffix is null