Class JavaArraySchema<T,E>
java.lang.Object
dev.drtheo.autojson.schema.template.JavaArraySchema<T,E>
- Type Parameters:
T- the array type, e.g.int[].E- the element type, e.g.Integerforints.
- All Implemented Interfaces:
ArraySchema<T,,List<E>> Schema<T>
- Implementation Note:
- Uses reflections to create a new array instance and a
ArrayListto store the values temporary. Consider using your ownArraySchemafor your own
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.drtheo.autojson.schema.base.ArraySchema
ArraySchema.Simple<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(JsonAdapter<Object, To> auto, JsonDeserializationContext c, List<E> ts, int index) Converts theArraySchematype into the builtArraySchematype.<To> voidserialize(JsonAdapter<Object, To> auto, JsonSerializationContext.Array c, T ts) static <T,E> JavaArraySchema<T, E> unwrap(SchemaHolder holder, Class<T> clazz) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.drtheo.autojson.schema.base.ArraySchema
serialize, typeMethods inherited from interface dev.drtheo.autojson.schema.base.Schema
asArray, asObject, asPrimitive
-
Constructor Details
-
JavaArraySchema
-
-
Method Details
-
unwrap
-
serialize
- Specified by:
serializein interfaceArraySchema<T,E> - Type Parameters:
To- the type the adapter serializes to.- Parameters:
auto- the adapter used to serialize this object.c- the serialization context. Used to provide the values in ascending order (fromarr[0]toarr[N]).ts- the object you're serializing.
-
instantiate
- Specified by:
instantiatein interfaceArraySchema<T,E> - Returns:
- a new instance of the
ArraySchematype.
-
deserialize
public <To> List<E> deserialize(JsonAdapter<Object, To> auto, JsonDeserializationContext c, List<E> ts, int index) - Specified by:
deserializein interfaceArraySchema<T,E> - Type Parameters:
To- the type the adapter serializes to.- Parameters:
auto- the adapter used to deserialize this object.c- the deserialization context. Used to query the deserialization.ts- the object you're deserializing the data into.index- the index of the element, maintaining the order used for serialization inArraySchema.serialize(JsonAdapter, JsonSerializationContext.Array, Object).- Returns:
- the new
ArraySchemavalue.
-
pack
Description copied from interface:ArraySchemaConverts theArraySchematype into the builtArraySchematype.- Specified by:
packin interfaceArraySchema<T,E> - Parameters:
l- theArraySchemaobject.- Returns:
- the built
ArraySchemaobject.
-