Package dev.drtheo.autojson.schema.base
Interface PrimitiveSchema<T>
- Type Parameters:
T- the type this schema serializes.
- All Superinterfaces:
Schema<T>
- All Known Subinterfaces:
StringSchema<T>
- All Known Implementing Classes:
JavaEnumSchema,UUIDSchema
One of the base implementations of the
Schema class.
Used for serializing into a primitive (number, character, boolean, string).-
Method Summary
Modifier and TypeMethodDescription<To> Tdeserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx) <To> voidserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Primitive 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 value.t- the object you're serializing.
-
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
- 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.
-