public final class Iterables
extends java.lang.Object
A utility class for Iterable.
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
firstOrDefault(java.lang.Iterable<T> iterable)
Gets the first element of an
Iterable or
null if it is empty. |
static <T extends java.lang.Comparable<? super T>> |
isSorted(java.lang.Iterable<T> iterable,
boolean ascending)
Determines whether the supplied
iterable is sorted. |
static <T> T[] |
toArray(java.lang.Iterable<T> iterable,
java.lang.Class<T> type)
Converts an
Iterable of type T into an array of type T. |
static <T> java.util.List<T> |
toList(java.lang.Iterable<T> iterable)
Converts an
Iterable into a List. |
public static <T> T firstOrDefault(java.lang.Iterable<T> iterable)
Gets the first element of an Iterable or
null if it is empty.
T - the type parameteriterable - the iterablenull.public static <T> java.util.List<T> toList(java.lang.Iterable<T> iterable)
Converts an Iterable into a List.
T - the type parameteriterable - the iterableiterable.public static <T> T[] toArray(java.lang.Iterable<T> iterable,
java.lang.Class<T> type)
Converts an Iterable of type T into an array of type T.
T - the type parameteriterable - the iterabletype - the typeT.public static <T extends java.lang.Comparable<? super T>> boolean isSorted(java.lang.Iterable<T> iterable,
boolean ascending)
Determines whether the supplied iterable is sorted.
T - the type parameteriterable - the iterableascending - a boolean value indicating whether to sort in ascending orderiterable is sorted or not.