public final class Generics2 extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
filter(Iterable<T> unfiltered,
com.google.common.base.Predicate<T> filter)
Returns the elements of
unfiltered that satisfy given filter. |
static String |
join(Iterable<?> elements,
char separator)
joins all given elements with a special separator
|
static <T> ArrayList<T> |
newArrayList(Iterable<? extends T> elements)
creates a new
ArrayList from given array of elements. |
static <T> ArrayList<T> |
newArrayList(Iterator<? extends T> elements)
Creates a mutable
ArrayList instance containing the given
elements. |
static <T> ArrayList<T> |
newArrayList(T... elements)
creates a new
ArrayList from given array of elements. |
static <T> Set<T> |
newHashSet(T... elements)
creates a new
HashSet from given array of elements. |
static <T> Set<T> |
newLinkedHashSet(Iterable<? extends T> elements)
creates a new
LinkedHashSet from given array of elements. |
static List<String> |
split(CharSequence value,
String separator)
splits a
CharSequence by given separator. |
static <P,R> List<R> |
transform(List<P> elements,
com.google.common.base.Function<P,R> transformer)
Returns a list that applies
transformer to each element of elements |
static <P,R> List<R> |
transform(P[] elements,
com.google.common.base.Function<P,R> transformer)
Returns a list that applies
transformer to each element of elements |
static <P,R> Set<R> |
transform(Set<P> elements,
com.google.common.base.Function<P,R> transformer)
Returns a list that applies
transformer to each element of elements |
static <T> List<T> |
transform(T[] elements)
transform an array of elements into a list of elements
|
public static <T> ArrayList<T> newArrayList(T... elements)
ArrayList from given array of elements.T - the type of all elements inside the listelements - the elements to add to new ArrayListArrayList that contains all given elementsIllegalArgumentException - if given array of elements is nullpublic static <T> ArrayList<T> newArrayList(Iterator<? extends T> elements)
ArrayList instance containing the given
elements.elements - the elements that the list should contain, in orderArrayList containing those elementspublic static <T> ArrayList<T> newArrayList(Iterable<? extends T> elements)
ArrayList from given array of elements.T - the type of all elements inside the listelements - the elements to add to new ArrayListArrayList that contains all given elementsIllegalArgumentException - if given array of elements is nullpublic static <T> Set<T> newLinkedHashSet(Iterable<? extends T> elements)
LinkedHashSet from given array of elements.T - the type of all elements inside the setelements - the elements to add to new LinkedHashSetLinkedHashSet that contains all given elementsIllegalArgumentException - if given array of elements is nullpublic static <T> Set<T> newHashSet(T... elements)
HashSet from given array of elements.T - the type of all elements inside the setelements - the elements to add to new HashSetHashSet that contains all given elementsIllegalArgumentException - if given array of elements is nullpublic static String join(Iterable<?> elements, char separator)
elements - elements to joinseparator - separator to usepublic static <T> List<T> transform(T[] elements)
T - the type of elementselements - the elements to add to listpublic static <P,R> List<R> transform(List<P> elements, com.google.common.base.Function<P,R> transformer)
transformer to each element of elementspublic static <P,R> Set<R> transform(Set<P> elements, com.google.common.base.Function<P,R> transformer)
transformer to each element of elementspublic static <P,R> List<R> transform(P[] elements, com.google.common.base.Function<P,R> transformer)
transformer to each element of elementspublic static <T> List<T> filter(Iterable<T> unfiltered, com.google.common.base.Predicate<T> filter)
unfiltered that satisfy given filter. The
resulting iterable's iterator does not support remove().public static List<String> split(CharSequence value, String separator)
CharSequence by given separator.value - the value to splitseparator - the separator to use to split valueCopyright © 2014. All Rights Reserved.