类 Maps

java.lang.Object
cn.valot.common.data.Maps

public final class Maps extends Object
Map工具类
作者:
sa@linkot.cn
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static <K, V> HashMap<K,V>
    asMap(Dict<K,V>... dicts)
    把所有 dict 转化为 hashmap
    static <K, V> Hashtable<K,V>
    asTable(Dict<K,V>... dicts)
    把所有 dict 转化为 hashtable
    static <K, V> Map<K,V>
    filter(Map<K,V> map, java.util.function.BiPredicate<K,V> func)
    过滤 map 中的键值对
    static <K, V> Map<K,V>
    parseMap(List<V> list, java.util.function.Function<V,K> keyFunc)
    把 list 转化为 map
    static <K, V, R> Map<K,R>
    parseMap(List<V> list, java.util.function.Function<V,K> keyFunc, java.util.function.Function<V,R> valueFunc)
    把 list 转化为 map

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • Maps

      public Maps()
  • 方法详细资料

    • asMap

      @SafeVarargs public static <K, V> HashMap<K,V> asMap(Dict<K,V>... dicts)
      把所有 dict 转化为 hashmap
      参数:
      dicts - 键值对集
      返回:
      hashmap
    • asTable

      @SafeVarargs public static <K, V> Hashtable<K,V> asTable(Dict<K,V>... dicts)
      把所有 dict 转化为 hashtable
      参数:
      dicts - 键值对集
      返回:
      hashtable
    • parseMap

      public static <K, V> Map<K,V> parseMap(List<V> list, java.util.function.Function<V,K> keyFunc)
      把 list 转化为 map
      参数:
      list - 所有元素
      keyFunc - 转化为 key 的方法
      返回:
      key 为通过 keyFunc 转换的, value 为原对象
    • parseMap

      public static <K, V, R> Map<K,R> parseMap(List<V> list, java.util.function.Function<V,K> keyFunc, java.util.function.Function<V,R> valueFunc)
      把 list 转化为 map
      参数:
      list - 所有元素
      keyFunc - 转化为 key 的方法
      valueFunc - 转化为 value 的方法
      返回:
      通过 keyFunc 和 valueFunc 映射的新 map
    • filter

      public static <K, V> Map<K,V> filter(Map<K,V> map, java.util.function.BiPredicate<K,V> func)
      过滤 map 中的键值对
      参数:
      map - 原 map
      func - 过滤函数
      返回:
      条件为 true 的map