public class CollectionHelper
extends java.lang.Object
Collections
.Constructor and Description |
---|
CollectionHelper() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
copySelective(java.util.Collection<? extends T> source,
java.util.Collection<? super T> target,
Predicate<T> filter)
Copies all elements that match a predicate.
|
static <T> java.util.List<T> |
selectAsList(java.util.Collection<? extends T> source,
Predicate<T> filter)
Retrieves all elements from a collection that match a predicate.
|
static <T> T |
selectFirst(java.util.Collection<? extends T> source,
Predicate<T> filter)
Retrieves the first element from a collection that matches a predicate.
|
public static <T> void copySelective(java.util.Collection<? extends T> source, java.util.Collection<? super T> target, Predicate<T> filter)
public static <T> java.util.List<T> selectAsList(java.util.Collection<? extends T> source, Predicate<T> filter)
T
- The type of elements we are interested in.source
- A collection containing elements we are interested in. Not null. Can be empty.filter
- The predicate determining if an element is to be retrieved. Not null.public static <T> T selectFirst(java.util.Collection<? extends T> source, Predicate<T> filter)
T
- The type of elements we are interested in.source
- A collection containing elements we are interested in. Not null. Can be empty.filter
- The predicate determining if an element is to be retrieved. Not null.