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>
All Known Implementing Classes:
AbstractMapSchema, BakedClassAutoSchema, JavaArraySchema, JavaEnumSchema, JavaListSchema, JavaMapSchema, JavaSetSchema, String2ObjectMapSchema, UUIDSchema

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

    • asArray

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

      default ObjectSchema<T> asObject()
    • asPrimitive

      default PrimitiveSchema<T> asPrimitive()
    • type

      SchemaType 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).