Package org.summerboot.jexpress.util
Class BeanUtil
java.lang.Object
org.summerboot.jexpress.util.BeanUtil
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final com.fasterxml.jackson.databind.ObjectMapperprotected static final com.fasterxml.jackson.databind.ObjectMapperstatic final jakarta.validation.ValidatorFactoryprotected static final com.fasterxml.jackson.dataformat.xml.XmlMapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigure(boolean fromJsonFailOnUnknownProperties, boolean toJsonPretty, boolean toJsonIgnoreNull) static voidconfigure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) static voidconfigure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) static voidconfigure(com.fasterxml.jackson.databind.DeserializationFeature f, boolean state) static voidconfigure(com.fasterxml.jackson.databind.SerializationFeature f, boolean state) static <T> Tstatic <T> TDeserialization , convert JSON string to object Tstatic <R> RDeserialization , convert JSON string to object Tstatic <T> TDeserialization , convert JSON string to object Tstatic <T> Tstatic Stringstatic voidregisterModules(com.fasterxml.jackson.databind.Module... modules) static <T> StringtoJson(T obj) Serialization, convert to JSON string, not pretty and ignore null/emptystatic <T> StringtoJson(T obj, boolean pretty, boolean ignoreNull) Serialization, convert to JSON stringstatic String
-
Field Details
-
JacksonMapper
protected static final com.fasterxml.jackson.databind.ObjectMapper JacksonMapper -
JacksonMapperIgnoreNull
protected static final com.fasterxml.jackson.databind.ObjectMapper JacksonMapperIgnoreNull -
xmlMapper
protected static final com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper -
ValidatorFactory
public static final jakarta.validation.ValidatorFactory ValidatorFactory
-
-
Constructor Details
-
BeanUtil
public BeanUtil()
-
-
Method Details
-
registerModules
public static void registerModules(com.fasterxml.jackson.databind.Module... modules) -
configure
public static void configure(com.fasterxml.jackson.databind.SerializationFeature f, boolean state) -
configure
public static void configure(com.fasterxml.jackson.databind.DeserializationFeature f, boolean state) -
configure
public static void configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) -
configure
public static void configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) -
configure
public static void configure(boolean fromJsonFailOnUnknownProperties, boolean toJsonPretty, boolean toJsonIgnoreNull) -
toJson
Serialization, convert to JSON string, not pretty and ignore null/empty- Type Parameters:
T-- Parameters:
obj-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
toJson
public static <T> String toJson(T obj, boolean pretty, boolean ignoreNull) throws com.fasterxml.jackson.core.JsonProcessingException Serialization, convert to JSON string- Type Parameters:
T-- Parameters:
obj-pretty-ignoreNull-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
fromJson
public static <T> T fromJson(Class<T> c, String json) throws com.fasterxml.jackson.core.JsonProcessingException Deserialization , convert JSON string to object T- Type Parameters:
T-- Parameters:
c-json-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
fromJson
public static <T> T fromJson(com.fasterxml.jackson.databind.JavaType javaType, String json) throws com.fasterxml.jackson.core.JsonProcessingException Deserialization , convert JSON string to object T- Type Parameters:
T-- Parameters:
javaType-json-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
fromJson
public static <T> T fromJson(com.fasterxml.jackson.core.type.TypeReference<T> javaType, String json) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
fromJson
public static <R> R fromJson(Class<R> collectionClass, Class<?> genericClass, String json) throws com.fasterxml.jackson.core.JsonProcessingException Deserialization , convert JSON string to object T- Type Parameters:
R-- Parameters:
collectionClass-genericClass-json-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
fromXML
public static <T> T fromXML(Class<T> targetClass, String xml) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
toXML
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getBeanValidationResult
-