|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.doolin.util.collection.ListUtils
public class ListUtils
This class provides utility methods for collection conversions.
| Method Summary | ||
|---|---|---|
static
|
convertMap(Map<K,? extends T> map,
ItemConverter<T,V> valueExtractor)
Deprecated. Use Maps.transformValues(Map, com.google.common.base.Function)
instead. |
|
static
|
convertMap(Map<K,? extends T> map,
String property)
Converts values from a source map to a target map, by getting a property from the source value. |
|
static
|
extractList(Collection<? extends T> list,
com.google.common.base.Predicate<T> predicate)
Extracts a sub-list by evaluating a Predicate on the source list |
|
static
|
find(List<? extends E> list,
com.google.common.base.Predicate<E> predicate)
Finds the first element in a list which is evaluated to true
by a Predicate. |
|
static
|
indexMap(Collection<? extends T> values,
com.google.common.base.Function<T,K> keyExtractor,
com.google.common.base.Function<T,V> valueExtractor)
Converts a list to a map by extracting keys and values from each element of the list |
|
static
|
indexMap(Collection<? extends T> values,
ItemConverter<T,K> keyExtractor,
ItemConverter<T,V> valueExtractor)
Deprecated. Use indexMap(Collection, Function, Function) instead |
|
static
|
indexMap(Collection<? extends T> list,
String keyProperty,
String valueProperty)
Converts a list to a map by extracting keys and values from each element of the list using a property |
|
static
|
indexMap(List<? extends V> values,
ItemConverter<V,K> keyExtractor)
Deprecated. Use Maps.uniqueIndex(Iterable, Function) instead |
|
static
|
indexMap(List<V> values,
String propertyName)
Converts a list to a map by extracting keys from each element of the list using a property name. |
|
static
|
indexOf(List<? extends E> list,
com.google.common.base.Predicate<E> predicate)
Returns the index of the first element of the list that is evaluated to true by the predicate. |
|
static
|
sublist(List<? extends T> list,
int[] indexes)
Creates a sub-list that contains items referenced by a list of indexes. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
@Deprecated
public static <T,K,V> Map<K,V> convertMap(Map<K,? extends T> map,
ItemConverter<T,V> valueExtractor)
Maps.transformValues(Map, com.google.common.base.Function)
instead.
converter for the values.
T - Type of the value in the source mapK - Type of key for both mapsV - Type of value for the target mapmap - Source mapvalueExtractor - Converter for the value
public static <T,K,V> Map<K,V> convertMap(Map<K,? extends T> map,
String property)
T - Type of the value in the source mapK - Type of key for both mapsV - Type of value for the target mapmap - Source mapproperty - Property to take from the source value
PropertyItemConverter
public static <T> List<T> extractList(Collection<? extends T> list,
com.google.common.base.Predicate<T> predicate)
Predicate on the source list
T - Type of object in the listlist - Source listpredicate - Predicate to evaluate
true for
public static <E> E find(List<? extends E> list,
com.google.common.base.Predicate<E> predicate)
true
by a Predicate.
E - Type of item in the listlist - Listpredicate - Predicate to apply
null if none is found
public static <T,K,V> Map<K,V> indexMap(Collection<? extends T> values,
com.google.common.base.Function<T,K> keyExtractor,
com.google.common.base.Function<T,V> valueExtractor)
T - Type of element in the listK - Type for the keyV - Type for the valuevalues - Source collectionkeyExtractor - Converter for the keyvalueExtractor - Converter for the value
@Deprecated
public static <T,K,V> Map<K,V> indexMap(Collection<? extends T> values,
ItemConverter<T,K> keyExtractor,
ItemConverter<T,V> valueExtractor)
indexMap(Collection, Function, Function) instead
T - Type of element in the listK - Type for the keyV - Type for the valuevalues - Source collectionkeyExtractor - Converter for the keyvalueExtractor - Converter for the value
public static <T,K,V> Map<K,V> indexMap(Collection<? extends T> list,
String keyProperty,
String valueProperty)
T - Type of element in the listK - Type for the keyV - Type for the valuelist - Source collectionkeyProperty - Property for the keyvalueProperty - Property for the value
@Deprecated
public static <K,V> Map<K,V> indexMap(List<? extends V> values,
ItemConverter<V,K> keyExtractor)
Maps.uniqueIndex(Iterable, Function) instead
K - Type for the keyV - Type for the list and the map valuevalues - Source collectionkeyExtractor - Converter for the key
IdentityConverter
public static <K,V> Map<K,V> indexMap(List<V> values,
String propertyName)
K - Type for the keyV - Type for the list and the map valuevalues - Source collectionpropertyName - Property for the key
public static <E> int indexOf(List<? extends E> list,
com.google.common.base.Predicate<E> predicate)
true by the predicate.
E - Type of object in the listlist - Listpredicate - Predicate to apply
public static <T> List<T> sublist(List<? extends T> list,
int[] indexes)
T - Type of object in the listlist - Source listindexes - List of indexes in the source list
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||