public final class Iterables
extends java.lang.Object
Iterable. This class consists of factory methods that allow creation
of a new Collection. These methods will infer the type of the collection.| Modifier and Type | Method and Description |
|---|---|
static <T> T |
first(java.lang.Iterable<T> iterable)
Retrieve the first item from an
Iterable. |
static <T> java.util.List<T> |
newImmutableList(java.util.List<? extends T> list)
Create a new immutable instance of
List preloaded with a given list of items. |
static <T> java.util.List<T> |
newImmutableList(T... items)
Create a new immutable instance of
List loaded with a dynamic list of items. |
static <T> java.util.List<T> |
newList()
Create a new instance of
List. |
static <T> java.util.List<T> |
newList(T... items)
Create a new instance of
List preloaded with a dynamic list of items. |
static <T> java.util.Set<T> |
newSet()
Creates a new instance of
Set. |
public static <T> java.util.List<T> newList()
List. This method will return a new ArrayList.List@SafeVarargs public static <T> java.util.List<T> newList(T... items)
List preloaded with a dynamic list of items. This method will return a new
ArrayList.items - A dynamic list of items that needs to be added to the list.List preloaded with the given items.public static <T> java.util.List<T> newImmutableList(java.util.List<? extends T> list)
List preloaded with a given list of items.list - An instance of List that contains items that need to be added to the immutable list.List.@SafeVarargs public static <T> java.util.List<T> newImmutableList(T... items)
List loaded with a dynamic list of items. These items shouldn't be null
or this method will throw an IllegalArgumentException.items - A dynamic list of items that should be loaded in the immutable list.Listpublic static <T> java.util.Set<T> newSet()
Set. This method will return a new instance of HashSet.Setpublic static <T> T first(java.lang.Iterable<T> iterable)
Iterable.iterable - The iterable to retrieve the first item from.IterableCopyright © 2021 eHealth. All rights reserved.