Package com.fasterxml.jackson.annotation
Enum JsonTypeInfo.Id
- java.lang.Object
-
- java.lang.Enum<JsonTypeInfo.Id>
-
- com.fasterxml.jackson.annotation.JsonTypeInfo.Id
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<JsonTypeInfo.Id>
- Enclosing class:
- JsonTypeInfo
public static enum JsonTypeInfo.Id extends java.lang.Enum<JsonTypeInfo.Id>
Definition of different type identifiers that can be included in JSON during serialization, and used for deserialization.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CLASS
Means that fully-qualified Java class name is used as the type identifier.CUSTOM
Means that typing mechanism uses customized handling, with possibly custom configuration.DEDUCTION
Means that no serialized typing-property is used.MINIMAL_CLASS
Means that Java class name with minimal path is used as the type identifier.NAME
Means that logical type name is used as type information; name will then need to be separately resolved to actual concrete type (Class).NONE
This means that no explicit type metadata is included, and typing is purely done using contextual information possibly augmented with other annotations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDefaultPropertyName()
static JsonTypeInfo.Id
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static JsonTypeInfo.Id[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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).
-
DEDUCTION
public static final JsonTypeInfo.Id DEDUCTION
Means that no serialized typing-property is used. Types are deduced based on the fields available. Deduction is limited to the names of fields (not their values or, consequently, any nested descendants). Exceptions will be thrown if not enough unique information is present to select a single subtype.
If deduction is being used annotation propertiesvisible
,property
andinclude
are ignored.- Since:
- 2.12.0.
-
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.
-
-
Method Detail
-
values
public static JsonTypeInfo.Id[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JsonTypeInfo.Id c : JsonTypeInfo.Id.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JsonTypeInfo.Id valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getDefaultPropertyName
public java.lang.String getDefaultPropertyName()
-
-