CompositeEncoder
CompositeEncoder is a part of encoding process that is bound to a particular structured part of the serialized form, described by the serial descriptor passed to Encoder.beginStructure.
All encode*
methods have index
and serialDescriptor
parameters with a strict semantics and constraints:
descriptor
is always the same as one used in Encoder.beginStructure. While this parameter may seem redundant, it is required for efficient serialization process to avoid excessive field spilling. If you are writing your own format, you can safely ignore this parameter and use one used inbeginStructure
for simplicity.index
of the element being encoded. This element at this index in the descriptor should be associated with the one being written.
The symmetric interface for the deserialization process is CompositeDecoder.
Not stable for inheritance
CompositeEncoder
interface is not stable for inheritance in 3rd party libraries, as new methods might be added to this interface or contracts of the existing methods can be changed.
Inheritors
Properties
Functions
Encodes a boolean value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.BOOLEAN kind.
Encodes a single byte value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.BYTE kind.
Encodes a 16-bit unicode character value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.CHAR kind.
Encodes a 64-bit IEEE 754 floating point value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.DOUBLE kind.
Encodes a 32-bit IEEE 754 floating point value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.FLOAT kind.
Returns Encoder for decoding an underlying type of a value class in an inline manner. Serializable value class is described by the child descriptor of given descriptor at index.
Encodes a 32-bit integer value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.INT kind.
Encodes a 64-bit integer value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.LONG kind.
Delegates nullable value encoding of the type T to the given serializer. value is associated with an element at the given index in serial descriptor.
Delegates value encoding of the type T to the given serializer. value is associated with an element at the given index in serial descriptor.
Encodes a 16-bit short value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.SHORT kind.
Encodes a string value associated with an element at the given index in serial descriptor. The element at the given index should have PrimitiveKind.STRING kind.
Denotes the end of the structure associated with current encoder. For example, composite encoder of JSON format will write a closing bracket in the underlying input and reduce the number of nesting for pretty printing.
Whether the format should encode values that are equal to the default values. This method is used by plugin-generated serializers for properties with default values: