Serializer

interface Serializer<T extends Object>

Known direct subclasses
LayoutProtoSerializer

Serializes the proto for use with DataStore.


The serializer determines the on-disk format and API for accessing it.

The type T MUST be immutable. Mutable types will result in broken DataStore functionality.

TODO(b/151635324): consider changing InputStream to File.

Summary

Public fields

abstract @NonNull T

Value to return if there is no data on disk.

Public methods

abstract @NonNull T

Unmarshal object from stream.

abstract void
writeTo(T t, OutputStream output)

Marshal object to a stream.

Public fields

defaultValue

abstract @NonNulldefaultValue

Value to return if there is no data on disk.

Public methods

readFrom

abstract @NonNullreadFrom(InputStream input)

Unmarshal object from stream.

Parameters
InputStream input

the InputStream with the data to deserialize

writeTo

abstract void writeTo(T t, OutputStream output)

Marshal object to a stream. Closing the provided OutputStream is a no-op.

Parameters
T t

the data to write to output