Package com.fasterxml.jackson.core.type

# Class WritableTypeId

java.lang.Object
com.fasterxml.jackson.core.type.WritableTypeId

public class WritableTypeId extends Object
This is a simple value class used between core streaming and higher level databinding to pass information about type ids to write. Properties are exposed and mutable on purpose: they are only used for communication over serialization of a single value, and neither retained across calls nor shared between threads.

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.

Since:
  2.9

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static 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.

## Field Summary

Fields
Modifier and Type
Field
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 Summary

Constructors
Constructor
Description
`WritableTypeId()`
`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(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).
`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).

## Method Summary

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### forValue

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

public 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.

### id

public Object id
Actual type id to use: usually {link java.lang.String}.

### asProperty

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`.

### include

public 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]).

### valueShape

public 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. 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.

### wrapperWritten

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.

### extra

public Object extra
Optional additional information that generator may add during "prefix write", to be available on matching "suffix write".

## Constructor Details

### WritableTypeId

public WritableTypeId()

### WritableTypeId

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.

Parameters:
  `value` - Actual value for which type information is written
  `valueShape` - Serialize shape writer will use for value

### WritableTypeId

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).

Parameters:
  `value` - Actual value for which type information is written
  `valueType` - Effective type of `value` to use for Type Id generation
  `valueShape` - Serialize shape writer will use for value

### WritableTypeId

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).

Parameters:
  `value` - Actual value for which type information is written
  `valueShape` - Serialize shape writer will use for value
  `id` - Actual type id to use if known; `null` if not