public final class Maps
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <K,V> V |
compute(java.util.Map<K,V> map,
K key,
BiFunction<? super K,? super V,? extends V> 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> V |
computeIfAbsent(java.util.Map<K,V> map,
K key,
Function<? super K,? extends V> 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> V |
computeIfPresent(java.util.Map<K,V> map,
K key,
BiFunction<? super K,? super V,? extends V> 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 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 <T extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(T resultMap,
java.lang.Object entity) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
deepEntity2Map(T resultMap,
java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <K,V> java.util.Map<K,V> |
diff(java.util.Map<K,V> map,
java.util.Map<? extends K,? extends V> map2) |
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 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 <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(T resultMap,
java.lang.Object entity) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2FlatMap(T resultMap,
java.lang.Object entity,
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) |
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 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 <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(T resultMap,
java.lang.Object entity) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(T resultMap,
java.lang.Object entity,
boolean ignoreNullProperty,
java.util.Collection<java.lang.String> ignoredPropNames,
NamingPolicy keyNamingPolicy) |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
entity2Map(T resultMap,
java.lang.Object entity,
java.util.Collection<java.lang.String> ignoredPropNames) |
static <K,V> java.util.Map<K,V> |
filter(java.util.Map<K,V> map,
BiPredicate<? super K,? super V> predicate) |
static <K,V> java.util.Map<K,V> |
filterByKey(java.util.Map<K,V> map,
Predicate<? super K> predicate) |
static <K,V> java.util.Map<K,V> |
filterByValue(java.util.Map<K,V> map,
Predicate<? super V> predicate) |
static <K,V> void |
forEach(java.util.Map<K,V> map,
BiConsumer<? super K,? super V> 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,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,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,java.util.List<K>> |
inverse(java.util.Map<K,? extends java.util.Collection<V>> map) |
static <K,V> java.util.Map<V,K> |
invert(java.util.Map<K,V> map) |
static java.lang.String |
join(java.util.Map<?,?> m) |
static java.lang.String |
join(java.util.Map<?,?> m,
char entryDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
char entryDelimiter,
char keyValueDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
char entryDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
char entryDelimiter,
boolean trim) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
char entryDelimiter,
char keyValueDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
char entryDelimiter,
char keyValueDelimiter,
boolean trim) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
java.lang.String entryDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
java.lang.String entryDelimiter,
boolean trim) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
java.lang.String entryDelimiter,
java.lang.String keyValueDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
int fromIndex,
int toIndex,
java.lang.String entryDelimiter,
java.lang.String keyValueDelimiter,
boolean trim) |
static java.lang.String |
join(java.util.Map<?,?> m,
java.lang.String entryDelimiter) |
static java.lang.String |
join(java.util.Map<?,?> m,
java.lang.String entryDelimiter,
java.lang.String keyValueDelimiter) |
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> 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 <K,V> V |
merge(java.util.Map<K,V> map,
K key,
V value,
BiFunction<? super V,? super V,? extends V> 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 <K,T> java.util.Map<K,T> |
newLinkedHashMap(java.util.Collection<? extends T> c,
Function<? super T,? extends K> keyExtractor) |
static <K,T> java.util.Map<K,T> |
newMap(java.util.Collection<? extends T> c,
Function<? super T,? extends K> keyExtractor) |
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) |
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 |
removeAll(java.util.Map<?,?> map,
java.util.Collection<?> keys) |
static boolean |
removeAll(java.util.Map<?,?> map,
java.util.Map<?,?> entriesToRemove)
The the entries from the specified
Map |
static <K,V> V |
replace(java.util.Map<K,V> map,
K key,
V value)
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> void |
replaceAll(java.util.Map<K,V> map,
BiFunction<? super K,? super V,? extends V> 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) |
public static <K,T> java.util.Map<K,T> newMap(java.util.Collection<? extends T> c, Function<? super T,? extends K> keyExtractor)
public static <K,T> java.util.Map<K,T> newLinkedHashMap(java.util.Collection<? extends T> c, Function<? super T,? extends K> keyExtractor)
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.key
- the key whose associated value is to be returneddefaultValue
- the default mapping of the keydefaultValue
if this map contains no mapping for the keyjava.lang.ClassCastException
- if the key is of an inappropriate type for
this map
(optional)java.lang.NullPointerException
- if the specified key is null and this map
does not permit null keys
(optional)public static <K,V> java.util.List<V> getOrDefaultForEach(java.util.Map<K,V> map, java.util.Collection<?> keys, V defaultValue)
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,V> diff(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> boolean remove(java.util.Map<K,V> map, java.util.Map.Entry<?,?> 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 removeAll(java.util.Map<?,?> map, java.util.Collection<?> keys)
map
- keys
- true
if any key/value was removed, otherwise false
.public static boolean removeAll(java.util.Map<?,?> map, java.util.Map<?,?> entriesToRemove)
Map
map
- entriesToRemove
- true
if any key/value was removed, otherwise false
.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 value)
key
- key with which the specified value is 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 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> void replaceAll(java.util.Map<K,V> map, BiFunction<? super K,? super V,? extends V> function)
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 iterationpublic static <K,V> V computeIfAbsent(java.util.Map<K,V> map, K key, Function<? super K,? extends V> mappingFunction)
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)public static <K,V> V computeIfPresent(java.util.Map<K,V> map, K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
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)public static <K,V> V compute(java.util.Map<K,V> map, K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
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)public static <K,V> V merge(java.util.Map<K,V> map, K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
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
nullpublic static <K,V> void forEach(java.util.Map<K,V> map, BiConsumer<? super K,? super V> action)
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 iterationpublic static <K,V> java.util.Map<K,V> filterByKey(java.util.Map<K,V> map, Predicate<? super K> predicate)
public static <K,V> java.util.Map<K,V> filterByValue(java.util.Map<K,V> map, Predicate<? super V> predicate)
public static <K,V> java.util.Map<K,V> filter(java.util.Map<K,V> map, BiPredicate<? super K,? super V> predicate)
public static <K,V> java.util.Map<V,K> invert(java.util.Map<K,V> map)
public static <K,V> java.util.Map<V,java.util.List<K>> inverse(java.util.Map<K,? extends java.util.Collection<V>> 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> 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 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 <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2Map(T resultMap, java.lang.Object entity)
resultMap
- entity
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2Map(T resultMap, java.lang.Object entity, boolean ignoreNullProperty)
resultMap
- entity
- ignoreNullProperty
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2Map(T resultMap, java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoredPropNames
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2Map(T resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2Map(T 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 <T extends java.util.Map<java.lang.String,java.lang.Object>> T deepEntity2Map(T resultMap, java.lang.Object entity)
resultMap
- entity
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T deepEntity2Map(T resultMap, java.lang.Object entity, boolean ignoreNullProperty)
resultMap
- entity
- ignoreNullProperty
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T deepEntity2Map(T resultMap, java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoredPropNames
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T deepEntity2Map(T resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T deepEntity2Map(T 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 <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2FlatMap(T resultMap, java.lang.Object entity)
resultMap
- entity
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2FlatMap(T resultMap, java.lang.Object entity, boolean ignoreNullProperty)
resultMap
- entity
- ignoreNullProperty
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2FlatMap(T resultMap, java.lang.Object entity, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoredPropNames
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2FlatMap(T resultMap, java.lang.Object entity, boolean ignoreNullProperty, java.util.Collection<java.lang.String> ignoredPropNames)
resultMap
- entity
- ignoreNullProperty
- ignoredPropNames
- resultMap
public static <T extends java.util.Map<java.lang.String,java.lang.Object>> T entity2FlatMap(T 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.lang.String join(java.util.Map<?,?> m)
public static java.lang.String join(java.util.Map<?,?> m, char entryDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, java.lang.String entryDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, char entryDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, char entryDelimiter, boolean trim)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, java.lang.String entryDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, java.lang.String entryDelimiter, boolean trim)
public static java.lang.String join(java.util.Map<?,?> m, char entryDelimiter, char keyValueDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, java.lang.String entryDelimiter, java.lang.String keyValueDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, char entryDelimiter, char keyValueDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, char entryDelimiter, char keyValueDelimiter, boolean trim)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, java.lang.String entryDelimiter, java.lang.String keyValueDelimiter)
public static java.lang.String join(java.util.Map<?,?> m, int fromIndex, int toIndex, java.lang.String entryDelimiter, java.lang.String keyValueDelimiter, boolean trim)