Class ObjectUtils
java.lang.Object
cool.scx.common.util.ObjectUtils
处理对象的工具类
本质上就是对
ObjectMapper 进行了一些简单的封装
todo 我们是否真的需要如此多的 ObjectMapper 来完成忽略注解这件事- Version:
- 0.0.1
- Author:
- scx567888
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.JavaTypeconstructType(com.fasterxml.jackson.core.type.TypeReference<?> typeRef) static com.fasterxml.jackson.databind.JavaTypeconstructType(Type type) static <T> TconvertValue(Object fromValue, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef) static <T> TconvertValue(Object fromValue, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef, ObjectUtils.Options options) static <T> TconvertValue(Object fromValue, com.fasterxml.jackson.databind.JavaType javaType) static <T> TconvertValue(Object fromValue, com.fasterxml.jackson.databind.JavaType javaType, ObjectUtils.Options options) static <T> TconvertValue(Object fromValue, Class<T> tClass) static <T> TconvertValue(Object fromValue, Class<T> tClass, ObjectUtils.Options options) static <T> TconvertValue(Object fromValue, Type toValueType) static <T> TconvertValue(Object fromValue, Type toValueType, ObjectUtils.Options options) 将嵌套的 map 扁平化static com.fasterxml.jackson.databind.type.TypeFactorystatic com.fasterxml.jackson.databind.json.JsonMapperstatic com.fasterxml.jackson.databind.json.JsonMapperjsonMapper(ObjectUtils.Options options) static com.fasterxml.jackson.databind.JavaTyperesolveMemberType(Type type, com.fasterxml.jackson.databind.type.TypeBindings contextBindings) static Stringstatic StringtoJson(Object value, ObjectUtils.Options options) static Stringstatic StringtoJson(Object value, String defaultValue, ObjectUtils.Options options) static Stringstatic StringtoXml(Object value, ObjectUtils.Options options) static Stringstatic StringtoXml(Object value, String defaultValue, ObjectUtils.Options options) static com.fasterxml.jackson.dataformat.xml.XmlMapperstatic com.fasterxml.jackson.dataformat.xml.XmlMapperxmlMapper(ObjectUtils.Options options)
-
Field Details
-
MAP_TYPE
-
-
Constructor Details
-
ObjectUtils
public ObjectUtils()
-
-
Method Details
-
jsonMapper
public static com.fasterxml.jackson.databind.json.JsonMapper jsonMapper(ObjectUtils.Options options) -
xmlMapper
-
jsonMapper
public static com.fasterxml.jackson.databind.json.JsonMapper jsonMapper() -
xmlMapper
public static com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper() -
constructType
-
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
-
convertValue
-
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
-
convertValue
-
convertValue
public static <T> T convertValue(Object fromValue, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef) -
toJson
-
toXml
-
toJson
-
toXml
-
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
-
toXml
-
flatMap
-