Class BeanUtil

java.lang.Object
org.summerboot.jexpress.util.BeanUtil

public class BeanUtil extends Object
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final com.fasterxml.jackson.databind.ObjectMapper
     
    protected static final com.fasterxml.jackson.databind.ObjectMapper
     
    static final jakarta.validation.ValidatorFactory
     
    protected static final com.fasterxml.jackson.dataformat.xml.XmlMapper
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    configure(boolean fromJsonFailOnUnknownProperties, boolean toJsonPretty, boolean toJsonIgnoreNull)
     
    static void
    configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state)
     
    static void
    configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state)
     
    static void
    configure(com.fasterxml.jackson.databind.DeserializationFeature f, boolean state)
     
    static void
    configure(com.fasterxml.jackson.databind.SerializationFeature f, boolean state)
     
    static <T> T
    fromJson(com.fasterxml.jackson.core.type.TypeReference<T> javaType, String json)
     
    static <T> T
    fromJson(com.fasterxml.jackson.databind.JavaType javaType, String json)
    Deserialization , convert JSON string to object T
    static <R> R
    fromJson(Class<R> collectionClass, Class<?> genericClass, String json)
    Deserialization , convert JSON string to object T
    static <T> T
    fromJson(Class<T> c, String json)
    Deserialization , convert JSON string to object T
    static <T> T
    fromXML(Class<T> targetClass, String xml)
     
    static String
     
    static void
    registerModules(com.fasterxml.jackson.databind.Module... modules)
     
    static <T> String
    toJson(T obj)
    Serialization, convert to JSON string, not pretty and ignore null/empty
    static <T> String
    toJson(T obj, boolean pretty, boolean ignoreNull)
    Serialization, convert to JSON string
    static String
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static <T> String toJson(T obj) throws com.fasterxml.jackson.core.JsonProcessingException
      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

      public static String toXML(Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getBeanValidationResult

      public static String getBeanValidationResult(Object bean)