Package dev.drtheo.autojson.schema.base
Interface ObjectSchema<T>
- Type Parameters:
T- the type this schema serializes.
- All Superinterfaces:
Schema<T>
- All Known Implementing Classes:
AbstractMapSchema,BakedClassAutoSchema,JavaMapSchema,String2ObjectMapSchema
One of the base implementations of the
Schema class.
Used for serializing into an object format (key-value pairs).-
Method Summary
Modifier and TypeMethodDescription<To> voiddeserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx, T t, String field) <To> voidserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Obj ctx, T t) default <To> JsonSerializationContext.Builtserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T t) default SchemaTypetype()The type of the schema.Methods inherited from interface dev.drtheo.autojson.schema.base.Schema
asArray, asObject, asPrimitive
-
Method Details
-
serialize
- 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
Description copied from interface:SchemaThe type of the schema.
Instead of doing if-instanceof checks for the schema implementations, the adapters should use theSchemaTypewith a switch statement instead. -
serialize
default <To> JsonSerializationContext.Built serialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T 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.
-