Package dev.drtheo.autojson.schema.base
Interface Schema
-
- All Implemented Interfaces:
public interface Schema<T>The base schema class. You should probably implement ObjectSchema, ArraySchema, PrimitiveSchema, WrapperSchema or one of their derivatives instead.
-
-
Method Summary
Modifier and Type Method Description <S> ArraySchema<S, out Object>asArray()<S> ObjectSchema<S>asObject()<S> PrimitiveSchema<S>asPrimitive()<S> WrapperSchema<S, out Object>asWrapper()abstract bytetype()The type of the schema. abstract <To> JsonSerializationContext.Builtserialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T t)static <T> TcreateInstance(Class<out T> clazz, boolean safe)Creates a new class of T.-
-
Method Detail
-
asArray
<S> ArraySchema<S, out Object> asArray()
-
asObject
<S> ObjectSchema<S> asObject()
-
asPrimitive
<S> PrimitiveSchema<S> asPrimitive()
-
asWrapper
<S> WrapperSchema<S, out Object> asWrapper()
-
type
abstract 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
abstract <To> JsonSerializationContext.Built serialize(JsonAdapter<Object, To> adapter, JsonSerializationContext ctx, T t)
-
createInstance
static <T> T createInstance(Class<out T> clazz, boolean safe)
Creates a new class of
T.- Parameters:
clazz- the class you want to instantiate.safe- whether to use a safe or fast method.- Returns:
A new instance of the specified class.
-
-
-
-