public final class CollectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T,U> Map<T,List<U>> |
deepCopyMap(Map<T,? extends List<U>> map)
Perform a deep copy of the provided map of lists.
|
static <T,U> Map<T,List<U>> |
deepCopyMap(Map<T,? extends List<U>> map,
Supplier<Map<T,List<U>>> mapConstructor)
Perform a deep copy of the provided map of lists.
|
static <T,U> Map<T,List<U>> |
deepUnmodifiableMap(Map<T,? extends List<U>> map)
Perform a deep copy of the provided map of lists, and make the result unmodifiable.
|
static <T,U> Map<T,List<U>> |
deepUnmodifiableMap(Map<T,? extends List<U>> map,
Supplier<Map<T,List<U>>> mapConstructor)
Perform a deep copy of the provided map of lists, and make the result unmodifiable.
|
static <T> T |
firstIfPresent(List<T> list) |
static boolean |
isNullOrEmpty(Collection<?> collection) |
static boolean |
isNullOrEmpty(Map<?,?> map) |
static <K,VInT,VOutT> |
mapValues(Map<K,VInT> inputMap,
Function<VInT,VOutT> mapper) |
static <T> List<T> |
mergeLists(List<T> list1,
List<T> list2)
Returns a new list containing the second list appended to the first list.
|
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> |
toMap()
Collect a stream of
Map.Entry to a Map with the same key/value types |
static <T,U> Map<T,List<U>> |
unmodifiableMapOfLists(Map<T,List<U>> map) |
public static boolean isNullOrEmpty(Collection<?> collection)
public static boolean isNullOrEmpty(Map<?,?> map)
public static <T> List<T> mergeLists(List<T> list1, List<T> list2)
public static <T> T firstIfPresent(List<T> list)
T
- Type of elements in the list.list
- List to get first element from.public static <T,U> Map<T,List<U>> deepCopyMap(Map<T,? extends List<U>> map)
public static <T,U> Map<T,List<U>> deepCopyMap(Map<T,? extends List<U>> map, Supplier<Map<T,List<U>>> mapConstructor)
public static <T,U> Map<T,List<U>> unmodifiableMapOfLists(Map<T,List<U>> map)
public static <T,U> Map<T,List<U>> deepUnmodifiableMap(Map<T,? extends List<U>> map)
deepCopyMap(java.util.Map<T, ? extends java.util.List<U>>)
followed by unmodifiableMapOfLists(java.util.Map<T, java.util.List<U>>)
.public static <T,U> Map<T,List<U>> deepUnmodifiableMap(Map<T,? extends List<U>> map, Supplier<Map<T,List<U>>> mapConstructor)
deepCopyMap(java.util.Map<T, ? extends java.util.List<U>>)
followed by unmodifiableMapOfLists(java.util.Map<T, java.util.List<U>>)
.public static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> toMap()
Map.Entry
to a Map
with the same key/value typesK
- the key typeV
- the value typeCopyright © 2020. All rights reserved.