public final class Maps
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <K,V,E extends java.lang.Exception> |
compute(java.util.Map<K,V> map,
K key,
Try.BiFunction<? super K,? super V,? extends V,E> remappingFunction)
Attempts to compute a mapping for the specified key and its current
mapped value (or
null if there is no current mapping). |
static <K,V,E extends java.lang.Exception> |
computeIfAbsent(java.util.Map<K,V> map,
K key,
Try.Function<? super K,? extends V,E> mappingFunction)
If the specified key is not already associated with a value (or is mapped
to
null ), attempts to compute its value using the given mapping
function and enters it into this map unless null . |
static <K,V,E extends java.lang.Exception> |
computeIfPresent(java.util.Map<K,V> map,
K key,
Try.BiFunction<? super K,? super V,? extends V,E> remappingFunction)
If the value for the specified key is present and non-null, attempts to
compute a new mapping given the key and its current mapped value.
|
static boolean |
contains(java.util.Map<?,?> map,
java.util.Map.Entry<?,?> entry)
Check if the specified
Map contains the specified Entry |
static boolean |
contains(java.util.Map<?,?> map,
java.lang.Object key,
java.lang.Object value) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(java.util.Collection<?> entityList) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(java.util.Collection<?> entityList,
boolean ignoreNullProperty) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(java.util.Collection<?> entityList,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(java.util.Collection<?> entityList,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(java.util.Collection<?> entityList,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(M resultMap,
java.lang.Object entity) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(M resultMap,
java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.Map<java.lang.String,java.lang.Object> |
deepEntity2Map(java.lang.Object entity) |
static java.util.Map<java.lang.String,java.lang.Object> |
deepEntity2Map(java.lang.Object entity,
boolean ignoreNullProperty) |
static java.util.Map<java.lang.String,java.lang.Object> |
deepEntity2Map(java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.Map<java.lang.String,java.lang.Object> |
deepEntity2Map(java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static java.util.Map<java.lang.String,java.lang.Object> |
deepEntity2Map(java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(java.lang.Object entity,
Supplier<? extends M> mapSupplier) |
static <K,V> java.util.Map<K,Pair<V,Nullable<V>>> |
difference(java.util.Map<K,V> map,
java.util.Map<K,V> map2) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(java.util.Collection<?> entityList) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(java.util.Collection<?> entityList,
boolean ignoreNullProperty) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(java.util.Collection<?> entityList,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(java.util.Collection<?> entityList,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(java.util.Collection<?> entityList,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(M resultMap,
java.lang.Object entity) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(M resultMap,
java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2FlatMap(java.lang.Object entity) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2FlatMap(java.lang.Object entity,
boolean ignoreNullProperty) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2FlatMap(java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2FlatMap(java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2FlatMap(java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(java.lang.Object entity,
Supplier<? extends M> mapSupplier) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(java.util.Collection<?> entityList) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(java.util.Collection<?> entityList,
boolean ignoreNullProperty) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(java.util.Collection<?> entityList,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(java.util.Collection<?> entityList,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(java.util.Collection<?> entityList,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(M resultMap,
java.lang.Object entity) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(M resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(M resultMap,
java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2Map(java.lang.Object entity) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2Map(java.lang.Object entity,
boolean ignoreNullProperty) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2Map(java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2Map(java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static java.util.Map<java.lang.String,java.lang.Object> |
entity2Map(java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(java.lang.Object entity,
Supplier<? extends M> mapSupplier) |
static <K,V,E extends java.lang.Exception> |
filter(java.util.Map<K,V> map,
Try.BiPredicate<? super K,? super V,E> predicate) |
static <K,V,E extends java.lang.Exception> |
filterByKey(java.util.Map<K,V> map,
Try.Predicate<? super K,E> predicate) |
static <K,V,E extends java.lang.Exception> |
filterByValue(java.util.Map<K,V> map,
Try.Predicate<? super V,E> predicate) |
static <K,V> java.util.Map<V,java.util.List<K>> |
flatInvert(java.util.Map<K,? extends java.util.Collection<? extends V>> map) |
static java.util.Map<java.lang.String,java.lang.Object> |
flatten(java.util.Map<java.lang.String,java.lang.Object> map) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
flatten(java.util.Map<java.lang.String,java.lang.Object> map,
java.lang.String delimiter,
Supplier<M> mapSupplier) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
flatten(java.util.Map<java.lang.String,java.lang.Object> map,
Supplier<M> mapSupplier) |
static <K,V,E extends java.lang.Exception> |
forEach(java.util.Map<K,V> map,
Try.BiConsumer<? super K,? super V,E> action)
Performs the given action for each entry in this map until all entries
have been processed or the action throws an exception.
|
static <K,V> Nullable<V> |
get(java.util.Map<K,V> map,
java.lang.Object key) |
static <K,E> java.util.Set<E> |
getAndPutLinkedHashSetIfAbsent(java.util.Map<K,java.util.Set<E>> map,
K key)
Returns the value associated with the specified
key if it exists in the specified map contains, or the new put Set if it's absent. |
static <K,E> java.util.List<E> |
getAndPutListIfAbsent(java.util.Map<K,java.util.List<E>> map,
K key)
Returns the value associated with the specified
key if it exists in the specified map contains, or the new put List if it's absent. |
static <K,KK,VV> java.util.Map<KK,VV> |
getAndPutMapIfAbsent(java.util.Map<K,java.util.Map<KK,VV>> map,
K key)
Returns the value associated with the specified
key if it exists in the specified map contains, or the new put Map if it's absent. |
static <K,E> java.util.Set<E> |
getAndPutSetIfAbsent(java.util.Map<K,java.util.Set<E>> map,
K key)
Returns the value associated with the specified
key if it exists in the specified map contains, or the new put Set if it's absent. |
static <K,V> java.util.List<V> |
getIfPresentForEach(java.util.Map<K,V> map,
java.util.Collection<?> keys)
Returns a list of values of the keys which exist in the specified
Map . |
static <K,V> V |
getOrDefault(java.util.Map<K,V> map,
java.lang.Object key,
V defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key. |
static <K,V> java.util.List<V> |
getOrDefaultForEach(java.util.Map<K,V> map,
java.util.Collection<?> keys,
V defaultValue) |
static <K,E,V extends java.util.List<E>> |
getOrEmptyList(java.util.Map<K,V> map,
java.lang.Object key)
Returns the value to which the specified key is mapped, or
an empty immutable
List if this map contains no mapping for the key. |
static <K,E,V extends java.util.Set<E>> |
getOrEmptySet(java.util.Map<K,V> map,
java.lang.Object key)
Returns the value to which the specified key is mapped, or
an empty immutable
Set if this map contains no mapping for the key. |
static <K,V> java.util.Map<K,V> |
intersection(java.util.Map<K,V> map,
java.util.Map<? extends K,? extends V> map2) |
static <K,V> java.util.Map<V,K> |
invert(java.util.Map<K,V> map) |
static <T> java.util.List<T> |
map2Entity(java.lang.Class<T> targetClass,
java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> mList) |
static <T> java.util.List<T> |
map2Entity(java.lang.Class<T> targetClass,
java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> mList,
boolean igoreNullProperty,
boolean ignoreUnknownProperty) |
static <T> java.util.List<T> |
map2Entity(java.lang.Class<T> targetClass,
java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> mList,
java.util.Collection<java.lang.String> selectPropNames) |
static <T> T |
map2Entity(java.lang.Class<T> targetClass,
java.util.Map<java.lang.String,java.lang.Object> m) |
static <T> T |
map2Entity(java.lang.Class<T> targetClass,
java.util.Map<java.lang.String,java.lang.Object> m,
boolean ignoreNullProperty,
boolean ignoreUnknownProperty) |
static <T> T |
map2Entity(java.lang.Class<T> targetClass,
java.util.Map<java.lang.String,java.lang.Object> m,
java.util.Collection<java.lang.String> selectPropNames) |
static <K,V,E extends java.lang.Exception> |
merge(java.util.Map<K,V> map,
K key,
V value,
Try.BiFunction<? super V,? super V,? extends V,E> remappingFunction)
If the specified key is not already associated with a value or is
associated with null, associates it with the given non-null value.
|
static <T,K,E extends java.lang.Exception> |
newLinkedHashMap(java.util.Collection<? extends T> c,
Try.Function<? super T,? extends K,E> keyExtractor) |
static <T,K,E extends java.lang.Exception> |
newMap(java.util.Collection<? extends T> c,
Try.Function<? super T,? extends K,E> keyExtractor) |
static <T,K,V,E extends java.lang.Exception,E2 extends java.lang.Exception> |
newMap(java.util.Collection<? extends T> c,
Try.Function<? super T,? extends K,E> keyExtractor,
Try.Function<? super T,? extends V,E2> valueExtractor) |
static <T,K,V,M extends java.util.Map<K,V>,E extends java.lang.Exception,E2 extends java.lang.Exception> |
newMap(java.util.Collection<? extends T> c,
Try.Function<? super T,? extends K,E> keyExtractor,
Try.Function<? super T,? extends V,E2> valueExtractor,
IntFunction<M> mapSupplier) |
static <K,V> V |
putIfAbsent(java.util.Map<K,V> map,
K key,
Supplier<V> supplier) |
static <K,V> V |
putIfAbsent(java.util.Map<K,V> map,
K key,
V value)
If the specified key is not already associated with a value (or is mapped
to
null ) associates it with the given value and returns
null , else returns the current value. |
static <K,V> boolean |
remove(java.util.Map<K,V> map,
java.util.Map.Entry<?,?> entry)
Removes the specified entry.
|
static <K,V> boolean |
remove(java.util.Map<K,V> map,
java.lang.Object key,
java.lang.Object value)
Removes the entry for the specified key only if it is currently
mapped to the specified value.
|
static boolean |
removeEntries(java.util.Map<?,?> map,
java.util.Map<?,?> entriesToRemove)
The the entries from the specified
Map |
static <K,V,E extends java.lang.Exception> |
removeIf(java.util.Map<K,V> map,
Try.Predicate<? super java.util.Map.Entry<K,V>,E> filter)
Removes entries from the specified
map by the the specified filter . |
static <K,V,E extends java.lang.Exception> |
removeIfKey(java.util.Map<K,V> map,
Try.Predicate<? super K,E> filter)
Removes entries from the specified
map by the the specified filter . |
static <K,V,E extends java.lang.Exception> |
removeIfValue(java.util.Map<K,V> map,
Try.Predicate<? super V,E> filter)
Removes entries from the specified
map by the the specified filter . |
static boolean |
removeKeys(java.util.Map<?,?> map,
java.util.Collection<?> keysToRemove) |
static <K,V> V |
replace(java.util.Map<K,V> map,
K key,
V newValue)
Replaces the entry for the specified key only if it is
currently mapped to some value.
|
static <K,V> boolean |
replace(java.util.Map<K,V> map,
K key,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently
mapped to the specified value.
|
static <K,V,E extends java.lang.Exception> |
replaceAll(java.util.Map<K,V> map,
Try.BiFunction<? super K,? super V,? extends V,E> function)
Replaces each entry's value with the result of invoking the given
function on that entry until all entries have been processed or the
function throws an exception.
|
static <K,V> java.util.Map<K,Pair<Nullable<V>,Nullable<V>>> |
symmetricDifference(java.util.Map<K,V> map,
java.util.Map<K,V> map2) |
static java.util.Map<java.lang.String,java.lang.Object> |
unflatten(java.util.Map<java.lang.String,java.lang.Object> map) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
unflatten(java.util.Map<java.lang.String,java.lang.Object> map,
java.lang.String delimiter,
Supplier<M> mapSupplier) |
static <M extends java.util.Map<java.lang.String,java.lang.Object>> |
unflatten(java.util.Map<java.lang.String,java.lang.Object> map,
Supplier<M> mapSupplier) |
public static <T,K,E extends java.lang.Exception> java.util.Map<K,T> newMap(java.util.Collection<? extends T> c, Try.Function<? super T,? extends K,E> keyExtractor) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <T,K,E extends java.lang.Exception> java.util.Map<K,T> newLinkedHashMap(java.util.Collection<? extends T> c, Try.Function<? super T,? extends K,E> keyExtractor) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <T,K,V,E extends java.lang.Exception,E2 extends java.lang.Exception> java.util.Map<K,V> newMap(java.util.Collection<? extends T> c, Try.Function<? super T,? extends K,E> keyExtractor, Try.Function<? super T,? extends V,E2> valueExtractor) throws E extends java.lang.Exception, E2 extends java.lang.Exception
E extends java.lang.Exception
public static <T,K,V,M extends java.util.Map<K,V>,E extends java.lang.Exception,E2 extends java.lang.Exception> M newMap(java.util.Collection<? extends T> c, Try.Function<? super T,? extends K,E> keyExtractor, Try.Function<? super T,? extends V,E2> valueExtractor, IntFunction<M> mapSupplier) throws E extends java.lang.Exception, E2 extends java.lang.Exception
E extends java.lang.Exception
public static <K,V> Nullable<V> get(java.util.Map<K,V> map, java.lang.Object key)
public static <K,V> java.util.List<V> getIfPresentForEach(java.util.Map<K,V> map, java.util.Collection<?> keys)
Map
.
If the key dosn't exist in the Map
, No value will be added into the returned list.map
- keys
- public static <K,V> V getOrDefault(java.util.Map<K,V> map, java.lang.Object key, V defaultValue)
defaultValue
if this map contains no mapping for the key.map
- key
- defaultValue
- public static <K,E,V extends java.util.List<E>> java.util.List<E> getOrEmptyList(java.util.Map<K,V> map, java.lang.Object key)
List
if this map contains no mapping for the key.map
- key
- public static <K,E,V extends java.util.Set<E>> java.util.Set<E> getOrEmptySet(java.util.Map<K,V> map, java.lang.Object key)
Set
if this map contains no mapping for the key.map
- key
- public static <K,V> java.util.List<V> getOrDefaultForEach(java.util.Map<K,V> map, java.util.Collection<?> keys, V defaultValue)
public static <K,E> java.util.List<E> getAndPutListIfAbsent(java.util.Map<K,java.util.List<E>> map, K key)
key
if it exists in the specified map
contains, or the new put List
if it's absent.map
- key
- public static <K,E> java.util.Set<E> getAndPutSetIfAbsent(java.util.Map<K,java.util.Set<E>> map, K key)
key
if it exists in the specified map
contains, or the new put Set
if it's absent.map
- key
- public static <K,E> java.util.Set<E> getAndPutLinkedHashSetIfAbsent(java.util.Map<K,java.util.Set<E>> map, K key)
key
if it exists in the specified map
contains, or the new put Set
if it's absent.map
- key
- public static <K,KK,VV> java.util.Map<KK,VV> getAndPutMapIfAbsent(java.util.Map<K,java.util.Map<KK,VV>> map, K key)
key
if it exists in the specified map
contains, or the new put Map
if it's absent.map
- key
- public static boolean contains(java.util.Map<?,?> map, java.util.Map.Entry<?,?> entry)
Map
contains the specified Entry
map
- entry
- public static boolean contains(java.util.Map<?,?> map, java.lang.Object key, java.lang.Object value)
public static <K,V> java.util.Map<K,V> intersection(java.util.Map<K,V> map, java.util.Map<? extends K,? extends V> map2)
public static <K,V> java.util.Map<K,Pair<V,Nullable<V>>> difference(java.util.Map<K,V> map, java.util.Map<K,V> map2)
public static <K,V> java.util.Map<K,Pair<Nullable<V>,Nullable<V>>> symmetricDifference(java.util.Map<K,V> map, java.util.Map<K,V> map2)
public static <K,V> V putIfAbsent(java.util.Map<K,V> map, K key, V value)
null
) associates it with the given value and returns
null
, else returns the current value.key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keynull
if there was no mapping for the key.
(A null
return can also indicate that the map
previously associated null
with the key,
if the implementation supports null values.)java.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the key or value is of an inappropriate
type for this map
(optional)java.lang.NullPointerException
- if the specified map is null, or if the specified key or value is null,
and this map does not permit null keys or values
(optional)java.lang.IllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this map
(optional)public static <K,V> V putIfAbsent(java.util.Map<K,V> map, K key, Supplier<V> supplier)
public static <K,V> boolean remove(java.util.Map<K,V> map, java.util.Map.Entry<?,?> entry)
map
- entry
- public static <K,V> boolean remove(java.util.Map<K,V> map, java.lang.Object key, java.lang.Object value)
key
- key with which the specified value is associatedvalue
- value expected to be associated with the specified keytrue
if the value was removedjava.lang.UnsupportedOperationException
- if the remove
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the key or value is of an inappropriate
type for this map
(optional)java.lang.NullPointerException
- if the specified key or value is null,
and this map does not permit null keys or values
(optional)public static boolean removeKeys(java.util.Map<?,?> map, java.util.Collection<?> keysToRemove)
map
- keysToRemove
- true
if any key/value was removed, otherwise false
.public static boolean removeEntries(java.util.Map<?,?> map, java.util.Map<?,?> entriesToRemove)
Map
map
- entriesToRemove
- true
if any key/value was removed, otherwise false
.public static <K,V,E extends java.lang.Exception> boolean removeIf(java.util.Map<K,V> map, Try.Predicate<? super java.util.Map.Entry<K,V>,E> filter) throws E extends java.lang.Exception
map
by the the specified filter
.map
- filter
- true
if there are one or more than one entries removed from the specified map.E
E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> boolean removeIfKey(java.util.Map<K,V> map, Try.Predicate<? super K,E> filter) throws E extends java.lang.Exception
map
by the the specified filter
.map
- filter
- true
if there are one or more than one entries removed from the specified map.E
E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> boolean removeIfValue(java.util.Map<K,V> map, Try.Predicate<? super V,E> filter) throws E extends java.lang.Exception
map
by the the specified filter
.map
- filter
- true
if there are one or more than one entries removed from the specified map.E
E extends java.lang.Exception
public static <K,V> boolean replace(java.util.Map<K,V> map, K key, V oldValue, V newValue)
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keynewValue
- value to be associated with the specified keytrue
if the value was replacedjava.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the class of a specified key or value
prevents it from being stored in this mapjava.lang.NullPointerException
- if a specified key or newValue is null,
and this map does not permit null keys or valuesjava.lang.NullPointerException
- if oldValue is null and this map does not
permit null values
(optional)java.lang.IllegalArgumentException
- if some property of a specified key
or value prevents it from being stored in this mappublic static <K,V> V replace(java.util.Map<K,V> map, K key, V newValue)
key
- key with which the specified value is associatednewValue
- value to be associated with the specified keynull
if there was no mapping for the key.
(A null
return can also indicate that the map
previously associated null
with the key,
if the implementation supports null values.)java.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map
(optional)java.lang.NullPointerException
- if the specified key or value is null,
and this map does not permit null keys or valuesjava.lang.IllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this mappublic static <K,V,E extends java.lang.Exception> void replaceAll(java.util.Map<K,V> map, Try.BiFunction<? super K,? super V,? extends V,E> function) throws E extends java.lang.Exception
function
- the function to apply to each entryjava.lang.UnsupportedOperationException
- if the set
operation
is not supported by this map's entry set iterator.java.lang.ClassCastException
- if the class of a replacement value
prevents it from being stored in this mapjava.lang.NullPointerException
- if the specified function is null, or the
specified replacement value is null, and this map does not permit null
valuesjava.lang.ClassCastException
- if a replacement value is of an inappropriate
type for this map
(optional)java.lang.NullPointerException
- if function or a replacement value is null,
and this map does not permit null keys or values
(optional)java.lang.IllegalArgumentException
- if some property of a replacement value
prevents it from being stored in this map
(optional)java.util.ConcurrentModificationException
- if an entry is found to be
removed during iterationE extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> V computeIfAbsent(java.util.Map<K,V> map, K key, Try.Function<? super K,? extends V,E> mappingFunction) throws E extends java.lang.Exception
null
), attempts to compute its value using the given mapping
function and enters it into this map unless null
.
If the function returns null
no mapping is recorded. If
the function itself throws an (unchecked) exception, the
exception is rethrown, and no mapping is recorded. The most
common usage is to construct a new object serving as an initial
mapped value or memoized result, as in:
map.computeIfAbsent(key, k -> new Value(f(k)));
Or to implement a multi-value map, Map<K,Collection<V>>
,
supporting multiple values per key:
map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);
key
- key with which the specified value is to be associatedmappingFunction
- the function to compute a valuejava.lang.NullPointerException
- if the specified map is null, or the specified key is null and
this map does not support null keys, or the mappingFunction
is nulljava.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map
(optional)E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> V computeIfPresent(java.util.Map<K,V> map, K key, Try.BiFunction<? super K,? super V,? extends V,E> remappingFunction) throws E extends java.lang.Exception
If the function returns null
, the mapping is removed. If the
function itself throws an (unchecked) exception, the exception is
rethrown, and the current mapping is left unchanged.
key
- key with which the specified value is to be associatedremappingFunction
- the function to compute a valuejava.lang.NullPointerException
- if the specified map is null, or the specified key is null and
this map does not support null keys, or the
remappingFunction is nulljava.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map
(optional)E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> V compute(java.util.Map<K,V> map, K key, Try.BiFunction<? super K,? super V,? extends V,E> remappingFunction) throws E extends java.lang.Exception
null
if there is no current mapping). For
example, to either create or append a String
msg to a value
mapping:
map.compute(key, (k, v) -> (v == null) ? msg : v.concat(msg))
(Method merge()
is often simpler to use for such purposes.)
If the function returns null
, the mapping is removed (or
remains absent if initially absent). If the function itself throws an
(unchecked) exception, the exception is rethrown, and the current mapping
is left unchanged.
key
- key with which the specified value is to be associatedremappingFunction
- the function to compute a valuejava.lang.NullPointerException
- if the specified map is null, or the specified key is null and
this map does not support null keys, or the
remappingFunction is nulljava.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map
(optional)E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> V merge(java.util.Map<K,V> map, K key, V value, Try.BiFunction<? super V,? super V,? extends V,E> remappingFunction) throws E extends java.lang.Exception
null
. This
method may be of use when combining multiple mapped values for a key.
For example, to either create or append a String msg
to a
value mapping:
map.merge(key, msg, String::concat)
If the function returns null
the mapping is removed. If the
function itself throws an (unchecked) exception, the exception is
rethrown, and the current mapping is left unchanged.
key
- key with which the resulting value is to be associatedvalue
- the non-null value to be merged with the existing value
associated with the key or, if no existing value or a null value
is associated with the key, to be associated with the keyremappingFunction
- the function to recompute a value if presentjava.lang.UnsupportedOperationException
- if the put
operation
is not supported by this map
(optional)java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map
(optional)java.lang.NullPointerException
- if the specified map is null, or the specified key is null and this map
does not support null keys or the value or remappingFunction is
nullE extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> void forEach(java.util.Map<K,V> map, Try.BiConsumer<? super K,? super V,E> action) throws E extends java.lang.Exception
action
- The action to be performed for each entryjava.lang.NullPointerException
- if the specified action is nulljava.util.ConcurrentModificationException
- if an entry is found to be
removed during iterationE extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> java.util.Map<K,V> filter(java.util.Map<K,V> map, Try.BiPredicate<? super K,? super V,E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> java.util.Map<K,V> filterByKey(java.util.Map<K,V> map, Try.Predicate<? super K,E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <K,V,E extends java.lang.Exception> java.util.Map<K,V> filterByValue(java.util.Map<K,V> map, Try.Predicate<? super V,E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <K,V> java.util.Map<V,K> invert(java.util.Map<K,V> map)
map
- Multimap#invertFrom(Map, com.landawn.abacus.util.function.Supplier)
,
ListMultimap.invertFrom(Map)
,
ListMultimap.invertFrom(Map)
public static <K,V> java.util.Map<V,java.util.List<K>> flatInvert(java.util.Map<K,? extends java.util.Collection<? extends V>> map)
map
- Multimap#flatInvertFrom(Map, com.landawn.abacus.util.function.Supplier)
,
ListMultimap.flatInvertFrom(Map)
,
SetMultimap.flatInvertFrom(Map)
public static <T> T map2Entity(java.lang.Class<T> targetClass, java.util.Map<java.lang.String,java.lang.Object> m)
public static <T> T map2Entity(java.lang.Class<T> targetClass, java.util.Map<java.lang.String,java.lang.Object> m, boolean ignoreNullProperty, boolean ignoreUnknownProperty)
public static <T> T map2Entity(java.lang.Class<T> targetClass, java.util.Map<java.lang.String,java.lang.Object> m, java.util.Collection<java.lang.String> selectPropNames)
public static <T> java.util.List<T> map2Entity(java.lang.Class<T> targetClass, java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> mList)
public static <T> java.util.List<T> map2Entity(java.lang.Class<T> targetClass, java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> mList, boolean igoreNullProperty, boolean ignoreUnknownProperty)
public static <T> java.util.List<T> map2Entity(java.lang.Class<T> targetClass, java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> mList, java.util.Collection<java.lang.String> selectPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> entity2Map(java.lang.Object entity)
public static java.util.Map<java.lang.String,java.lang.Object> entity2Map(java.lang.Object entity, boolean ignoreNullProperty)
public static java.util.Map<java.lang.String,java.lang.Object> entity2Map(java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> entity2Map(java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> entity2Map(java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2Map(java.lang.Object entity, Supplier<? extends M> mapSupplier)
resultMap
- entity
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2Map(M resultMap, java.lang.Object entity)
resultMap
- entity
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2Map(M resultMap, java.lang.Object entity, boolean ignoreNullProperty)
resultMap
- entity
- ignoreNullProperty
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2Map(M resultMap, java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoredPropNames
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2Map(M resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2Map(M resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- keyNamingPolicy
- resultMap
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2Map(java.util.Collection<?> entityList)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2Map(java.util.Collection<?> entityList, boolean ignoreNullProperty)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2Map(java.util.Collection<?> entityList, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2Map(java.util.Collection<?> entityList, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2Map(java.util.Collection<?> entityList, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
public static java.util.Map<java.lang.String,java.lang.Object> deepEntity2Map(java.lang.Object entity)
public static java.util.Map<java.lang.String,java.lang.Object> deepEntity2Map(java.lang.Object entity, boolean ignoreNullProperty)
public static java.util.Map<java.lang.String,java.lang.Object> deepEntity2Map(java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> deepEntity2Map(java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> deepEntity2Map(java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M deepEntity2Map(java.lang.Object entity, Supplier<? extends M> mapSupplier)
resultMap
- entity
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M deepEntity2Map(M resultMap, java.lang.Object entity)
resultMap
- entity
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M deepEntity2Map(M resultMap, java.lang.Object entity, boolean ignoreNullProperty)
resultMap
- entity
- ignoreNullProperty
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M deepEntity2Map(M resultMap, java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoredPropNames
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M deepEntity2Map(M resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M deepEntity2Map(M resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- keyNamingPolicy
- resultMap
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> deepEntity2Map(java.util.Collection<?> entityList)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> deepEntity2Map(java.util.Collection<?> entityList, boolean ignoreNullProperty)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> deepEntity2Map(java.util.Collection<?> entityList, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> deepEntity2Map(java.util.Collection<?> entityList, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> deepEntity2Map(java.util.Collection<?> entityList, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
public static java.util.Map<java.lang.String,java.lang.Object> entity2FlatMap(java.lang.Object entity)
public static java.util.Map<java.lang.String,java.lang.Object> entity2FlatMap(java.lang.Object entity, boolean ignoreNullProperty)
public static java.util.Map<java.lang.String,java.lang.Object> entity2FlatMap(java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> entity2FlatMap(java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.Map<java.lang.String,java.lang.Object> entity2FlatMap(java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2FlatMap(java.lang.Object entity, Supplier<? extends M> mapSupplier)
resultMap
- entity
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2FlatMap(M resultMap, java.lang.Object entity)
resultMap
- entity
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2FlatMap(M resultMap, java.lang.Object entity, boolean ignoreNullProperty)
resultMap
- entity
- ignoreNullProperty
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2FlatMap(M resultMap, java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoredPropNames
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2FlatMap(M resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- resultMap
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M entity2FlatMap(M resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- keyNamingPolicy
- resultMap
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2FlatMap(java.util.Collection<?> entityList)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2FlatMap(java.util.Collection<?> entityList, boolean ignoreNullProperty)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2FlatMap(java.util.Collection<?> entityList, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2FlatMap(java.util.Collection<?> entityList, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> entity2FlatMap(java.util.Collection<?> entityList, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames, NamingPolicy keyNamingPolicy)
public static java.util.Map<java.lang.String,java.lang.Object> flatten(java.util.Map<java.lang.String,java.lang.Object> map)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M flatten(java.util.Map<java.lang.String,java.lang.Object> map, Supplier<M> mapSupplier)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M flatten(java.util.Map<java.lang.String,java.lang.Object> map, java.lang.String delimiter, Supplier<M> mapSupplier)
public static java.util.Map<java.lang.String,java.lang.Object> unflatten(java.util.Map<java.lang.String,java.lang.Object> map)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M unflatten(java.util.Map<java.lang.String,java.lang.Object> map, Supplier<M> mapSupplier)
public static <M extends java.util.Map<java.lang.String,java.lang.Object>> M unflatten(java.util.Map<java.lang.String,java.lang.Object> map, java.lang.String delimiter, Supplier<M> mapSupplier)