Class CollectionUtils


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

      • CollectionUtils

        public CollectionUtils()
    • 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
      • 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)
      • filterIntoList

        public static <T,​C extends Collection<T>> List<T> filterIntoList​(C collection,
                                                                               Predicate<T> predicate)
      • findItem

        public static <T> T findItem​(Collection<T> items,
                                     Object key)
      • 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)
      • sublistByIndexes

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