public class WritableTypeId extends Object
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 |
---|---|
static class |
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.
|
Modifier and Type | Field and Description |
---|---|
String |
asProperty
If type id is to be embedded as a regular property, name of the property;
otherwise `null`.
|
Object |
extra
Optional additional information that generator may add during "prefix write",
to be available on matching "suffix write".
|
Object |
forValue
Java object for which type id is being written.
|
Class<?> |
forValueType
(optional) Super-type of
forValue to use for type id generation (if no
explicit id passed): used instead of actual class of forValue in cases
where we do not want to use the "real" type but something more generic, usually
to work around specific problem with implementation type, or its deserializer. |
Object |
id
Actual type id to use: usually {link java.lang.String}.
|
WritableTypeId.Inclusion |
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]).
|
JsonToken |
valueShape
Information about intended shape of the value being written (that is,
forValue );
in case of structured values, start token of the structure; for scalars, value token. |
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.
|
Constructor and Description |
---|
WritableTypeId() |
WritableTypeId(Object value,
Class<?> valueType0,
JsonToken valueShape0)
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(Object value,
JsonToken valueShape0)
Constructor used when calling a method for generating and writing Type Id;
caller only knows value object and its intended shape.
|
WritableTypeId(Object value,
JsonToken valueShape0,
Object id0)
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).
|
public Object forValue
public Class<?> forValueType
forValue
to use for type id generation (if no
explicit id passed): used instead of actual class of forValue
in cases
where we do not want to use the "real" type but something more generic, usually
to work around specific problem with implementation type, or its deserializer.public Object id
public String asProperty
NOTE: if "wrap-as-Object" is used, this does NOT contain property name to use but `null`.
public WritableTypeId.Inclusion include
public JsonToken valueShape
forValue
);
in case of structured values, start token of the structure; for scalars, value token.
Main difference is between structured values
(JsonToken.START_ARRAY
, JsonToken.START_OBJECT
)
and scalars (JsonToken.VALUE_STRING
): specific scalar type may not be
important for processing.public boolean wrapperWritten
public Object extra
public WritableTypeId()
public WritableTypeId(Object value, JsonToken valueShape0)
public WritableTypeId(Object value, Class<?> valueType0, JsonToken valueShape0)
Copyright © 2021 JBoss by Red Hat. All rights reserved.