published on in celeb

CollectionUtils (AWS SDK for Java

CollectionUtils (AWS SDK for Java - 2.25.23) public final class CollectionUtils extends Object
  • Method Summary

    All MethodsStatic MethodsConcrete Methods

    Perform a deep copy of the provided map of lists.

    Perform a deep copy of the provided map of lists.

    Perform a deep copy of the provided map of lists, and make the result unmodifiable.

    Perform a deep copy of the provided map of lists, and make the result unmodifiable.

    static <K, V> Map<K,V>

    Filters a map based on a condition

    static <T> T

    static <K, V> Map<K,V>

    Return a new map that is the inverse of the supplied map, with the values becoming the keys and vice versa.

    static boolean

    static boolean

    static boolean

    static <K, VInT, VOutT>
    Map<K,VOutT>

    Transforms the values of a map to another map with the same keys, using the supplied function.

    Returns a new list containing the second list appended to the first list.

    Collect a stream of Map.Entry to a Map with the same key/value types static <K, V> Map<K,V>

    For a collection of values of type V that can all be converted to type K, create a map that indexes all of the values by K.

  • Method Details

    • isNullOrEmpty

      public static boolean isNullOrEmpty(Collection<?> collection)
    • isNullOrEmpty

      public static boolean isNullOrEmpty(Map<?,?> map)
    • isNotEmpty

      public static boolean isNotEmpty(Map<?,?> map)
    • mergeLists

      public static <T> List<T> mergeLists(List<T> list1, List<T> list2)

      Returns a new list containing the second list appended to the first list.

    • firstIfPresent

      public static <T> T firstIfPresent(List<T> list) Type Parameters: T - Type of elements in the list. Parameters: list - List to get first element from. Returns: The first element in the list if it exists. If the list is null or empty this will return null.
    • deepCopyMap

      public static <T, U> Map<T,List<U>> deepCopyMap(Map<T,? extends List<U>> map)

      Perform a deep copy of the provided map of lists. This only performs a deep copy of the map and lists. Entries are not copied, so care should be taken to ensure that entries are immutable if preventing unwanted mutations of the elements is desired.

    • deepCopyMap

      Perform a deep copy of the provided map of lists. This only performs a deep copy of the map and lists. Entries are not copied, so care should be taken to ensure that entries are immutable if preventing unwanted mutations of the elements is desired.

    • unmodifiableMapOfLists

      public static <T, U> Map<T,List<U>> unmodifiableMapOfLists(Map<T,List<U>> map)
    • deepUnmodifiableMap

      public static <T, U> Map<T,List<U>> deepUnmodifiableMap(Map<T,? extends List<U>> map)
    • deepUnmodifiableMap

    • toMap

      Collect a stream of Map.Entry to a Map with the same key/value types Type Parameters: K - the key type V - the value type Returns: a map
    • mapValues

      public static <K, VInT, VOutT> Map<K,VOutT> mapValues(Map<K,VInT> inputMap, Function<VInT,VOutT> mapper)

      Transforms the values of a map to another map with the same keys, using the supplied function.

      Type Parameters: K - the key type VInT - the value type for the input map VOutT - the value type for the output map Parameters: inputMap - the input map mapper - the function used to transform the map values Returns: a map
    • filterMap

      Filters a map based on a condition

      Type Parameters: K - the key type V - the value type Parameters: map - the input map condition - the predicate to filter on Returns: the filtered map
    • inverseMap

      public static <K, V> Map<K,V> inverseMap(Map<V,K> inputMap)

      Return a new map that is the inverse of the supplied map, with the values becoming the keys and vice versa. Requires the values to be unique.

      Type Parameters: K - the key type V - the value type Parameters: inputMap - a map where both the keys and values are unique Returns: a map
    • uniqueIndex

      public static <K, V> Map<K,V> uniqueIndex(Iterable<V> values, Function<? super V,K> indexFunction)

      For a collection of values of type V that can all be converted to type K, create a map that indexes all of the values by K. This requires that no two values map to the same index.

      Type Parameters: K - the index (or key) type V - the value type Parameters: values - the collection of values to index indexFunction - the function used to convert a value to its index Returns: a (modifiable) map that indexes K to its unique value V Throws: IllegalArgumentException - if any of the values map to the same index

ncG1vNJzZmirlKB7ornAs6anmaeoe6S7zGihmq6RZK6xtY6lmK2do6l8tLvFra6aqpVkrq6t2ailaJmnqMClt46uq6Kko2SQsLjLnpqtoZ%2BjorW1y6xloaydoQ%3D%3D