public final class Maps extends Object
Note: This class includes codes copied from Apache Commons Lang, Google Guava and other open source projects under the Apache License 2.0. The methods copied from other libraries/frameworks/projects may be modified in this class.
N,
Iterables,
Iterators,
StringUtil| Modifier and Type | Method and Description |
|---|---|
static boolean |
contains(Map<?,?> map,
Map.Entry<?,?> entry)
Check if the specified
Map contains the specified Entry. |
static boolean |
contains(Map<?,?> map,
Object key,
Object value) |
static List<Map<String,Object>> |
deepEntity2Map(Collection<?> entityList)
Deep entity to map.
|
static List<Map<String,Object>> |
deepEntity2Map(Collection<?> entityList,
boolean ignoreNullProperty)
Deep entity to map.
|
static List<Map<String,Object>> |
deepEntity2Map(Collection<?> entityList,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Deep entity to map.
|
static List<Map<String,Object>> |
deepEntity2Map(Collection<?> entityList,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Deep entity to map.
|
static List<Map<String,Object>> |
deepEntity2Map(Collection<?> entityList,
Collection<String> ignoredPropNames)
Deep entity to map.
|
static <M extends Map<String,Object>> |
deepEntity2Map(M resultMap,
Object entity)
Deep entity to map.
|
static <M extends Map<String,Object>> |
deepEntity2Map(M resultMap,
Object entity,
boolean ignoreNullProperty)
Deep entity to map.
|
static <M extends Map<String,Object>> |
deepEntity2Map(M resultMap,
Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Deep entity to map.
|
static <M extends Map<String,Object>> |
deepEntity2Map(M resultMap,
Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Deep entity to map.
|
static <M extends Map<String,Object>> |
deepEntity2Map(M resultMap,
Object entity,
Collection<String> ignoredPropNames)
Deep entity to map.
|
static Map<String,Object> |
deepEntity2Map(Object entity)
Deep entity to map.
|
static Map<String,Object> |
deepEntity2Map(Object entity,
boolean ignoreNullProperty)
Deep entity to map.
|
static Map<String,Object> |
deepEntity2Map(Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Deep entity to map.
|
static Map<String,Object> |
deepEntity2Map(Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Deep entity to map.
|
static Map<String,Object> |
deepEntity2Map(Object entity,
Collection<String> ignoredPropNames)
Deep entity to map.
|
static <M extends Map<String,Object>> |
deepEntity2Map(Object entity,
Supplier<? extends M> mapSupplier)
Deep entity to map.
|
static <K,V> Map<K,Pair<V,u.Nullable<V>>> |
difference(Map<K,V> map,
Map<K,V> map2) |
static List<Map<String,Object>> |
entity2FlatMap(Collection<?> entityList)
Entity 2 flat map.
|
static List<Map<String,Object>> |
entity2FlatMap(Collection<?> entityList,
boolean ignoreNullProperty)
Entity 2 flat map.
|
static List<Map<String,Object>> |
entity2FlatMap(Collection<?> entityList,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Entity 2 flat map.
|
static List<Map<String,Object>> |
entity2FlatMap(Collection<?> entityList,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Entity 2 flat map.
|
static List<Map<String,Object>> |
entity2FlatMap(Collection<?> entityList,
Collection<String> ignoredPropNames)
Entity 2 flat map.
|
static <M extends Map<String,Object>> |
entity2FlatMap(M resultMap,
Object entity)
Entity 2 flat map.
|
static <M extends Map<String,Object>> |
entity2FlatMap(M resultMap,
Object entity,
boolean ignoreNullProperty)
Entity 2 flat map.
|
static <M extends Map<String,Object>> |
entity2FlatMap(M resultMap,
Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Entity 2 flat map.
|
static <M extends Map<String,Object>> |
entity2FlatMap(M resultMap,
Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Entity 2 flat map.
|
static <M extends Map<String,Object>> |
entity2FlatMap(M resultMap,
Object entity,
Collection<String> ignoredPropNames)
Entity 2 flat map.
|
static Map<String,Object> |
entity2FlatMap(Object entity)
Entity 2 flat map.
|
static Map<String,Object> |
entity2FlatMap(Object entity,
boolean ignoreNullProperty)
Entity 2 flat map.
|
static Map<String,Object> |
entity2FlatMap(Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Entity 2 flat map.
|
static Map<String,Object> |
entity2FlatMap(Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Entity 2 flat map.
|
static Map<String,Object> |
entity2FlatMap(Object entity,
Collection<String> ignoredPropNames)
Entity 2 flat map.
|
static <M extends Map<String,Object>> |
entity2FlatMap(Object entity,
Supplier<? extends M> mapSupplier)
Entity 2 flat map.
|
static List<Map<String,Object>> |
entity2Map(Collection<?> entityList)
Entity to map.
|
static List<Map<String,Object>> |
entity2Map(Collection<?> entityList,
boolean ignoreNullProperty)
Entity to map.
|
static List<Map<String,Object>> |
entity2Map(Collection<?> entityList,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Entity to map.
|
static List<Map<String,Object>> |
entity2Map(Collection<?> entityList,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Entity to map.
|
static List<Map<String,Object>> |
entity2Map(Collection<?> entityList,
Collection<String> ignoredPropNames)
Entity to map.
|
static <M extends Map<String,Object>> |
entity2Map(M resultMap,
Object entity)
Entity to map.
|
static <M extends Map<String,Object>> |
entity2Map(M resultMap,
Object entity,
boolean ignoreNullProperty)
Entity to map.
|
static <M extends Map<String,Object>> |
entity2Map(M resultMap,
Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Entity to map.
|
static <M extends Map<String,Object>> |
entity2Map(M resultMap,
Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Entity to map.
|
static <M extends Map<String,Object>> |
entity2Map(M resultMap,
Object entity,
Collection<String> ignoredPropNames)
Entity to map.
|
static Map<String,Object> |
entity2Map(Object entity)
Entity to map.
|
static Map<String,Object> |
entity2Map(Object entity,
boolean ignoreNullProperty)
Entity to map.
|
static Map<String,Object> |
entity2Map(Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames)
Entity to map.
|
static Map<String,Object> |
entity2Map(Object entity,
boolean ignoreNullProperty,
Collection<String> ignoredPropNames,
NamingPolicy keyNamingPolicy)
Entity to map.
|
static Map<String,Object> |
entity2Map(Object entity,
Collection<String> ignoredPropNames)
Entity to map.
|
static <M extends Map<String,Object>> |
entity2Map(Object entity,
Supplier<? extends M> mapSupplier)
Entity to map.
|
static <K,V,E extends Exception> |
filter(Map<K,V> map,
Throwables.BiPredicate<? super K,? super V,E> predicate) |
static <K,V,E extends Exception> |
filterByKey(Map<K,V> map,
Throwables.Predicate<? super K,E> predicate)
Filter by key.
|
static <K,V,E extends Exception> |
filterByValue(Map<K,V> map,
Throwables.Predicate<? super V,E> predicate)
Filter by value.
|
static <K,V> Map<V,List<K>> |
flatInvert(Map<K,? extends Collection<? extends V>> map) |
static Map<String,Object> |
flatten(Map<String,Object> map) |
static <M extends Map<String,Object>> |
flatten(Map<String,Object> map,
String delimiter,
Supplier<? extends M> mapSupplier) |
static <M extends Map<String,Object>> |
flatten(Map<String,Object> map,
Supplier<? extends M> mapSupplier) |
static <K,V> List<Map<K,V>> |
flatToMap(Map<K,? extends Collection<? extends V>> map)
{a=[1, 2, 3], b=[4, 5, 6], c=[7, 8]} -> [{a=1, b=4, c=7}, {a=2, b=5, c=8}, {a=3, b=6}]
|
static <K,V,E extends Exception> |
forEach(Map<K,V> map,
Throwables.BiConsumer<? super K,? super V,E> action) |
static <K,V,E extends Exception> |
forEach(Map<K,V> map,
Throwables.Consumer<? super Map.Entry<K,V>,E> action) |
static <K,T> u.Optional<T> |
get(Map<? super K,?> map,
K key,
Class<? extends T> targetType)
Returns an empty
Optional<String> if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K,T> T |
get(Map<? super K,?> map,
K key,
T defaultForNull)
Returns the mapped
T or a T converted from N.valueOf((Class<T>) defaultForNull.getClass(), N.stringOf(val)). |
static <K,V> u.Nullable<V> |
get(Map<K,? extends V> map,
K key) |
static <K,E> Set<E> |
getAndPutLinkedHashSetIfAbsent(Map<K,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> List<E> |
getAndPutListIfAbsent(Map<K,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> Map<KK,VV> |
getAndPutMapIfAbsent(Map<K,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> Set<E> |
getAndPutSetIfAbsent(Map<K,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> u.OptionalBoolean |
getBoolean(Map<? super K,?> map,
K key)
Returns an empty
OptionalBoolean if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> boolean |
getBoolean(Map<? super K,?> map,
K key,
boolean defaultForNull)
Returns the mapped
boolean or a boolean converted from String. |
static <K> u.OptionalByte |
getByte(Map<? super K,?> map,
K key)
Returns an empty
OptionalByte if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> byte |
getByte(Map<? super K,?> map,
K key,
byte defaultForNull)
Returns the mapped
byte or a byte converted from String. |
static <K> u.OptionalChar |
getChar(Map<? super K,?> map,
K key)
Returns an empty
OptionalChar if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> char |
getChar(Map<? super K,?> map,
K key,
char defaultForNull)
Returns the mapped
char or a char converted from String. |
static <K> u.OptionalDouble |
getDouble(Map<? super K,?> map,
K key)
Returns an empty
OptionalDouble if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> double |
getDouble(Map<? super K,?> map,
K key,
double defaultForNull)
Returns the mapped
double or a double converted from String. |
static <K> u.OptionalFloat |
getFloat(Map<? super K,?> map,
K key)
Returns an empty
OptionalFloat if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> float |
getFloat(Map<? super K,?> map,
K key,
float defaultForNull)
Returns the mapped
float or a float converted from String. |
static <K,V> List<V> |
getIfPresentForEach(Map<K,? extends V> map,
Collection<?> keys)
Returns a list of values of the keys which exist in the specified
Map. |
static <K> u.OptionalInt |
getInt(Map<? super K,?> map,
K key)
Returns an empty
OptionalInt if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> int |
getInt(Map<? super K,?> map,
K key,
int defaultForNull)
Returns the mapped
integer or an integer converted from String. |
static <K> u.OptionalLong |
getLong(Map<? super K,?> map,
K key)
Returns an empty
OptionalLong if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> long |
getLong(Map<? super K,?> map,
K key,
long defaultForNull)
Returns the mapped
long or a long converted from String. |
static <K,V> V |
getOrDefault(Map<K,? extends V> map,
K 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> List<V> |
getOrDefaultForEach(Map<K,V> map,
Collection<?> keys,
V defaultValue)
Gets the or default for each.
|
static <K,V> V |
getOrDefaultIfNull(Map<K,? extends V> map,
K key,
V defaultForNull)
Returns the value to which the specified key is mapped if it's not
null,
or defaultForNull if this map contains no mapping for the key or it's null. |
static <K,V> List<V> |
getOrDefaultIfNullForEach(Map<K,V> map,
Collection<?> keys,
V defaultValue) |
static <K,E,V extends List<E>> |
getOrEmptyList(Map<K,V> map,
K 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 Set<E>> |
getOrEmptySet(Map<K,V> map,
K 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> u.OptionalShort |
getShort(Map<? super K,?> map,
K key)
Returns an empty
OptionalShort if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> short |
getShort(Map<? super K,?> map,
K key,
short defaultForNull)
Returns the mapped
short or a short converted from String. |
static <K> u.Optional<String> |
getString(Map<? super K,?> map,
K key)
Returns an empty
Optional<String> if the specified map is empty, or no value found by the specified key, or the value is null. |
static <K> String |
getString(Map<? super K,?> map,
K key,
String defaultForNull)
Returns the mapped
String or a String converted from N.toString(value). |
static <K,V> Map<K,V> |
intersection(Map<K,V> map,
Map<? extends K,? extends V> map2) |
static <K,V> Map<V,K> |
invert(Map<K,V> map) |
static <K,V,E extends Exception> |
invert(Map<K,V> map,
Throwables.BinaryOperator<K,E> mergeOp) |
static <T> List<T> |
map2Entity(Class<T> targetClass,
Collection<Map<String,Object>> mList)
Map to entity.
|
static <T> List<T> |
map2Entity(Class<T> targetClass,
Collection<Map<String,Object>> mList,
boolean igoreNullProperty,
boolean ignoreUnmatchedProperty)
Map to entity.
|
static <T> List<T> |
map2Entity(Class<T> targetClass,
Collection<Map<String,Object>> mList,
Collection<String> selectPropNames)
Map to entity.
|
static <T> T |
map2Entity(Class<T> targetClass,
Map<String,Object> m)
Map to entity.
|
static <T> T |
map2Entity(Class<T> targetClass,
Map<String,Object> m,
boolean ignoreNullProperty,
boolean ignoreUnmatchedProperty)
Map to entity.
|
static <T> T |
map2Entity(Class<T> targetClass,
Map<String,Object> m,
Collection<String> selectPropNames)
Map to entity.
|
static <K,V> Map.Entry<K,V> |
newEntry(K key,
V value)
Deprecated.
replaced by
CommonUtil.newEntry(Object, Object) |
static <K,V> ImmutableEntry<K,V> |
newImmutableEntry(K key,
V value)
Deprecated.
replaced by
CommonUtil.newImmutableEntry(Object, Object) |
static <T,K,E extends Exception> |
newMap(Collection<? extends T> c,
Throwables.Function<? super T,? extends K,E> keyMapper) |
static <T,K,V,E extends Exception,E2 extends Exception> |
newMap(Collection<? extends T> c,
Throwables.Function<? super T,? extends K,E> keyMapper,
Throwables.Function<? super T,? extends V,E2> valueExtractor) |
static <T,K,V,M extends Map<K,V>,E extends Exception,E2 extends Exception> |
newMap(Collection<? extends T> c,
Throwables.Function<? super T,? extends K,E> keyMapper,
Throwables.Function<? super T,? extends V,E2> valueExtractor,
IntFunction<? extends M> mapSupplier) |
static <T,K,E extends Exception> |
newMap(Iterator<? extends T> iter,
Throwables.Function<? super T,K,E> keyMapper) |
static <T,K,V,E extends Exception,E2 extends Exception> |
newMap(Iterator<? extends T> iter,
Throwables.Function<? super T,K,E> keyMapper,
Throwables.Function<? super T,? extends V,E2> valueExtractor) |
static <T,K,V,M extends Map<K,V>,E extends Exception,E2 extends Exception> |
newMap(Iterator<? extends T> iter,
Throwables.Function<? super T,K,E> keyMapper,
Throwables.Function<? super T,? extends V,E2> valueExtractor,
Supplier<? extends M> mapSupplier) |
static <K,V> V |
putIfAbsent(Map<K,V> map,
K key,
Supplier<V> supplier)
Put if absent.
|
static <K,V> V |
putIfAbsent(Map<K,V> map,
K key,
V value)
Put if absent.
|
static <K,V> boolean |
remove(Map<K,V> map,
Map.Entry<?,?> entry)
Removes the specified entry.
|
static <K,V> boolean |
remove(Map<K,V> map,
Object key,
Object value) |
static boolean |
removeEntries(Map<?,?> map,
Map<?,?> entriesToRemove)
The the entries from the specified
Map. |
static <K,V,E extends Exception> |
removeIf(Map<K,V> map,
Throwables.Predicate<? super Map.Entry<K,V>,E> filter)
Removes entries from the specified
map by the the specified filter. |
static <K,V,E extends Exception> |
removeIfKey(Map<K,V> map,
Throwables.Predicate<? super K,E> filter)
Removes entries from the specified
map by the the specified filter. |
static <K,V,E extends Exception> |
removeIfValue(Map<K,V> map,
Throwables.Predicate<? super V,E> filter)
Removes entries from the specified
map by the the specified filter. |
static boolean |
removeKeys(Map<?,?> map,
Collection<?> keysToRemove)
Removes the keys.
|
static <K,V> V |
replace(Map<K,V> map,
K key,
V newValue) |
static <K,V> boolean |
replace(Map<K,V> map,
K key,
V oldValue,
V newValue) |
static <K,V,E extends Exception> |
replaceAll(Map<K,V> map,
Throwables.BiFunction<? super K,? super V,? extends V,E> function) |
static <K,V> Map<K,Pair<u.Nullable<V>,u.Nullable<V>>> |
symmetricDifference(Map<K,V> map,
Map<K,V> map2) |
static Map<String,Object> |
unflatten(Map<String,Object> map) |
static <M extends Map<String,Object>> |
unflatten(Map<String,Object> map,
String delimiter,
Supplier<? extends M> mapSupplier) |
static <M extends Map<String,Object>> |
unflatten(Map<String,Object> map,
Supplier<? extends M> mapSupplier) |
static <K,V> Map<K,V> |
zip(Collection<? extends K> keys,
Collection<? extends V> values) |
static <K,V,M extends Map<K,V>> |
zip(Collection<? extends K> keys,
Collection<? extends V> values,
BinaryOperator<V> mergeFunction,
IntFunction<? extends M> mapSupplier) |
static <K,V,M extends Map<K,V>> |
zip(Collection<? extends K> keys,
Collection<? extends V> values,
IntFunction<? extends M> mapSupplier) |
public static <T,K,E extends Exception> Map<K,T> newMap(Collection<? extends T> c, Throwables.Function<? super T,? extends K,E> keyMapper) throws E extends Exception
T - K - the key typeE - c - keyMapper - E - the eE extends Exceptionpublic static <T,K,V,E extends Exception,E2 extends Exception> Map<K,V> newMap(Collection<? extends T> c, Throwables.Function<? super T,? extends K,E> keyMapper, Throwables.Function<? super T,? extends V,E2> valueExtractor) throws E extends Exception, E2 extends Exception
T - K - the key typeV - the value typeE - E2 - c - keyMapper - valueExtractor - E - the eE2 - the e2E extends Exceptionpublic static <T,K,V,M extends Map<K,V>,E extends Exception,E2 extends Exception> M newMap(Collection<? extends T> c, Throwables.Function<? super T,? extends K,E> keyMapper, Throwables.Function<? super T,? extends V,E2> valueExtractor, IntFunction<? extends M> mapSupplier) throws E extends Exception, E2 extends Exception
T - K - the key typeV - the value typeM - E - E2 - c - keyMapper - valueExtractor - mapSupplier - E - the eE2 - the e2E extends Exceptionpublic static <T,K,E extends Exception> Map<K,T> newMap(Iterator<? extends T> iter, Throwables.Function<? super T,K,E> keyMapper) throws E extends Exception
T - K - the key typeE - iter - keyMapper - E - the eE extends Exceptionpublic static <T,K,V,E extends Exception,E2 extends Exception> Map<K,V> newMap(Iterator<? extends T> iter, Throwables.Function<? super T,K,E> keyMapper, Throwables.Function<? super T,? extends V,E2> valueExtractor) throws E extends Exception, E2 extends Exception
T - K - the key typeV - the value typeE - E2 - iter - keyMapper - valueExtractor - E - the eE2 - the e2E extends Exceptionpublic static <T,K,V,M extends Map<K,V>,E extends Exception,E2 extends Exception> M newMap(Iterator<? extends T> iter, Throwables.Function<? super T,K,E> keyMapper, Throwables.Function<? super T,? extends V,E2> valueExtractor, Supplier<? extends M> mapSupplier) throws E extends Exception, E2 extends Exception
T - K - the key typeV - the value typeM - E - E2 - iter - keyMapper - valueExtractor - mapSupplier - E - the eE2 - the e2E extends Exception@Deprecated public static <K,V> Map.Entry<K,V> newEntry(K key, V value)
CommonUtil.newEntry(Object, Object)K - V - key - value - @Deprecated public static <K,V> ImmutableEntry<K,V> newImmutableEntry(K key, V value)
CommonUtil.newImmutableEntry(Object, Object)K - V - key - value - public static <K,V> Map<K,V> zip(Collection<? extends K> keys, Collection<? extends V> values)
public static <K,V,M extends Map<K,V>> Map<K,V> zip(Collection<? extends K> keys, Collection<? extends V> values, IntFunction<? extends M> mapSupplier)
public static <K,V,M extends Map<K,V>> Map<K,V> zip(Collection<? extends K> keys, Collection<? extends V> values, BinaryOperator<V> mergeFunction, IntFunction<? extends M> mapSupplier)
public static <K,V> u.Nullable<V> get(Map<K,? extends V> map, K key)
K - the key typeV - the value typemap - key - public static <K,V> V getOrDefault(Map<K,? extends V> map, K key, V defaultValue)
defaultValue if this map contains no mapping for the key.K - the key typeV - the value typemap - key - defaultValue - public static <K,V> V getOrDefaultIfNull(Map<K,? extends V> map, K key, V defaultForNull)
null,
or defaultForNull if this map contains no mapping for the key or it's null.K - V - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalBoolean getBoolean(Map<? super K,?> map, K key)
OptionalBoolean if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> boolean getBoolean(Map<? super K,?> map, K key, boolean defaultForNull)
boolean or a boolean converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalChar getChar(Map<? super K,?> map, K key)
OptionalChar if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> char getChar(Map<? super K,?> map, K key, char defaultForNull)
char or a char converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalByte getByte(Map<? super K,?> map, K key)
OptionalByte if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> byte getByte(Map<? super K,?> map, K key, byte defaultForNull)
byte or a byte converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalShort getShort(Map<? super K,?> map, K key)
OptionalShort if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> short getShort(Map<? super K,?> map, K key, short defaultForNull)
short or a short converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalInt getInt(Map<? super K,?> map, K key)
OptionalInt if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> int getInt(Map<? super K,?> map, K key, int defaultForNull)
integer or an integer converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalLong getLong(Map<? super K,?> map, K key)
OptionalLong if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> long getLong(Map<? super K,?> map, K key, long defaultForNull)
long or a long converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalFloat getFloat(Map<? super K,?> map, K key)
OptionalFloat if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> float getFloat(Map<? super K,?> map, K key, float defaultForNull)
float or a float converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.OptionalDouble getDouble(Map<? super K,?> map, K key)
OptionalDouble if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> double getDouble(Map<? super K,?> map, K key, double defaultForNull)
double or a double converted from String.
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K> u.Optional<String> getString(Map<? super K,?> map, K key)
Optional<String> if the specified map is empty, or no value found by the specified key, or the value is null.K - map - key - public static <K> String getString(Map<? super K,?> map, K key, String defaultForNull)
String or a String converted from N.toString(value).
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K,T> u.Optional<T> get(Map<? super K,?> map, K key, Class<? extends T> targetType)
Optional<String> if the specified map is empty, or no value found by the specified key, or the value is null.
Abacus, if there is a conversion behind when the source value is not assignable to the target type, put the targetType to last parameter of the method.
Otherwise, put the targetTpye to the first parameter of the method.K - T - map - key - targetType - public static <K,T> T get(Map<? super K,?> map, K key, T defaultForNull)
T or a T converted from N.valueOf((Class<T>) defaultForNull.getClass(), N.stringOf(val)).
defaultForNull is returned if the specified map doesn't contain the specified key or the mapped value is null.K - T - map - key - defaultForNull - to return if the specified map doesn't contain the specified key or the mapped value is null.public static <K,E,V extends List<E>> List<E> getOrEmptyList(Map<K,V> map, K key)
List if this map contains no mapping for the key.K - the key typeE - V - the value typemap - key - public static <K,E,V extends Set<E>> Set<E> getOrEmptySet(Map<K,V> map, K key)
Set if this map contains no mapping for the key.K - the key typeE - V - the value typemap - key - public static <K,E> List<E> getAndPutListIfAbsent(Map<K,List<E>> map, K key)
key if it exists in the specified map contains, or the new put List if it's absent.K - the key typeE - map - key - public static <K,E> Set<E> getAndPutSetIfAbsent(Map<K,Set<E>> map, K key)
key if it exists in the specified map contains, or the new put Set if it's absent.K - the key typeE - map - key - public static <K,E> Set<E> getAndPutLinkedHashSetIfAbsent(Map<K,Set<E>> map, K key)
key if it exists in the specified map contains, or the new put Set if it's absent.K - the key typeE - map - key - public static <K,KK,VV> Map<KK,VV> getAndPutMapIfAbsent(Map<K,Map<KK,VV>> map, K key)
key if it exists in the specified map contains, or the new put Map if it's absent.K - the key typeKK - VV - map - key - public static <K,V> List<V> getIfPresentForEach(Map<K,? extends V> map, Collection<?> keys)
Map.
If the key dosn't exist in the Map, No value will be added into the returned list.K - the key typeV - the value typemap - keys - public static <K,V> List<V> getOrDefaultForEach(Map<K,V> map, Collection<?> keys, V defaultValue)
K - the key typeV - the value typemap - keys - defaultValue - public static <K,V> List<V> getOrDefaultIfNullForEach(Map<K,V> map, Collection<?> keys, V defaultValue)
public static boolean contains(Map<?,?> map, Map.Entry<?,?> entry)
Map contains the specified Entry.map - entry - public static boolean contains(Map<?,?> map, Object key, Object value)
map - key - value - public static <K,V> Map<K,V> intersection(Map<K,V> map, Map<? extends K,? extends V> map2)
K - the key typeV - the value typemap - map2 - public static <K,V> Map<K,Pair<V,u.Nullable<V>>> difference(Map<K,V> map, Map<K,V> map2)
K - the key typeV - the value typemap - map2 - public static <K,V> Map<K,Pair<u.Nullable<V>,u.Nullable<V>>> symmetricDifference(Map<K,V> map, Map<K,V> map2)
K - the key typeV - the value typemap - map2 - public static <K,V> V putIfAbsent(Map<K,V> map, K key, V value)
K - the key typeV - the value typemap - key - value - public static <K,V> V putIfAbsent(Map<K,V> map, K key, Supplier<V> supplier)
K - the key typeV - the value typemap - key - supplier - public static <K,V> boolean remove(Map<K,V> map, Map.Entry<?,?> entry)
K - the key typeV - the value typemap - entry - public static <K,V> boolean remove(Map<K,V> map, Object key, Object value)
K - the key typeV - the value typemap - key - value - public static boolean removeKeys(Map<?,?> map, Collection<?> keysToRemove)
map - keysToRemove - true if any key/value was removed, otherwise false.public static boolean removeEntries(Map<?,?> map, Map<?,?> entriesToRemove)
Map.map - entriesToRemove - true if any key/value was removed, otherwise false.public static <K,V,E extends Exception> boolean removeIf(Map<K,V> map, Throwables.Predicate<? super Map.Entry<K,V>,E> filter) throws E extends Exception
map by the the specified filter.K - the key typeV - the value typeE - map - filter - true if there are one or more than one entries removed from the specified map.E - the eE extends Exceptionpublic static <K,V,E extends Exception> boolean removeIfKey(Map<K,V> map, Throwables.Predicate<? super K,E> filter) throws E extends Exception
map by the the specified filter.K - the key typeV - the value typeE - map - filter - true if there are one or more than one entries removed from the specified map.E - the eE extends Exceptionpublic static <K,V,E extends Exception> boolean removeIfValue(Map<K,V> map, Throwables.Predicate<? super V,E> filter) throws E extends Exception
map by the the specified filter.K - the key typeV - the value typeE - map - filter - true if there are one or more than one entries removed from the specified map.E - the eE extends Exceptionpublic static <K,V> boolean replace(Map<K,V> map, K key, V oldValue, V newValue)
K - the key typeV - the value typemap - key - oldValue - newValue - public static <K,V> V replace(Map<K,V> map, K key, V newValue)
K - the key typeV - the value typemap - key - newValue - public static <K,V,E extends Exception> void replaceAll(Map<K,V> map, Throwables.BiFunction<? super K,? super V,? extends V,E> function) throws E extends Exception
K - the key typeV - the value typeE - map - function - E - the eE extends Exceptionpublic static <K,V,E extends Exception> void forEach(Map<K,V> map, Throwables.Consumer<? super Map.Entry<K,V>,E> action) throws E extends Exception
E extends Exceptionpublic static <K,V,E extends Exception> void forEach(Map<K,V> map, Throwables.BiConsumer<? super K,? super V,E> action) throws E extends Exception
K - the key typeV - the value typeE - map - action - E - the eE extends Exceptionpublic static <K,V,E extends Exception> Map<K,V> filter(Map<K,V> map, Throwables.BiPredicate<? super K,? super V,E> predicate) throws E extends Exception
K - the key typeV - the value typeE - map - predicate - E - the eE extends Exceptionpublic static <K,V,E extends Exception> Map<K,V> filterByKey(Map<K,V> map, Throwables.Predicate<? super K,E> predicate) throws E extends Exception
K - the key typeV - the value typeE - map - predicate - E - the eE extends Exceptionpublic static <K,V,E extends Exception> Map<K,V> filterByValue(Map<K,V> map, Throwables.Predicate<? super V,E> predicate) throws E extends Exception
K - the key typeV - the value typeE - map - predicate - E - the eE extends Exceptionpublic static <K,V> Map<V,K> invert(Map<K,V> map)
K - the key typeV - the value typemap - Multimap#invertFrom(Map, com.landawn.abacus.util.function.Supplier),
ListMultimap.invertFrom(Map),
ListMultimap.invertFrom(Map)public static <K,V,E extends Exception> Map<V,K> invert(Map<K,V> map, Throwables.BinaryOperator<K,E> mergeOp) throws E extends Exception
K - the key typeV - the value typeE - map - mergeOp - E - the eE extends Exceptionpublic static <K,V> Map<V,List<K>> flatInvert(Map<K,? extends Collection<? extends V>> map)
K - the key typeV - the value typemap - Multimap#flatInvertFrom(Map, com.landawn.abacus.util.function.Supplier),
ListMultimap.flatInvertFrom(Map),
SetMultimap.flatInvertFrom(Map)public static <K,V> List<Map<K,V>> flatToMap(Map<K,? extends Collection<? extends V>> map)
K - V - map - public static <M extends Map<String,Object>> M flatten(Map<String,Object> map, Supplier<? extends M> mapSupplier)
M - map - mapSupplier - public static <M extends Map<String,Object>> M flatten(Map<String,Object> map, String delimiter, Supplier<? extends M> mapSupplier)
M - map - delimiter - mapSupplier - public static Map<String,Object> unflatten(Map<String,Object> map)
map - public static <M extends Map<String,Object>> M unflatten(Map<String,Object> map, Supplier<? extends M> mapSupplier)
M - map - mapSupplier - public static <M extends Map<String,Object>> M unflatten(Map<String,Object> map, String delimiter, Supplier<? extends M> mapSupplier)
M - map - delimiter - mapSupplier - public static <T> T map2Entity(Class<T> targetClass, Map<String,Object> m)
T - targetClass - m - public static <T> T map2Entity(Class<T> targetClass, Map<String,Object> m, boolean ignoreNullProperty, boolean ignoreUnmatchedProperty)
T - targetClass - m - ignoreNullProperty - ignoreUnmatchedProperty - public static <T> T map2Entity(Class<T> targetClass, Map<String,Object> m, Collection<String> selectPropNames)
T - targetClass - m - selectPropNames - public static <T> List<T> map2Entity(Class<T> targetClass, Collection<Map<String,Object>> mList)
T - targetClass - mList - public static <T> List<T> map2Entity(Class<T> targetClass, Collection<Map<String,Object>> mList, boolean igoreNullProperty, boolean ignoreUnmatchedProperty)
T - targetClass - mList - igoreNullProperty - ignoreUnmatchedProperty - public static <T> List<T> map2Entity(Class<T> targetClass, Collection<Map<String,Object>> mList, Collection<String> selectPropNames)
T - targetClass - mList - selectPropNames - public static Map<String,Object> entity2Map(Object entity)
entity - public static Map<String,Object> entity2Map(Object entity, boolean ignoreNullProperty)
entity - ignoreNullProperty - public static Map<String,Object> entity2Map(Object entity, Collection<String> ignoredPropNames)
entity - ignoredPropNames - public static Map<String,Object> entity2Map(Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
entity - ignoreNullProperty - ignoredPropNames - public static Map<String,Object> entity2Map(Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
entity - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static <M extends Map<String,Object>> M entity2Map(Object entity, Supplier<? extends M> mapSupplier)
M - entity - mapSupplier - public static <M extends Map<String,Object>> M entity2Map(M resultMap, Object entity)
M - resultMap - entity - public static <M extends Map<String,Object>> M entity2Map(M resultMap, Object entity, boolean ignoreNullProperty)
M - resultMap - entity - ignoreNullProperty - public static <M extends Map<String,Object>> M entity2Map(M resultMap, Object entity, Collection<String> ignoredPropNames)
M - resultMap - entity - ignoredPropNames - public static <M extends Map<String,Object>> M entity2Map(M resultMap, Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
M - resultMap - entity - ignoreNullProperty - ignoredPropNames - public static <M extends Map<String,Object>> M entity2Map(M resultMap, Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
M - resultMap - entity - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static List<Map<String,Object>> entity2Map(Collection<?> entityList)
entityList - public static List<Map<String,Object>> entity2Map(Collection<?> entityList, boolean ignoreNullProperty)
entityList - ignoreNullProperty - public static List<Map<String,Object>> entity2Map(Collection<?> entityList, Collection<String> ignoredPropNames)
entityList - ignoredPropNames - public static List<Map<String,Object>> entity2Map(Collection<?> entityList, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
entityList - ignoreNullProperty - ignoredPropNames - public static List<Map<String,Object>> entity2Map(Collection<?> entityList, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
entityList - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static Map<String,Object> deepEntity2Map(Object entity)
entity - public static Map<String,Object> deepEntity2Map(Object entity, boolean ignoreNullProperty)
entity - ignoreNullProperty - public static Map<String,Object> deepEntity2Map(Object entity, Collection<String> ignoredPropNames)
entity - ignoredPropNames - public static Map<String,Object> deepEntity2Map(Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
entity - ignoreNullProperty - ignoredPropNames - public static Map<String,Object> deepEntity2Map(Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
entity - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static <M extends Map<String,Object>> M deepEntity2Map(Object entity, Supplier<? extends M> mapSupplier)
M - entity - mapSupplier - public static <M extends Map<String,Object>> M deepEntity2Map(M resultMap, Object entity)
M - resultMap - entity - public static <M extends Map<String,Object>> M deepEntity2Map(M resultMap, Object entity, boolean ignoreNullProperty)
M - resultMap - entity - ignoreNullProperty - public static <M extends Map<String,Object>> M deepEntity2Map(M resultMap, Object entity, Collection<String> ignoredPropNames)
M - resultMap - entity - ignoredPropNames - public static <M extends Map<String,Object>> M deepEntity2Map(M resultMap, Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
M - resultMap - entity - ignoreNullProperty - ignoredPropNames - public static <M extends Map<String,Object>> M deepEntity2Map(M resultMap, Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
M - resultMap - entity - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static List<Map<String,Object>> deepEntity2Map(Collection<?> entityList)
entityList - public static List<Map<String,Object>> deepEntity2Map(Collection<?> entityList, boolean ignoreNullProperty)
entityList - ignoreNullProperty - public static List<Map<String,Object>> deepEntity2Map(Collection<?> entityList, Collection<String> ignoredPropNames)
entityList - ignoredPropNames - public static List<Map<String,Object>> deepEntity2Map(Collection<?> entityList, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
entityList - ignoreNullProperty - ignoredPropNames - public static List<Map<String,Object>> deepEntity2Map(Collection<?> entityList, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
entityList - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static Map<String,Object> entity2FlatMap(Object entity)
entity - public static Map<String,Object> entity2FlatMap(Object entity, boolean ignoreNullProperty)
entity - ignoreNullProperty - public static Map<String,Object> entity2FlatMap(Object entity, Collection<String> ignoredPropNames)
entity - ignoredPropNames - public static Map<String,Object> entity2FlatMap(Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
entity - ignoreNullProperty - ignoredPropNames - public static Map<String,Object> entity2FlatMap(Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
entity - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static <M extends Map<String,Object>> M entity2FlatMap(Object entity, Supplier<? extends M> mapSupplier)
M - entity - mapSupplier - public static <M extends Map<String,Object>> M entity2FlatMap(M resultMap, Object entity)
M - resultMap - entity - public static <M extends Map<String,Object>> M entity2FlatMap(M resultMap, Object entity, boolean ignoreNullProperty)
M - resultMap - entity - ignoreNullProperty - public static <M extends Map<String,Object>> M entity2FlatMap(M resultMap, Object entity, Collection<String> ignoredPropNames)
M - resultMap - entity - ignoredPropNames - public static <M extends Map<String,Object>> M entity2FlatMap(M resultMap, Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
M - resultMap - entity - ignoreNullProperty - ignoredPropNames - public static <M extends Map<String,Object>> M entity2FlatMap(M resultMap, Object entity, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
M - resultMap - entity - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - public static List<Map<String,Object>> entity2FlatMap(Collection<?> entityList)
entityList - public static List<Map<String,Object>> entity2FlatMap(Collection<?> entityList, boolean ignoreNullProperty)
entityList - ignoreNullProperty - public static List<Map<String,Object>> entity2FlatMap(Collection<?> entityList, Collection<String> ignoredPropNames)
entityList - ignoredPropNames - public static List<Map<String,Object>> entity2FlatMap(Collection<?> entityList, boolean ignoreNullProperty, Collection<String> ignoredPropNames)
entityList - ignoreNullProperty - ignoredPropNames - public static List<Map<String,Object>> entity2FlatMap(Collection<?> entityList, boolean ignoreNullProperty, Collection<String> ignoredPropNames, NamingPolicy keyNamingPolicy)
entityList - ignoreNullProperty - ignoredPropNames - keyNamingPolicy - Copyright © 2021. All rights reserved.