Class CollectionUtils

java.lang.Object
org.openforis.commons.collection.CollectionUtils

public abstract class CollectionUtils extends Object
Author:
M. Togna, S. Ricci
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • 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
    • unmodifiableSet

      public static <T> Set<T> unmodifiableSet(Set<? extends T> set)
    • unmodifiableMap

      public static <K, V> Map<K,V> unmodifiableMap(Map<? extends K,? extends V> map)
    • 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)
    • 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:
    • cloneValuesInto

      public static <K, V> void cloneValuesInto(Map<K,V> fromMap, Map<K,V> intoMap)
    • copyAndFillWithNulls

      public static <T> List<T> copyAndFillWithNulls(List<T> list, int newSize)
    • copyAndFillWith

      public static <T> List<T> copyAndFillWith(List<T> list, int newSize, T fillValue)
    • 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)
    • sublistByIndexes

      public static <T> List<T> sublistByIndexes(List<T> source, List<Integer> indexes)