Package org.openforis.commons.collection
Class CollectionUtils
- java.lang.Object
-
- org.openforis.commons.collection.CollectionUtils
-
public abstract class CollectionUtils extends Object
- Author:
- M. Togna, S. Ricci
-
-
Constructor Summary
Constructors Constructor Description CollectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Collection<T>addIgnoreNull(Collection<T> items, T item)static <T> List<T>clone(List<T> list)Creates a clone of the specified list (NOT a DEEP CLONE of the objects inside the list)static <K,V>
voidcloneValuesInto(Map<K,V> fromMap, Map<K,V> intoMap)static <T> List<T>copyAndFillWith(List<T> list, int newSize, T fillValue)static <T> List<T>copyAndFillWithNulls(List<T> list, int newSize)static <T extends DeepComparable>
booleandeepEquals(Collection<T> coll1, Collection<T> coll2)static <T extends DeepComparable>
booleandeepEquals(Collection<T> coll1, Collection<T> coll2, boolean ignoreId)static <T,C extends Collection<T>>
voidfilter(C collection, Predicate<T> predicate)static <T,C extends Collection<T>>
List<T>filterIntoList(C collection, Predicate<T> predicate)static <T> Tfind(Collection<T> items, Predicate<T> predicate)static <T> TfindItem(Collection<T> items, Object key)static <T> TfindItem(Collection<T> items, Object key, String keyPropertyName)static <T> List<Integer>indexOfItems(List<T> list, Collection<T> items)static <T> Set<T>intersect(Collection<T> listA, Collection<T> listB)static booleanisNotEmpty(Collection<?> collection)static <T> List<T>map(Collection<T> collection, Transformer<T> transformer)static <I,T>
List<I>project(Collection<T> items, String propertyName)static <T> voidshiftItem(List<T> list, T item, int toIndex)Shifts the item to the specified index.static <T> List<T>sublistByIndexes(List<T> source, List<Integer> indexes)static <T> Collection<T>unmodifiableCollection(Collection<? extends T> collection)static <T> List<T>unmodifiableList(List<? extends T> list)Returns an unmodifiable view of the specified list.static <K,V>
Map<K,V>unmodifiableMap(Map<? extends K,? extends V> map)static <T> Set<T>unmodifiableSet(Set<? extends T> set)
-
-
-
Method Detail
-
unmodifiableList
public static <T> List<T> unmodifiableList(List<? extends T> list)
Returns an unmodifiable view of the specified list.
This method makes use of the method unmodifiableList of java.util.Collections and returns an empty list if the provided list is null.- Parameters:
list-- Returns:
- See Also:
java.util.Collections.unmodifiableList
-
unmodifiableCollection
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> collection)
-
shiftItem
public static <T> void shiftItem(List<T> list, T item, int toIndex)
Shifts the item to the specified index.
-
isNotEmpty
public static boolean isNotEmpty(Collection<?> collection)
-
filter
public static <T,C extends Collection<T>> void filter(C collection, Predicate<T> predicate)
-
filterIntoList
public static <T,C extends Collection<T>> List<T> filterIntoList(C collection, Predicate<T> predicate)
-
find
public static <T> T find(Collection<T> items, Predicate<T> predicate)
-
findItem
public static <T> T findItem(Collection<T> items, Object key)
-
findItem
public static <T> T findItem(Collection<T> items, Object key, String keyPropertyName)
-
addIgnoreNull
public static <T> Collection<T> addIgnoreNull(Collection<T> items, T item)
-
project
public static <I,T> List<I> project(Collection<T> items, String propertyName)
-
deepEquals
public static <T extends DeepComparable> boolean deepEquals(Collection<T> coll1, Collection<T> coll2)
-
deepEquals
public static <T extends DeepComparable> boolean deepEquals(Collection<T> coll1, Collection<T> coll2, boolean ignoreId)
-
clone
public static <T> List<T> clone(List<T> list)
Creates a clone of the specified list (NOT a DEEP CLONE of the objects inside the list)- Parameters:
list-- Returns:
-
intersect
public static <T> Set<T> intersect(Collection<T> listA, Collection<T> listB)
-
indexOfItems
public static <T> List<Integer> indexOfItems(List<T> list, Collection<T> items)
-
map
public static <T> List<T> map(Collection<T> collection, Transformer<T> transformer)
-
-