Usual usage pattern is such that instance of this class is passed on two calls that are needed for outputting type id (and possible additional wrapping, depending on format; JSON, for example, requires wrapping as type id is part of regular data): first, a "prefix" write (which usually includes actual id), performed before value write; and then matching "suffix" write after value serialization.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | WritableTypeId.
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. |
| Modifier and Type | Field and Description |
|---|---|
| public String | asProperty
If type id is to be embedded as a regular property, name of the property; otherwise `null`. |
| public Object | extra
Optional additional information that generator may add during "prefix write", to be available on matching "suffix write". |
| public Object | forValue
Java object for which type id is being written. |
| public Class | forValueType
(optional) Super-type of |
| public Object | id
Actual type id to use: usually {link java.lang.String}. |
| public WritableTypeId. | include
Property used to indicate style of inclusion for this type id, in cases where no native type id may be used (either because format has none, like JSON; or because use of native type ids is disabled [with YAML]). |
| public JsonToken | valueShape
Information about intended shape of the value being written (that is, |
| public boolean | wrapperWritten
Flag that can be set to indicate that wrapper structure was written (during prefix-writing); used to determine if suffix requires matching close markers. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | WritableTypeId(Object
Actual value for which type information is written value, JsonToken Serialize shape writer will use for value valueShape)Constructor used when calling a method for generating and writing Type Id; caller only knows value object and its intended shape. |
| public | WritableTypeId(Object
Actual value for which type information is written value, Class<?> Effective type of valueType, JsonToken value to use for Type Id generationSerialize shape writer will use for value valueShape)Constructor used when calling a method for generating and writing Type Id, but where actual type to use for generating id is NOT the type of value (but its supertype). |
| public | WritableTypeId(Object
Actual value for which type information is written value, JsonToken Serialize shape writer will use for value valueShape, Object Actual type id to use if known; id)null if notConstructor used when calling a method for writing Type Id; caller knows value object, its intended shape as well as id to use; but not details of wrapping (if any). |
| asProperty | back to summary |
|---|---|
| public String asProperty If type id is to be embedded as a regular property, name of the property; otherwise `null`. Note if "wrap-as-Object" is used, this does NOT contain property name to use but `null`. | |
| extra | back to summary |
|---|---|
| public Object extra Optional additional information that generator may add during "prefix write", to be available on matching "suffix write". | |
| forValue | back to summary |
|---|---|
| public Object forValue Java object for which type id is being written. Not needed by default handling, but may be useful for customized format handling. | |
| forValueType | back to summary |
|---|---|
| public Class<?> forValueType (optional) Super-type of | |
| id | back to summary |
|---|---|
| public Object id Actual type id to use: usually {link java.lang.String}. | |
| include | back to summary |
|---|---|
| public WritableTypeId. Property used to indicate style of inclusion for this type id, in cases where no native type id may be used (either because format has none, like JSON; or because use of native type ids is disabled [with YAML]). | |
| valueShape | back to summary |
|---|---|
| public JsonToken valueShape Information about intended shape of the value being written (that is, | |
| wrapperWritten | back to summary |
|---|---|
| public boolean wrapperWritten Flag that can be set to indicate that wrapper structure was written (during prefix-writing); used to determine if suffix requires matching close markers. | |
| WritableTypeId | back to summary |
|---|---|
| public WritableTypeId() | |
| WritableTypeId | back to summary |
|---|---|
| public WritableTypeId(Object value, JsonToken valueShape) Constructor used when calling a method for generating and writing Type Id; caller only knows value object and its intended shape. | |
| WritableTypeId | back to summary |
|---|---|
| public WritableTypeId(Object value, Class<?> valueType, JsonToken valueShape) Constructor used when calling a method for generating and writing Type Id, but where actual type to use for generating id is NOT the type of value (but its supertype). | |
| WritableTypeId | back to summary |
|---|---|
| public WritableTypeId(Object value, JsonToken valueShape, Object id) Constructor used when calling a method for writing Type Id; caller knows value object, its intended shape as well as id to use; but not details of wrapping (if any). | |
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.
| Modifier and Type | Field and Description |
|---|---|
| public static final WritableTypeId. | 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. |
| public static final WritableTypeId. | PARENT_PROPERTY
Inclusion as a property within "parent" Object of value Object to write. |
| public static final WritableTypeId. | 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. |
| public static final WritableTypeId. | WRAPPER_ARRAY
Inclusion as wrapper Array (1st element type id, 2nd element value). |
| public static final WritableTypeId. | WRAPPER_OBJECT
Inclusion as wrapper Object that has one key/value pair where type id is the key for typed value. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public static WritableTypeId. | |
| public static WritableTypeId. |
| METADATA_PROPERTY | back to summary |
|---|---|
| public static final WritableTypeId. 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
Corresponds to | |
| PARENT_PROPERTY | back to summary |
|---|---|
| public static final WritableTypeId. 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.
Corresponds to | |
| PAYLOAD_PROPERTY | back to summary |
|---|---|
| public static final WritableTypeId. 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 Note if shape of typed value to write is NOT Object, will instead use
Corresponds to | |
| WRAPPER_ARRAY | back to summary |
|---|---|
| public static final WritableTypeId. Inclusion as wrapper Array (1st element type id, 2nd element value).
Corresponds to | |
| WRAPPER_OBJECT | back to summary |
|---|---|
| public static final WritableTypeId. Inclusion as wrapper Object that has one key/value pair where type id is the key for typed value.
Corresponds to | |
| Inclusion | back to summary |
|---|---|
| private Inclusion() | |
| requiresObjectContext | back to summary |
|---|---|
| public boolean requiresObjectContext() | |
| valueOf | back to summary |
|---|---|
| public static WritableTypeId. | |
| values | back to summary |
|---|---|
| public static WritableTypeId. | |