Package dev.drtheo.autojson.schema.base
Interface ArraySchema<T,Intermediary>
- Type Parameters:
T- the type this schema serializes.Intermediary- the intermediary type used for collecting the elements.
- All Superinterfaces:
Schema<T>
- All Known Subinterfaces:
ArraySchema.Simple<T>
- All Known Implementing Classes:
JavaArraySchema,JavaListSchema,JavaSetSchema
One of the base implementations of the
Schema class.
Used for serializing into an array format (indexed values).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA utility class that implementsArraySchemawithout an intermediary value. -
Method Summary
Modifier and TypeMethodDescription<To> Intermediarydeserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx, Intermediary o, int index) pack(Intermediary obj) Converts theArraySchematype into the builtArraySchematype.<To> voidserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext.Array ctx, T t) default <To> JsonSerializationContext.Builtserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T t) default bytetype()The type of the schema.Methods inherited from interface dev.drtheo.autojson.schema.base.Schema
asArray, asObject, asPrimitive, asWrapper
-
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 values in ascending order (fromarr[0]toarr[N]).t- the object you're serializing.
-
instantiate
Intermediary instantiate()- Returns:
- a new instance of the
ArraySchematype.
-
pack
Converts theArraySchematype into the builtArraySchematype.- Parameters:
obj- theArraySchemaobject.- Returns:
- the built
ArraySchemaobject.
-
type
default byte 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> Intermediary deserialize(JsonAdapter<Object, To> adapter, JsonDeserializationContext ctx, Intermediary o, int index) - 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.o- the object you're deserializing the data into.index- the index of the element, maintaining the order used for serialization inserialize(JsonAdapter, JsonSerializationContext.Array, Object).- Returns:
- the new
ArraySchemavalue.
-