Class BeanUtil

java.lang.Object
tools.jackson.databind.util.BeanUtil

public class BeanUtil extends Object
Helper class that contains functionality needed by both serialization and deserialization side.
  • Constructor Details

    • BeanUtil

      public BeanUtil()
  • Method Details

    • stdManglePropertyName

      @Deprecated public static String stdManglePropertyName(String basename, int offset)
      Deprecated.
      since 3.0.0-rc2 Use DefaultAccessorNamingStrategy instead
    • propertyDefaultValue

      public static Object propertyDefaultValue(JavaType type, boolean wrappersAsNulls)
      Accessor used to find out "default value" to use for comparing values to serialize, to determine whether to exclude value from serialization with inclusion type of JsonInclude.Include.NON_DEFAULT.

      Default logic is such that for primitives, expected defaults (0 for `int`, `false` for `boolean`) are returned; for primitive wrappers (`Integer`, `Boolean`, etc), either `null` or wrapped default for matching primitive is returned (depending on MapperFeature.WRAPPERS_DEFAULT_TO_NULL setting); for Strings, empty String; and for structured (Maps, Collections, arrays) and reference types, criteria JsonInclude.Include.NON_EMPTY is used (to compare to "empty" value)

      Parameters:
      type - Type for which default value requested
      wrappersAsNulls - If true, default for primitive wrapper types like Boolean will be null; if false will be wrapped default of matching primitive type (for java.lang.Boolean that would be Boolean.FALSE)
      Since:
      3.1
    • propertyDefaultValue

      public static Object propertyDefaultValue(DatabindContext ctxt, JavaType type)
      Short-cut for:
       getDefaultValue(type, ctxt.isEnabled(MapperFeature.WRAPPERS_DEFAULT_TO_NUL));
      
      Since:
      3.1
    • propertyDefaultValue

      public static Object propertyDefaultValue(MapperConfig<?> config, JavaType type)
      Short-cut for:
       propertyDefaultValue(type, config.isEnabled(MapperFeature.WRAPPERS_DEFAULT_TO_NUL));
      
      Since:
      3.1
    • getDefaultValue

      @Deprecated public static Object getDefaultValue(JavaType type)
      Deprecated.
      Since 3.1 use one of propertyDefaultValue() variants.
    • checkUnsupportedType

      public static String checkUnsupportedType(MapperConfig<?> config, JavaType type)
      Helper method called by BeanDeserializerFactory and BeanSerializerFactory to check if given unrecognized type (to be (de)serialized as general POJO) is one of "well-known" types for which there would be a datatype module; and if so, return appropriate failure message to give to caller.
    • isJodaTimeClass

      public static boolean isJodaTimeClass(Class<?> rawType)