Enum WritableTypeId.Inclusion
- java.lang.Object
-
- java.lang.Enum<WritableTypeId.Inclusion>
-
- com.fasterxml.jackson.core.type.WritableTypeId.Inclusion
-
- All Implemented Interfaces:
Serializable
,Comparable<WritableTypeId.Inclusion>
- Enclosing class:
- WritableTypeId
public static enum WritableTypeId.Inclusion extends Enum<WritableTypeId.Inclusion>
Enumeration of values that matches enum `As` from annotation `JsonTypeInfo`: separate definition to avoid dependency between streaming core and annotations packages; also allows more flexibility in case new values needed at this level of internal API.NOTE: in most cases this only matters with formats that do NOT have native type id capabilities, and require type id to be included within regular data (whether exposed as Java properties or not). Formats with native types usually use native type id functionality regardless, unless overridden by a feature to use "non-native" type inclusion.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description METADATA_PROPERTY
Inclusion as a property within Object to write, but logically as separate metadata that is not exposed as payload to caller: that is, does not match any of visible properties value object has.PARENT_PROPERTY
Inclusion as a property within "parent" Object of value Object to write.PAYLOAD_PROPERTY
Inclusion as a "regular" property within Object to write; this implies that its value should come from regular POJO property on serialization, and be deserialized into such property.WRAPPER_ARRAY
Inclusion as wrapper Array (1st element type id, 2nd element value).WRAPPER_OBJECT
Inclusion as wrapper Object that has one key/value pair where type id is the key for typed value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
requiresObjectContext()
static WritableTypeId.Inclusion
valueOf(String name)
Returns the enum constant of this type with the specified name.static WritableTypeId.Inclusion[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
WRAPPER_ARRAY
public static final WritableTypeId.Inclusion WRAPPER_ARRAY
Inclusion as wrapper Array (1st element type id, 2nd element value).Corresponds to
JsonTypeInfo.As.WRAPPER_ARRAY
.
-
WRAPPER_OBJECT
public static final WritableTypeId.Inclusion WRAPPER_OBJECT
Inclusion as wrapper Object that has one key/value pair where type id is the key for typed value.Corresponds to
JsonTypeInfo.As.WRAPPER_OBJECT
.
-
METADATA_PROPERTY
public static final WritableTypeId.Inclusion METADATA_PROPERTY
Inclusion as a property within Object to write, but logically as separate metadata that is not exposed as payload to caller: that is, does not match any of visible properties value object has.NOTE: if shape of typed value to write is NOT Object, will instead use
WRAPPER_ARRAY
inclusion.Corresponds to
JsonTypeInfo.As.PROPERTY
.
-
PAYLOAD_PROPERTY
public static final WritableTypeId.Inclusion PAYLOAD_PROPERTY
Inclusion as a "regular" property within Object to write; this implies that its value should come from regular POJO property on serialization, and be deserialized into such property. This handling, however, is up to databinding.Regarding handling, type id is ONLY written as native type id; if no native type ids available, caller is assumed to handle output some other way. This is different from
METADATA_PROPERTY
.NOTE: if shape of typed value to write is NOT Object, will instead use
WRAPPER_ARRAY
inclusion.Corresponds to
JsonTypeInfo.As.EXISTING_PROPERTY
.
-
PARENT_PROPERTY
public static final WritableTypeId.Inclusion PARENT_PROPERTY
Inclusion as a property within "parent" Object of value Object to write. This typically requires slightly convoluted processing in which property that contains type id is actually written after typed value object itself is written.
Note that it is illegal to call write method if the current (parent) write context is not Object: no coercion is done for other inclusion types (unlike with otherxxx_PROPERTY
choices. This also means that root values MAY NOT use this type id inclusion mechanism (as they have no parent context).Corresponds to
JsonTypeInfo.As.EXTERNAL_PROPERTY
.
-
-
Method Detail
-
values
public static WritableTypeId.Inclusion[] 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 (WritableTypeId.Inclusion c : WritableTypeId.Inclusion.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static WritableTypeId.Inclusion 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 nameNullPointerException
- if the argument is null
-
requiresObjectContext
public boolean requiresObjectContext()
-
-