Package dev.drtheo.autojson.schema.base
Interface PrimitiveSchema
-
- All Implemented Interfaces:
-
dev.drtheo.autojson.schema.base.Schema
public interface PrimitiveSchema<T> implements Schema<T>
One of the base implementations of the Schema class. Used for serializing into a primitive (number, character, boolean, string).
-
-
Method Summary
Modifier and Type Method Description abstract <To> voidserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Primitive ctx, T t)bytetype()The type of the schema. <To> JsonSerializationContext.Builtserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T t)abstract <To> Tdeserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx)-
-
Method Detail
-
serialize
abstract <To> void serialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Primitive ctx, T t)
- Parameters:
adapter- the adapter used to serialize this object.ctx- the serialization context.t- the object you're serializing.
-
type
byte type()
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.
- Returns:
the type of this schema.
-
serialize
<To> JsonSerializationContext.Built serialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T t)
-
deserialize
abstract <To> T deserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx)
- Parameters:
adapter- the adapter used to deserialize this object.ctx- the deserialization context.- Returns:
The deserialized object.
-
-
-
-