Interface ObjectSchema<T>

Type Parameters:
T - the type this schema serializes.
All Superinterfaces:
Schema<T>
All Known Implementing Classes:
AbstractMapSchema, BakedClassAutoSchema, JavaMapSchema, String2ObjectMapSchema

public non-sealed interface ObjectSchema<T> extends Schema<T>
One of the base implementations of the Schema class. Used for serializing into an object format (key-value pairs).
  • Method Details

    • serialize

      <To> void serialize(JsonAdapter<Object,To> adapter, JsonSerializationContext.Obj ctx, T t)
      Type Parameters:
      To - the type the adapter serializes to.
      Parameters:
      adapter - the adapter used to serialize this object.
      ctx - the serialization context. Used to provide the key-value pairs.
      t - the object you're serializing.
    • instantiate

      T instantiate()
      Returns:
      A new instance of the object this schema serializes.
    • type

      default byte type()
      Description copied from interface: Schema
      The type of the schema.
      Instead of doing if-instanceof checks for the schema implementations, the adapters should use the SchemaType with a switch statement instead.
      Specified by:
      type in interface Schema<T>
      Returns:
      the type of this schema.
    • serialize

      default <To> JsonSerializationContext.Built serialize(JsonAdapter<Object,To> adapter, JsonSerializationContext ctx, T t)
      Specified by:
      serialize in interface Schema<T>
    • deserialize

      <To> void deserialize(JsonAdapter<Object,To> adapter, JsonDeserializationContext ctx, T t, String field)
      Type Parameters:
      To - the type the adapter serializes to.
      Parameters:
      adapter - the adapter used to deserialize this object.
      ctx - the deserialization context. Used to query the deserialization.
      t - the object you're deserializing the data into.
      field - the name of the field you're deserializing.