Interface Schema<T>

Type Parameters:
T - the type this schema serializes.
All Known Subinterfaces:
ArraySchema<T,Intermediary>, ArraySchema.Simple<T>, ObjectSchema<T>, PrimitiveSchema<T>, StringSchema<T>, WrapperSchema<T,B>
All Known Implementing Classes:
AbstractMapSchema, BakedClassAutoSchema, JavaArraySchema, JavaEnumSchemaFastMap, JavaEnumSchemaSimple, JavaListSchema, JavaMapSchema, JavaSetSchema, String2ObjectMapSchema, UUIDSchema

public sealed interface Schema<T> permits ArraySchema<T,Intermediary>, ObjectSchema<T>, PrimitiveSchema<T>, WrapperSchema<T,B>
The base schema class.
You should probably implement ObjectSchema, ArraySchema, PrimitiveSchema, WrapperSchema or one of their derivatives instead.
  • Method Details

    • asArray

      default <S> ArraySchema<S,?> asArray()
    • asObject

      default <S> ObjectSchema<S> asObject()
    • asPrimitive

      default <S> PrimitiveSchema<S> asPrimitive()
    • asWrapper

      default <S> WrapperSchema<S,?> asWrapper()
    • type

      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

    • createInstance

      static <T> T createInstance(Class<? extends T> clazz, boolean safe)
      Creates a new class of T.
      Type Parameters:
      T - the type of the class you want to instantiate.
      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.
      Implementation Note:
      When using the safe method, it will create a new instance by invoking the constructor via reflections. Otherwise, it will allocate a new instance using Unsafe, which is faster, but won't call the constructor, meaning that all fields will get their default values (0 for numbers, false for booleans and null for objects).