public abstract class Consumers extends Object
| Constructor and Description |
|---|
Consumers() |
| Modifier and Type | Method and Description |
|---|---|
static <E> List<E> |
all(E[] array)
Yields all element of the array in a list.
|
static <R extends Collection<E>,E> |
all(E[] array,
Provider<R> provider)
Yields all elements of the iterator (in a collection created by the
provider).
|
static <R extends Collection<E>,E> |
all(E[] array,
R collection)
Yields all elements of the array (in the provided collection).
|
static <E> List<E> |
all(Iterable<E> iterable)
Yields all elements of the iterable's iterator (in a list).
|
static <E,R extends Collection<E>> |
all(Iterable<E> iterable,
Provider<R> provider)
Yields all elements of the iterator (in a collection created by the
provider).
|
static <R extends Collection<E>,E> |
all(Iterable<E> iterable,
R collection)
Yields all elements of the iterator (in the provided collection).
|
static <E> List<E> |
all(Iterator<E> iterator)
yields all elements of the iterator (in a list).
|
static <E,R extends Collection<E>> |
all(Iterator<E> iterator,
Provider<R> provider)
Yields all elements of the iterator (in a collection created by the
provider).
|
static <R extends Collection<E>,E> |
all(Iterator<E> iterator,
R collection)
Yields all elements of the iterator (in the provided collection).
|
static <E> E |
at(long index,
E[] array)
Yields element at (0-based) position of the array.
|
static <E> E |
at(long index,
Iterable<E> iterable)
Yields element at (0-based) position of the iterable.
|
static <E> E |
at(long index,
Iterator<E> iterator)
Yields element at (0-based) position of the iterator.
|
static <K,V> Map<K,V> |
dict(Iterable<Pair<K,V>> iterable)
Yields all elements of the iterable's iterator (in a map).
|
static <M extends Map<K,V>,K,V> |
dict(Iterable<Pair<K,V>> iterable,
M map)
Yields all elements of the iterator (in the provided map).
|
static <M extends Map<K,V>,K,V> |
dict(Iterable<Pair<K,V>> iterable,
Provider<M> provider)
Yields all elements of the iterator (in a map created by the provider).
|
static <K,V> Map<K,V> |
dict(Iterator<Pair<K,V>> iterator)
Yields all elements of the iterator (in a map).
|
static <M extends Map<K,V>,K,V> |
dict(Iterator<Pair<K,V>> iterator,
M map)
Yields all elements of the iterator (in the provided map).
|
static <M extends Map<K,V>,K,V> |
dict(Iterator<Pair<K,V>> iterator,
Provider<M> provider)
Yields all elements of the iterator (in a map created by the provider).
|
static <M extends Map<K,V>,K,V> |
dict(M map,
Pair<K,V>... array)
Yields all elements of the array (in the provided map).
|
static <K,V> Map<K,V> |
dict(Pair<K,V>... array)
Yields all element of the array in a map.
|
static <M extends Map<K,V>,K,V> |
dict(Provider<M> provider,
Pair<K,V>... array)
Yields all elements of the iterator (in a map created by the provider).
|
static <E> E |
first(E[] array)
Yields the first element of the array.
|
static <E> E |
first(Iterable<E> iterable)
Yields the first element of the iterable.
|
static <E> E |
first(Iterator<E> iterator)
Yields the first element of the iterator.
|
static <E> E |
last(E[] array)
Yields the last element.
|
static <E> E |
last(Iterable<E> iterable)
Yields the last element.
|
static <E> E |
last(Iterator<E> iterator)
Yields the last element.
|
static <E> Maybe<E> |
maybeAt(long index,
E[] array)
Yields element at (0-based) position of the array if found or nothing.
|
static <E> Maybe<E> |
maybeAt(long index,
Iterable<E> iterable)
Yields element at (0-based) position of the iterable if found or nothing.
|
static <E> Maybe<E> |
maybeAt(long index,
Iterator<E> iterator)
Yields element at (0-based) position of the iterator if found or nothing.
|
static <E> Maybe<E> |
maybeFirst(E[] array)
Yields the first element if present, nothing otherwise.
|
static <E> Maybe<E> |
maybeFirst(Iterable<E> iterable)
Yields the first element if present, nothing otherwise.
|
static <E> Maybe<E> |
maybeFirst(Iterator<E> iterator)
Yields the first element if present, nothing otherwise.
|
static <E> Maybe<E> |
maybeLast(E[] array)
Yields the last element if present, nothing otherwise.
|
static <E> Maybe<E> |
maybeLast(Iterable<E> iterable)
Yields the last element if present, nothing otherwise.
|
static <E> Maybe<E> |
maybeLast(Iterator<E> iterator)
Yields the last element if present, nothing otherwise.
|
static <E> Maybe<E> |
maybeNth(long count,
E[] array)
Yields nth (1-based) element of the array if found or nothing.
|
static <E> Maybe<E> |
maybeNth(long count,
Iterable<E> iterable)
Yields nth (1-based) element of the iterable if found or nothing.
|
static <E> Maybe<E> |
maybeNth(long count,
Iterator<E> iterator)
Yields nth (1-based) element of the iterator if found or nothing.
|
static <E> Maybe<E> |
maybeOne(E[] array)
Yields the only element if found, nothing otherwise.
|
static <E> Maybe<E> |
maybeOne(Iterable<E> iterable)
Yields the only element if found, nothing otherwise.
|
static <E> Maybe<E> |
maybeOne(Iterator<E> iterator)
Yields the only element if found, nothing otherwise.
|
static <E> E |
nth(long count,
E[] array)
Yields nth (1-based) element of the array.
|
static <E> E |
nth(long count,
Iterable<E> iterable)
Yields nth (1-based) element of the iterable.
|
static <E> E |
nth(long count,
Iterator<E> iterator)
Yields nth (1-based) element of the iterator.
|
static <E> E |
one(E[] array)
Yields the only element.
|
static <E> E |
one(Iterable<E> iterable)
Yields the only element.
|
static <E> E |
one(Iterator<E> iterator)
Yields the only element.
|
static <E> void |
pipe(E[] array,
OutputIterator<E> outputIterator)
Consumes the array into the output iterator.
|
static <E> void |
pipe(Iterable<E> iterable,
OutputIterator<E> outputIterator)
Consumes an iterable into the output iterator.
|
static <E> void |
pipe(Iterator<E> iterator,
OutputIterator<E> outputIterator)
Consumes the input iterator to the output iterator.
|
public static <R extends Collection<E>,E> R all(Iterator<E> iterator, R collection)
R - the returned collection typeE - the collection element typeiterator - the iterator that will be consumedcollection - the collection where the iterator is consumedpublic static <R extends Collection<E>,E> R all(Iterable<E> iterable, R collection)
R - the returned collection typeE - the collection element typeiterable - the iterable that will be consumedcollection - the collection where the iterator is consumedpublic static <R extends Collection<E>,E> R all(E[] array, R collection)
R - the returned collection typeE - the collection element typearray - the array that will be consumedcollection - the collection where the iterator is consumedpublic static <E,R extends Collection<E>> R all(Iterator<E> iterator, Provider<R> provider)
R - the returned collection typeE - the collection element typeiterator - the iterator that will be consumedprovider - the factory used to provide the returned collectionpublic static <E,R extends Collection<E>> R all(Iterable<E> iterable, Provider<R> provider)
R - the returned collection typeE - the collection element typeiterable - the iterable that will be consumedprovider - the factory used to provide the returned collectionpublic static <R extends Collection<E>,E> R all(E[] array, Provider<R> provider)
R - the returned collection typeE - the collection element typearray - the array that will be consumedprovider - the factory used to provide the returned collectionpublic static <E> List<E> all(Iterator<E> iterator)
E - the iterator element typeiterator - the iterator that will be consumedpublic static <E> List<E> all(Iterable<E> iterable)
E - the iterable element typeiterable - the iterable that will be consumedpublic static <E> List<E> all(E[] array)
E - the array element typearray - the array that will be consumedpublic static <M extends Map<K,V>,K,V> M dict(Iterator<Pair<K,V>> iterator, M map)
M - the returned map typeK - the map key typeV - the map value typeiterator - the iterator that will be consumedmap - the map where the iterator is consumedpublic static <M extends Map<K,V>,K,V> M dict(Iterable<Pair<K,V>> iterable, M map)
M - the returned map typeK - the map key typeV - the map value typeiterable - the iterable that will be consumedmap - the map where the iterator is consumedpublic static <M extends Map<K,V>,K,V> M dict(M map, Pair<K,V>... array)
M - the returned map typeK - the map key typeV - the map value typemap - the map where the iterator is consumedarray - the array that will be consumedpublic static <M extends Map<K,V>,K,V> M dict(Iterator<Pair<K,V>> iterator, Provider<M> provider)
M - the returned map typeK - the map key typeV - the map value typeiterator - the iterator that will be consumedprovider - the factory used to provide the returned mappublic static <M extends Map<K,V>,K,V> M dict(Iterable<Pair<K,V>> iterable, Provider<M> provider)
M - the returned map typeK - the map key typeV - the map value typeiterable - the iterable that will be consumedprovider - the factory used to provide the returned mappublic static <M extends Map<K,V>,K,V> M dict(Provider<M> provider, Pair<K,V>... array)
M - the returned map typeK - the map key typeV - the map value typeprovider - the factory used to provide the returned maparray - the array that will be consumedpublic static <K,V> Map<K,V> dict(Iterator<Pair<K,V>> iterator)
K - the map key typeV - the map value typeiterator - the iterator that will be consumedpublic static <K,V> Map<K,V> dict(Iterable<Pair<K,V>> iterable)
K - the map key typeV - the map value typeiterable - the iterable that will be consumedpublic static <K,V> Map<K,V> dict(Pair<K,V>... array)
K - the map key typeV - the map value typearray - the array that will be consumedpublic static <E> void pipe(Iterator<E> iterator, OutputIterator<E> outputIterator)
E - the iterator element typeiterator - the iterator that will be consumedoutputIterator - the iterator that will be filledpublic static <E> void pipe(Iterable<E> iterable, OutputIterator<E> outputIterator)
E - the iterator element typeiterable - the iterable that will be consumedoutputIterator - the iterator that will be filledpublic static <E> void pipe(E[] array,
OutputIterator<E> outputIterator)
E - the iterator element typearray - the array that will be consumedoutputIterator - the iterator that will be filledpublic static <E> Maybe<E> maybeFirst(Iterable<E> iterable)
E - the iterable element typeiterable - the iterable that will be consumedpublic static <E> Maybe<E> maybeFirst(Iterator<E> iterator)
E - the iterator element typeiterator - the iterator that will be consumedpublic static <E> Maybe<E> maybeFirst(E[] array)
E - the array element typearray - the array that will be consumedpublic static <E> E first(Iterator<E> iterator)
E - the element type parameteriterator - the iterator to be searchedIllegalArgumentException - if no element is presentpublic static <E> E first(Iterable<E> iterable)
E - the element type parameteriterable - the iterable to be searchedIllegalArgumentException - if no element is presentpublic static <E> E first(E[] array)
E - the element type parameterarray - the array to be searchedIllegalArgumentException - if no element matchespublic static <E> Maybe<E> maybeOne(Iterator<E> iterator)
E - the iterator element typeiterator - the iterator that will be consumedIllegalStateException - if the iterator contains more than one
elementpublic static <E> Maybe<E> maybeOne(Iterable<E> iterable)
E - the iterable element typeiterable - the iterable that will be consumedIllegalStateException - if the iterator contains more than one
elementpublic static <E> Maybe<E> maybeOne(E[] array)
E - the array element typearray - the array that will be consumedIllegalStateException - if the iterator contains more than one
elementpublic static <E> E one(Iterator<E> iterator)
E - the element type parameteriterator - the iterator to be searchedIllegalStateException - if more than one element is foundIllegalArgumentException - if no element matchespublic static <E> E one(Iterable<E> iterable)
E - the element type parameteriterable - the iterable to be searchedIllegalStateException - if more than one element is foundIllegalArgumentException - if no element matchespublic static <E> E one(E[] array)
E - the element type parameterarray - the array to be searchedIllegalStateException - if more than one element is foundIllegalArgumentException - if no element matchespublic static <E> Maybe<E> maybeLast(Iterator<E> iterator)
E - the iterator element typeiterator - the iterator that will be consumedpublic static <E> Maybe<E> maybeLast(Iterable<E> iterable)
E - the iterable element typeiterable - the iterable that will be consumedpublic static <E> Maybe<E> maybeLast(E[] array)
E - the array element typearray - the array that will be consumedpublic static <E> E last(Iterator<E> iterator)
E - the iterator element typeiterator - the iterator that will be consumed @throw
IllegalArgumentException if no element is foundpublic static <E> E last(Iterable<E> iterable)
E - the iterable element typeiterable - the iterable that will be consumed @throw
IllegalArgumentException if no element is foundpublic static <E> E last(E[] array)
E - the array element typearray - the array that will be consumed @throw
IllegalArgumentException if no element is foundpublic static <E> E nth(long count,
Iterator<E> iterator)
E - the iterator element typecount - the element cardinalityiterator - the iterator that will be consumedpublic static <E> E nth(long count,
Iterable<E> iterable)
E - the iterable element typecount - the element cardinalityiterable - the iterable that will be consumedpublic static <E> E nth(long count,
E[] array)
E - the array element typecount - the element cardinalityarray - the array that will be consumedpublic static <E> Maybe<E> maybeNth(long count, Iterator<E> iterator)
E - the iterator element typecount - the element cardinalityiterator - the iterator that will be consumedpublic static <E> Maybe<E> maybeNth(long count, Iterable<E> iterable)
E - the iterable element typecount - the element cardinalityiterable - the iterable that will be consumedpublic static <E> Maybe<E> maybeNth(long count, E[] array)
E - the array element typecount - the element cardinalityarray - the array that will be consumedpublic static <E> E at(long index,
Iterator<E> iterator)
E - the iterator element typeindex - the element indexiterator - the iterator that will be consumedpublic static <E> E at(long index,
Iterable<E> iterable)
E - the iterable element typeindex - the element indexiterable - the iterable that will be consumedpublic static <E> E at(long index,
E[] array)
E - the array element typeindex - the element indexarray - the array that will be consumedpublic static <E> Maybe<E> maybeAt(long index, Iterator<E> iterator)
E - the iterator element typeindex - the element indexiterator - the iterator that will be consumedpublic static <E> Maybe<E> maybeAt(long index, Iterable<E> iterable)
E - the iterable element typeindex - the element indexiterable - the iterable that will be consumedpublic static <E> Maybe<E> maybeAt(long index, E[] array)
E - the array element typeindex - the element indexarray - the array that will be consumedCopyright © 2013. All rights reserved.