Enum JsonTypeInfo.Id

java.lang.Object
java.lang.Enum<JsonTypeInfo.Id>
com.fasterxml.jackson.annotation.JsonTypeInfo.Id
All Implemented Interfaces:
Serializable, Comparable<JsonTypeInfo.Id>, java.lang.constant.Constable
Enclosing class:
JsonTypeInfo

public static enum JsonTypeInfo.Id extends Enum<JsonTypeInfo.Id>
Definition of different type identifiers that can be included in JSON during serialization, and used for deserialization.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Means that fully-qualified Java class name is used as the type identifier.
    Means that typing mechanism uses customized handling, with possibly custom configuration.
    Means that no serialized typing-property is used.
    Means that Java class name with minimal path is used as the type identifier.
    Means that logical type name is used as type information; name will then need to be separately resolved to actual concrete type (Class).
    This means that no explicit type metadata is included, and typing is purely done using contextual information possibly augmented with other annotations.
    Means that the simple name of the Java class, equivalent to the value returned by Class.getSimpleName(), is used as the default type identifier, unless explicit name is specified by annotation JsonTypeName.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Id(String defProp)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NONE

      public static final JsonTypeInfo.Id NONE
      This means that no explicit type metadata is included, and typing is purely done using contextual information possibly augmented with other annotations.
    • CLASS

      public static final JsonTypeInfo.Id CLASS
      Means that fully-qualified Java class name is used as the type identifier.
    • MINIMAL_CLASS

      public static final JsonTypeInfo.Id MINIMAL_CLASS
      Means that Java class name with minimal path is used as the type identifier. Minimal means that only the class name, and that part of preceding Java package name is included that is needed to construct fully-qualified name given fully-qualified name of the declared supertype; additionally a single leading dot ('.') must be used to indicate that partial class name is used. For example, for supertype "com.foobar.Base", and concrete type "com.foo.Impl", only ".Impl" would be included; and for "com.foo.impl.Impl2" only ".impl.Impl2" would be included.
      NOTE: leading dot ('.') MUST be used to denote partial (minimal) name; if it is missing, value is assumed to be fully-qualified name. Fully-qualified name is used in cases where subtypes are not in same package (or sub-package thereof) as base class.

      If all related classes are in the same Java package, this option can reduce amount of type information overhead, especially for small types. However, please note that using this alternative is inherently risky since it assumes that the supertype can be reliably detected. Given that it is based on declared type (since ultimate supertype, java.lang.Object would not be very useful reference point), this may not always work as expected.

    • NAME

      public static final JsonTypeInfo.Id NAME
      Means that logical type name is used as type information; name will then need to be separately resolved to actual concrete type (Class).
    • SIMPLE_NAME

      public static final JsonTypeInfo.Id SIMPLE_NAME
      Means that the simple name of the Java class, equivalent to the value returned by Class.getSimpleName(), is used as the default type identifier, unless explicit name is specified by annotation JsonTypeName.
      For instance:
      • For a class "com.example.MyClass", only "MyClass" is used.
      • For an inner class "com.example.MyClass$Inner", only "Inner" is used.
      Note: This approach reduces verbosity but requires the simple names to be unique to avoid conflicts. If multiple classes share the same simple name, the last declared one will be used. This approach should be used with careful consideration of your type hierarchy.
      Since:
      2.16
    • DEDUCTION

      public static final JsonTypeInfo.Id DEDUCTION
      Means that no serialized typing-property is used. Types are deduced based on the Object properties available in the input. Deduction is limited to the names of properties (not their values or, consequently, any nested values). Exceptions will be thrown if not enough unique information is present to select a single sub-type.
      If deduction is being used annotation properties visible, property and include are ignored.

      NOTE: being Property-based, will essentially only work for POJOs and not for other kinds of types (like arrays, Collections, Maps, scalars, etc); similarly, serialized form must be (JSON) Object.

      On serialization, no type Id is written, and only regular properties are included.

      Since:
      2.12
    • CUSTOM

      public static final JsonTypeInfo.Id CUSTOM
      Means that typing mechanism uses customized handling, with possibly custom configuration. This means that semantics of other properties is not defined by Jackson package, but by the custom implementation.
  • Field Details

    • _defaultPropertyName

      private final String _defaultPropertyName
  • Constructor Details

    • Id

      private Id(String defProp)
  • Method Details

    • values

      public static JsonTypeInfo.Id[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static JsonTypeInfo.Id valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getDefaultPropertyName

      public String getDefaultPropertyName()