类 MapUtil

java.lang.Object
com.alibaba.nacos.common.utils.MapUtil

public class MapUtil extends Object
Map utils.
作者:
liaochuntao
  • 构造器详细资料

    • MapUtil

      public MapUtil()
  • 方法详细资料

    • isEmpty

      public static boolean isEmpty(Map map)
      Null-safe check if the specified Dictionary is empty.

      Null returns true.

      参数:
      map - the collection to check, may be null
      返回:
      true if empty or null
    • isEmpty

      public static boolean isEmpty(Dictionary coll)
      Null-safe check if the specified Dictionary is empty.

      Null returns true.

      参数:
      coll - the collection to check, may be null
      返回:
      true if empty or null
    • isNotEmpty

      public static boolean isNotEmpty(Map map)
      Null-safe check if the specified Dictionary is not empty.

      Null returns false.

      参数:
      map - the collection to check, may be null
      返回:
      true if non-null and non-empty
    • isNotEmpty

      public static boolean isNotEmpty(Dictionary coll)
      Null-safe check if the specified Dictionary is not empty.

      Null returns false.

      参数:
      coll - the collection to check, may be null
      返回:
      true if non-null and non-empty
    • putIfValNoNull

      public static void putIfValNoNull(Map target, Object key, Object value)
      Put into map if value is not null.
      参数:
      target - target map
      key - key
      value - value
    • putIfValNoEmpty

      public static void putIfValNoEmpty(Map target, Object key, Object value)
      Put into map if value is not empty.
      参数:
      target - target map
      key - key
      value - value
    • computeIfAbsent

      @NotThreadSafe public static <K,​ C,​ V,​ T> V computeIfAbsent(Map<K,​V> target, K key, BiFunction<C,​T,​V> mappingFunction, C param1, T param2)
      ComputeIfAbsent lazy load.
      参数:
      target - target Map data.
      key - map key.
      mappingFunction - function which is need to be executed.
      param1 - function's parameter value1.
      param2 - function's parameter value1.
      返回:
    • removeKey

      public static <K,​ V> V removeKey(Map<K,​V> map, K key, Predicate<V> removeJudge)
      remove value, Thread safety depends on whether the Map is a thread-safe Map.
      类型参数:
      K - key type
      V - value type
      参数:
      map - map
      key - key
      removeJudge - judge this key can be remove
      返回:
      value