Class MapGets

java.lang.Object
org.miaixz.bus.core.center.map.MapValidator
org.miaixz.bus.core.center.map.MapGets
Direct Known Subclasses:
MapKit

public class MapGets extends MapValidator
Map的getXXX封装,提供针对通用型的value按照所需类型获取值
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • MapGets

      public MapGets()
  • Method Details

    • getString

      public static String getString(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为字符串
      Parameters:
      map - Map
      key - 键
      Returns:
    • getString

      public static String getString(Map<?,?> map, Object key, String defaultValue)
      获取Map指定key的值,并转换为字符串
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getInt

      public static Integer getInt(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Integer
      Parameters:
      map - Map
      key - 键
      Returns:
    • getInt

      public static Integer getInt(Map<?,?> map, Object key, Integer defaultValue)
      获取Map指定key的值,并转换为Integer
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getDouble

      public static Double getDouble(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Double
      Parameters:
      map - Map
      key - 键
      Returns:
    • getDouble

      public static Double getDouble(Map<?,?> map, Object key, Double defaultValue)
      获取Map指定key的值,并转换为Double
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getFloat

      public static Float getFloat(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Float
      Parameters:
      map - Map
      key - 键
      Returns:
    • getFloat

      public static Float getFloat(Map<?,?> map, Object key, Float defaultValue)
      获取Map指定key的值,并转换为Float
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getShort

      public static Short getShort(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Short
      Parameters:
      map - Map
      key - 键
      Returns:
    • getShort

      public static Short getShort(Map<?,?> map, Object key, Short defaultValue)
      获取Map指定key的值,并转换为Short
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getBoolean

      public static Boolean getBoolean(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Bool
      Parameters:
      map - Map
      key - 键
      Returns:
    • getBoolean

      public static Boolean getBoolean(Map<?,?> map, Object key, Boolean defaultValue)
      获取Map指定key的值,并转换为Bool
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getChar

      public static Character getChar(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Character
      Parameters:
      map - Map
      key - 键
      Returns:
    • getChar

      public static Character getChar(Map<?,?> map, Object key, Character defaultValue)
      获取Map指定key的值,并转换为Character
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getLong

      public static Long getLong(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Long
      Parameters:
      map - Map
      key - 键
      Returns:
    • getLong

      public static Long getLong(Map<?,?> map, Object key, Long defaultValue)
      获取Map指定key的值,并转换为Long
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • getDate

      public static Date getDate(Map<?,?> map, Object key)
      获取Map指定key的值,并转换为Date
      Parameters:
      map - Map
      key - 键
      Returns:
    • getDate

      public static Date getDate(Map<?,?> map, Object key, Date defaultValue)
      获取Map指定key的值,并转换为Date
      Parameters:
      map - Map
      key - 键
      defaultValue - 默认值
      Returns:
    • get

      public static <T> T get(Map<?,?> map, Object key, Class<T> type)
      获取Map指定key的值,并转换为指定类型
      Type Parameters:
      T - 目标值类型
      Parameters:
      map - Map
      key - 键
      type - 值类型
      Returns:
    • get

      public static <T> T get(Map<?,?> map, Object key, Class<T> type, T defaultValue)
      获取Map指定key的值,并转换为指定类型
      Type Parameters:
      T - 目标值类型
      Parameters:
      map - Map
      key - 键
      type - 值类型
      defaultValue - 默认值
      Returns:
    • getQuietly

      public static <T> T getQuietly(Map<?,?> map, Object key, Class<T> type, T defaultValue)
      获取Map指定key的值,并转换为指定类型,此方法在转换失败后不抛异常,返回null。
      Type Parameters:
      T - 目标值类型
      Parameters:
      map - Map
      key - 键
      type - 值类型
      defaultValue - 默认值
      Returns:
    • get

      public static <T> T get(Map<?,?> map, Object key, TypeReference<T> type)
      获取Map指定key的值,并转换为指定类型
      Type Parameters:
      T - 目标值类型
      Parameters:
      map - Map
      key - 键
      type - 值类型
      Returns:
    • get

      public static <T> T get(Map<?,?> map, Object key, TypeReference<T> type, T defaultValue)
      获取Map指定key的值,并转换为指定类型
      Type Parameters:
      T - 目标值类型
      Parameters:
      map - Map
      key - 键
      type - 值类型
      defaultValue - 默认值
      Returns:
    • getQuietly

      public static <T> T getQuietly(Map<?,?> map, Object key, TypeReference<T> type, T defaultValue)
      获取Map指定key的值,并转换为指定类型,转换失败后返回null,不抛异常
      Type Parameters:
      T - 目标值类型
      Parameters:
      map - Map
      key - 键
      type - 值类型
      defaultValue - 默认值
      Returns: