Package icu.easyj.core.util
Class MapUtils
java.lang.Object
icu.easyj.core.util.MapUtils
- Direct Known Subclasses:
CollectionUtils
Map工具类
- Author:
- wangliang181230
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> V computeIfAbsent(Map<K, V> map, K key, Function<? super K, ? extends V> mappingFunction) A temporary workaround for Java 8 specific performance issue JDK-8161372 .
This class should be removed once we drop Java 8 support.static <T extends Map<?,?>>
TdefaultIfEmpty(T map, Supplier<T> defaultValueSupplier) 如果为空数组,则执行supplier生成新的值static <T extends Map<?,?>>
TdefaultIfEmpty(T map, T defaultValue) 如果为空集合,则取默认值static boolean判断集合是否为空static booleanisNotEmpty(Map<?, ?> map) 判断集合是否不为空static <K,V> Map<K, V> quickMap(K key, V value) 快速创建Mapstatic <K,V> Map<K, V> quickMap(K key1, V value1, K key2, V value2) 快速创建Mapstatic <K,V> Map<K, V> quickMap(K key1, V value1, K key2, V value2, K key3, V value3) 快速创建Map将对象转换为Map
注意:暂时不支持嵌套类。将对象转换为Map
注意:暂时不支持嵌套类。static StringMap to string.
-
Constructor Details
-
MapUtils
public MapUtils()
-
-
Method Details
-
isEmpty
判断集合是否为空- Parameters:
map- 集合- Returns:
- 是否为空
-
isNotEmpty
判断集合是否不为空- Parameters:
map- 集合- Returns:
- 是否不为空
-
defaultIfEmpty
如果为空集合,则取默认值- Type Parameters:
T- 集合类型- Parameters:
map- 集合defaultValue- 默认值- Returns:
- 入参集合或默认值
-
defaultIfEmpty
如果为空数组,则执行supplier生成新的值- Type Parameters:
T- 集合类型- Parameters:
map- 集合defaultValueSupplier- 默认值提供者- Returns:
- 入参集合或生成的默认值
-
quickMap
快速创建Map- Type Parameters:
K- 键类型V- 值类型- Parameters:
key- 键value- 值- Returns:
- Map
-
quickMap
快速创建Map- Type Parameters:
K- 键类型V- 值类型- Parameters:
key1- 键1value1- 值1key2- 键2value2- 值2- Returns:
- Map
-
quickMap
快速创建Map- Type Parameters:
K- 键类型V- 值类型- Parameters:
key1- 键1value1- 值1key2- 键2value2- 值2key3- 键3value3- 值3- Returns:
- Map
-
computeIfAbsent
public static <K,V> V computeIfAbsent(Map<K, V> map, K key, Function<? super K, ? extends V> mappingFunction) A temporary workaround for Java 8 specific performance issue JDK-8161372 .
This class should be removed once we drop Java 8 support.- Type Parameters:
K- the type of keyV- the type of value- Parameters:
map- the mapkey- the keymappingFunction- the mapping function- Returns:
- the value
- See Also:
-
toMap
将对象转换为Map
注意:暂时不支持嵌套类。- Type Parameters:
V- 值类- Parameters:
obj- 对象valueClass- 值类型- Returns:
- map
- Since:
- 0.6.5
-
toMap
将对象转换为Map
注意:暂时不支持嵌套类。- Parameters:
obj- 对象- Returns:
- map
- Since:
- 0.6.5
-
toString
Map to string.- Parameters:
map- the map- Returns:
- the string
-