Class Generics2
- java.lang.Object
-
- de.agilecoders.wicket.jquery.util.Generics2
-
public final class Generics2 extends Object
helper class to handle creation/transformation/filtering of collections. This class is used to wrap guava. Future releases of bootstrap won't depend on guava anymore.- Author:
- miha
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>filter(Iterable<T> unfiltered, Predicate<T> filter)Returns the elements ofunfilteredthat satisfy givenfilter.static Stringjoin(Iterable<?> elements, char separator)joins all given elements with a special separatorstatic <T> ArrayList<T>newArrayList(Iterable<? extends T> elements)creates a newArrayListfrom given array of elements.static <T> ArrayList<T>newArrayList(Iterator<? extends T> elements)Creates a mutableArrayListinstance containing the given elements.static <T> ArrayList<T>newArrayList(T... elements)creates a newArrayListfrom given array of elements.static <T> Set<T>newHashSet(T... elements)creates a newHashSetfrom given array of elements.static <T> Set<T>newLinkedHashSet(Iterable<? extends T> elements)creates a newLinkedHashSetfrom given array of elements.static List<String>split(CharSequence value, String separator)splits aCharSequenceby given separator.static <P,R>
List<R>transform(List<P> elements, Function<P,R> transformer)Returns a list that appliestransformerto each element ofelementsstatic <P,R>
Set<R>transform(Set<P> elements, Function<P,R> transformer)Returns a list that appliestransformerto each element ofelementsstatic <P,R>
List<R>transform(P[] elements, Function<P,R> transformer)Returns a list that appliestransformerto each element ofelementsstatic <T> List<T>transform(T[] elements)transform an array of elements into a list of elements
-
-
-
Method Detail
-
newArrayList
public static <T> ArrayList<T> newArrayList(T... elements)
creates a newArrayListfrom given array of elements.- Type Parameters:
T- the type of all elements inside the list- Parameters:
elements- the elements to add to newArrayList- Returns:
- new
ArrayListthat contains all given elements - Throws:
IllegalArgumentException- if given array of elements is null
-
newArrayList
public static <T> ArrayList<T> newArrayList(Iterator<? extends T> elements)
Creates a mutableArrayListinstance containing the given elements.- Parameters:
elements- the elements that the list should contain, in order- Returns:
- a new
ArrayListcontaining those elements
-
newArrayList
public static <T> ArrayList<T> newArrayList(Iterable<? extends T> elements)
creates a newArrayListfrom given array of elements.- Type Parameters:
T- the type of all elements inside the list- Parameters:
elements- the elements to add to newArrayList- Returns:
- new
ArrayListthat contains all given elements - Throws:
IllegalArgumentException- if given array of elements is null
-
newLinkedHashSet
public static <T> Set<T> newLinkedHashSet(Iterable<? extends T> elements)
creates a newLinkedHashSetfrom given array of elements.- Type Parameters:
T- the type of all elements inside the set- Parameters:
elements- the elements to add to newLinkedHashSet- Returns:
- new
LinkedHashSetthat contains all given elements - Throws:
IllegalArgumentException- if given array of elements is null
-
newHashSet
public static <T> Set<T> newHashSet(T... elements)
creates a newHashSetfrom given array of elements.- Type Parameters:
T- the type of all elements inside the set- Parameters:
elements- the elements to add to newHashSet- Returns:
- new
HashSetthat contains all given elements - Throws:
IllegalArgumentException- if given array of elements is null
-
join
public static String join(Iterable<?> elements, char separator)
joins all given elements with a special separator- Parameters:
elements- elements to joinseparator- separator to use- Returns:
- elements as string
-
transform
public static <T> List<T> transform(T[] elements)
transform an array of elements into a list of elements- Type Parameters:
T- the type of elements- Parameters:
elements- the elements to add to list- Returns:
- new list of elements
-
transform
public static <P,R> List<R> transform(List<P> elements, Function<P,R> transformer)
Returns a list that appliestransformerto each element ofelements
-
transform
public static <P,R> Set<R> transform(Set<P> elements, Function<P,R> transformer)
Returns a list that appliestransformerto each element ofelements
-
transform
public static <P,R> List<R> transform(P[] elements, Function<P,R> transformer)
Returns a list that appliestransformerto each element ofelements
-
filter
public static <T> List<T> filter(Iterable<T> unfiltered, Predicate<T> filter)
Returns the elements ofunfilteredthat satisfy givenfilter. The resulting iterable's iterator does not supportremove().
-
split
public static List<String> split(CharSequence value, String separator)
splits aCharSequenceby given separator.- Parameters:
value- the value to splitseparator- the separator to use to split value- Returns:
- list of values
-
-