Class ObjectUtils

java.lang.Object
cool.scx.common.util.ObjectUtils

public final class ObjectUtils extends Object
处理对象的工具类
本质上就是对 ObjectMapper 进行了一些简单的封装 todo 我们是否真的需要如此多的 ObjectMapper 来完成忽略注解这件事
Version:
0.0.1
Author:
scx567888
  • Field Details

    • MAP_TYPE

      public static final com.fasterxml.jackson.core.type.TypeReference<Map<String,Object>> MAP_TYPE
      因为 java 无法方便的存储泛型 使用 TypeReference 创建一些常用的类型 此类为 Map 类型
  • Constructor Details

    • ObjectUtils

      public ObjectUtils()
  • Method Details

    • jsonMapper

      public static com.fasterxml.jackson.databind.json.JsonMapper jsonMapper(ObjectUtils.Options options)
    • xmlMapper

      public static com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper(ObjectUtils.Options options)
    • jsonMapper

      public static com.fasterxml.jackson.databind.json.JsonMapper jsonMapper()
    • xmlMapper

      public static com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper()
    • constructType

      public static com.fasterxml.jackson.databind.JavaType constructType(Type type)
    • constructType

      public static com.fasterxml.jackson.databind.JavaType constructType(com.fasterxml.jackson.core.type.TypeReference<?> typeRef)
    • resolveMemberType

      public static com.fasterxml.jackson.databind.JavaType resolveMemberType(Type type, com.fasterxml.jackson.databind.type.TypeBindings contextBindings)
    • getTypeFactory

      public static com.fasterxml.jackson.databind.type.TypeFactory getTypeFactory()
    • convertValue

      public static <T> T convertValue(Object fromValue, com.fasterxml.jackson.databind.JavaType javaType, ObjectUtils.Options options)
    • convertValue

      public static <T> T convertValue(Object fromValue, Class<T> tClass, ObjectUtils.Options options)
    • convertValue

      public static <T> T convertValue(Object fromValue, Type toValueType, ObjectUtils.Options options)
    • convertValue

      public static <T> T convertValue(Object fromValue, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef, ObjectUtils.Options options)
    • convertValue

      public static <T> T convertValue(Object fromValue, com.fasterxml.jackson.databind.JavaType javaType)
    • convertValue

      public static <T> T convertValue(Object fromValue, Class<T> tClass)
    • convertValue

      public static <T> T convertValue(Object fromValue, Type toValueType)
    • convertValue

      public static <T> T convertValue(Object fromValue, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef)
    • toJson

      public static String toJson(Object value, String defaultValue, ObjectUtils.Options options)
    • toXml

      public static String toXml(Object value, String defaultValue, ObjectUtils.Options options)
    • toJson

      public static String toJson(Object value, String defaultValue)
    • toXml

      public static String toXml(Object value, String defaultValue)
    • toJson

      public static String toJson(Object value, ObjectUtils.Options options) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • toXml

      public static String toXml(Object value, ObjectUtils.Options options) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • toJson

      public static String toJson(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • toXml

      public static String toXml(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • flatMap

      public static Map<String,Object> flatMap(Map<?,?> sourceMap)
      将嵌套的 map 扁平化
      Parameters:
      sourceMap - 源 map
      Returns:
      扁平化后的 map