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> Tstatic <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 booleanstatic booleanstatic booleanstatic <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 ofMap.Entryto aMapwith the same key/value typesstatic <K, V> Map<K,V>For a collection of values of type
Vthat can all be converted to typeK, create a map that indexes all of the values byK.
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 ofMap.Entryto aMapwith the same key/value types Type Parameters:K- the key typeV- the value type Returns: a mapmapValues
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 typeVInT- the value type for the input mapVOutT- the value type for the output map Parameters:inputMap- the input mapmapper- the function used to transform the map values Returns: a mapfilterMap
Filters a map based on a condition
Type Parameters:K- the key typeV- the value type Parameters:map- the input mapcondition- the predicate to filter on Returns: the filtered mapinverseMap
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 typeV- the value type Parameters:inputMap- a map where both the keys and values are unique Returns: a mapuniqueIndex
public static <K, V> Map<K,V> uniqueIndex(Iterable<V> values, Function<? super V,K> indexFunction)For a collection of values of type
Type Parameters:Vthat can all be converted to typeK, create a map that indexes all of the values byK. This requires that no two values map to the same index.K- the index (or key) typeV- the value type Parameters:values- the collection of values to indexindexFunction- 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