public final class Iterables extends Object
Modifier and Type | Method and Description |
---|---|
static <T,C extends Collection<T>> |
addAll(C collection, Iterable<? extends T> iterable)
Add all items of an Iterable into a Collection.
|
static <T> Iterable<T> |
asIterable(T... items)
Create an Iterable of given items.
|
static long |
count(Iterable<?> iterable)
Count the number of items.
|
static <T> Iterable<T> |
empty()
Empty Iterable.
|
static <T> T |
first(Iterable<T> iterable)
First item or null.
|
static <I,O> Iterable<O> |
map(Iterable<I> input, Function<I,O> function) |
static <T,I extends Iterable<T>> |
notEmptyOrNull(I iterable) |
static <T> Iterable<T> |
skip(int skip, Iterable<T> iterable)
Skip some items.
|
static <T> List<T> |
toList(Iterable<T> iterable)
Create a new List with all items of an Iterable.
|
public static <T> Iterable<T> empty()
T
- Parameterized item type
public static <T> T first(Iterable<T> iterable)
T
- Parameterized item type
iterable
- Iterable
public static long count(Iterable<?> iterable)
iterable
- Iterable
public static <T> Iterable<T> skip(int skip, Iterable<T> iterable)
T
- Parameterized item type
skip
- How many items to skip
iterable
- Iterable
public static <T,C extends Collection<T>> C addAll(C collection, Iterable<? extends T> iterable)
T
- Parameterized item type
C
- Parameterized collection type
collection
- Collection to add to
iterable
- Items to add to the given collection
public static <T> Iterable<T> asIterable(T... items)
T
- Parameterized item type
items
- Items to turn in an Iterable
public static <T> List<T> toList(Iterable<T> iterable)
T
- Parameterized item type
iterable
- Iterable
public static <T,I extends Iterable<T>> I notEmptyOrNull(I iterable)