Interface PrimitiveSchema<T>

Type Parameters:
T - the type this schema serializes.
All Superinterfaces:
Schema<T>
All Known Subinterfaces:
StringSchema<T>
All Known Implementing Classes:
JavaEnumSchemaFastMap, JavaEnumSchemaSimple, UUIDSchema

public non-sealed interface PrimitiveSchema<T> extends Schema<T>
One of the base implementations of the Schema class. Used for serializing into a primitive (number, character, boolean, string).
  • Method Details

    • serialize

      <To> void serialize(JsonAdapter<Object,To> adapter, JsonSerializationContext.Primitive 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 value.
      t - the object you're serializing.
    • 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> T deserialize(JsonAdapter<Object,To> adapter, JsonDeserializationContext ctx)
      Type Parameters:
      To - whatever the adapter's serializing to.
      Parameters:
      adapter - the adapter used to deserialize this object.
      ctx - the deserialization context. Used to query the deserialization.
      Returns:
      The deserialized object.