Iterable instances.Note
this util class has been designed for fail-fast argument checking.
NullPointerException if a null Iterable is passed as argument.
Predicate, will result in a NullPointerException. Exception: passing
a null Comparator is equivalent to a Comparator with natural ordering.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final FluentIterable | EMPTY_ITERABLE
An empty iterable. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static < the element type E> Iterable | Returns: a bounded view on the specified iterablethe iterable to limit, may not be null iterable, final long the maximum number of elements, must not be negative maxSize)Returns a view of the given iterable that contains at most the given number of elements. |
| public static < the element type E> Iterable | Returns: a new iterable, combining the provided iterablesthe first iterable, may not be null a, final Iterable<? extends E> the second iterable, may not be null b)Combines two iterables into a single iterable. |
| public static < the element type E> Iterable | Returns: a new iterable, combining the provided iterablesthe first iterable, may not be null a, final Iterable<? extends E> the second iterable, may not be null b, final Iterable<? extends E> the third iterable, may not be null c)Combines three iterables into a single iterable. |
| public static < the element type E> Iterable | Returns: a new iterable, combining the provided iterablesthe first iterable, may not be null a, final Iterable<? extends E> the second iterable, may not be null b, final Iterable<? extends E> the third iterable, may not be null c, final Iterable<? extends E> the fourth iterable, may not be null d)Combines four iterables into a single iterable. |
| public static < the element type E> Iterable | Returns: a new iterable, combining the provided iterablesthe iterables to combine, may not be null iterables)Combines the provided iterables into a single iterable. |
| pack-priv static void | |
| pack-priv static void | checkNotNull(final Iterable<?>...
the iterables to check iterables)Fail-fast check for null arguments. |
| public static < the element type E> Iterable | Returns: a filtered view on the specified iterablethe first iterable, may not be null a, final Iterable<? extends E> the second iterable, may not be null b)Combines the two provided iterables into an ordered iterable using natural ordering. |
| public static < the element type E> Iterable | Returns: a filtered view on the specified iterablethe comparator defining an ordering over the elements,
may be null, in which case natural ordering will be used comparator, final Iterable<? extends E> the first iterable, may not be null a, final Iterable<? extends E> the second iterable, may not be null b)Combines the two provided iterables into an ordered iterable using the provided comparator. |
| public static < the type of object the E> booleanIterable contains | |
| public static < the type of object the E> booleanIterable contains | Returns: true if the object is contained in the iterable, false otherwisethe iterable to check, may be null iterable, final E the object to check object, final Equator<? super E> the equator to use to check, may not be null equator)Checks if the object is contained in the given iterable. |
| public static < the type of object the E> longIterable contains | Returns: the number of matches for the predicate in the collectionthe input, final Predicate<? super E> Iterable to get the input from, may be nullthe predicate to use, may not be null predicate)Counts the number of elements in the input iterable that match the predicate. |
| public static < the element type E> Iterable | Returns: an empty iterable if the argument is nullthe iterable, may be null iterable)Returns an immutable empty iterable if the argument is null, or the argument itself otherwise. |
| public static < the element type E> Iterable | |
| private static < the element type E> Iterator | Returns: an empty iterator if the argument isnullthe iterable, possibly iterable)nullReturns an empty iterator if the argument is |
| public static < the element type E> Iterable | Returns: a filtered view on the specified iterablethe iterable to filter, may not be null iterable, final Predicate<? super E> the predicate used to filter elements, may not be null predicate)Returns a view of the given iterable that only contains elements matching the provided predicate. |
| public static < the element type E> E | Returns: the first element of the iterable which matches the predicate or null if none could be foundthe iterable to search, may be null iterable, final Predicate<? super E> the predicate to use, may not be null predicate)Finds the first element in the given iterable which matches the given predicate. |
| public static < the type of object in the T> TIterable. | |
| public static < the element type E> void | |
| public static < the type of object the E> EIterable contains | Returns: the last element in the iterable, or null if iterable is null or emptythe iterable to get the input from, may be null iterable, final Closure<? super E> the closure to perform, may not be null closure)Executes the given closure on each but the last element in the iterable. |
| public static < the element type that the E, Iterable may containthe element type of the object to find T extends E> int | |
| public static < the type of object in the T> TIterable. | |
| public static < the element type E> int | Returns: the index of the first element which matches the predicate or -1 if none matchesthe iterable to search, may be null iterable, final Predicate<? super E> the predicate to use, may not be null predicate)Returns the index of the first element in the specified iterable that matches the given predicate. |
| public static boolean | |
| public static < the element type E> Iterable | Returns: a view of the iterable, providing an infinite loop over its elementsthe iterable to loop, may not be null iterable)Returns a view of the given iterable which will cycle infinitely over its elements. |
| public static < the type of object the E> booleanIterable contains | Returns: true if every element of the collection matches the predicate or if the collection is empty, false otherwisethe iterable, final Predicate<? super E> Iterable to use, may be nullthe predicate to use, may not be null predicate)Answers true if a predicate is true for every element of an iterable. |
| public static < the type of object the E> booleanIterable contains | Returns: true if any element of the collection matches the predicate, false otherwisethe iterable, final Predicate<? super E> Iterable to use, may be nullthe predicate to use, may not be null predicate)Answers true if a predicate is true for any element of the iterable. |
| public static < the type of object the O> ListIterable contains | Returns: a list containing the output collectionsthe iterable to partition, may be null iterable, final Predicate<? super O> the predicate to use, may not be null predicate)Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicate. |
| public static < the type of object the O> ListIterable contains | Returns: a list containing the output collectionsthe collection to get the input from, may be null iterable, final Predicate<? super O>... the predicates to use, may not be null predicates)Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicates. |
| public static < the type of object the O, Iterable containsthe type of the output R extends CollectionCollection | Returns: a list containing the output collectionsthe collection to get the input from, may be null iterable, final Factory<R> the factory used to create the output collections partitionFactory, final Predicate<? super O>... the predicates to use, may not be null predicates)Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicates. |
| public static < the element type E> Iterable | Returns: a reversed view of the specified iterablethe iterable to use, may not be null iterable)Returns a reversed view of the given iterable. |
| public static int | |
| public static < the element type E> Iterable | Returns: a view of the specified iterable, skipping the first N elementsthe iterable to use, may not be null iterable, final long the number of elements to skip from the start, must not be negative elementsToSkip)Returns a view of the given iterable that skips the first N elements. |
| public static < the element type E> List | |
| public static < the element type E> String | |
| public static < the element type E> String | Returns: a string representation ofiterablethe iterable to convert to a string, may be null iterable, final Transformer<? super E, String> the transformer used to get a string representation of an element transformer)Returns a string representation of the elements of the specified iterable. |
| public static < the element type E> String | Returns: a string representation ofiterablethe iterable to convert to a string, may be null iterable, final Transformer<? super E, String> the transformer used to get a string representation of an element transformer, final String the string to delimit elements delimiter, final String the prefix, prepended to the string representation prefix, final String the suffix, appended to the string representation suffix)Returns a string representation of the elements of the specified iterable. |
| public static < the input element type I, the output element type O> Iterable | Returns: a transformed view of the specified iterablethe iterable to transform, may not be null iterable, final Transformer<? super I, ? extends O> the transformer, must not be null transformer)Returns a transformed view of the given iterable where all of its elements have been transformed by the provided transformer. |
| public static < the element type E> Iterable | Returns: a unique view of the specified iterablethe iterable to use, may not be null iterable)Returns a unique view of the given iterable. |
| public static < the element type E> Iterable | Returns: an unmodifiable view of the specified iterablethe iterable to use, may not be null iterable)Returns an unmodifiable view of the given iterable. |
| public static < the element type E> Iterable | Returns: a new iterable, interleaving the provided iterablesthe first iterable, may not be null a, final Iterable<? extends E> the second iterable, may not be null b)Interleaves two iterables into a single iterable. |
| public static < the element type E> Iterable | Returns: a new iterable, interleaving the provided iterablesthe first iterable, may not be null first, final Iterable<? extends E>... the array of iterables to interleave, may not be null others)Interleaves two iterables into a single iterable. |