Class SchemaContext

java.lang.Object
com.hypixel.hytale.codec.schema.SchemaContext

public class SchemaContext extends Object
A context used to assist building schema from codecs.
  • Constructor Details

    • SchemaContext

      public SchemaContext()
      Default Constructor for a SchemaContext instance.
  • Method Details

    • addFileReference

      public void addFileReference(@Nonnull String fileName, @Nonnull SchemaConvertable<?> codec)
      Adds a file reference to the context.

      A file reference is a codec that is stored in a external file and should be accessed by a reference.

      Parameters:
      fileName - The filename to access this by.
      codec - The codec.
    • getFileReference

      @Nullable public Schema getFileReference(@Nonnull SchemaConvertable<?> codec)
      Returns a schema referencing the codec or null if this codec isn't stored in its own file.
      Parameters:
      codec - The codec to get.
      Returns:
      The schema ref or null.
    • refDefinition

      @Nonnull public Schema refDefinition(@Nonnull SchemaConvertable<?> codec)
      Returns a reference to the passed codec if it's a builder codec, creating the schema if needed. Otherwise, just returns the schema for the codec.
      Parameters:
      codec - The codec to ref.
      Returns:
      The schema or schema ref.
    • refDefinition

      @Nonnull public <T> Schema refDefinition(@Nonnull SchemaConvertable<T> convertable, @Nullable T def)
      Returns a reference to the passed codec if it's a builder codec, creating the schema if needed. Otherwise, just returns the schema for the codec.
      Type Parameters:
      T - The type of the codec.
      Parameters:
      convertable - The codec to ref.
      def - The default value.
      Returns:
      The schema or schema ref.
    • getRawDefinition

      @Nullable public Schema getRawDefinition(@Nonnull BuilderCodec<?> codec)
      Gets the raw schema definition for the passed codec.
      Parameters:
      codec - The codec.
      Returns:
      the raw schema, or null if the codec is not a BuilderCodec.
    • getRawDefinition

      @Nullable public Schema getRawDefinition(@Nonnull RecordCodec<?> codec)
    • getRawDefinition

      @Nullable public Schema getRawDefinition(@Nonnull NamedSchema namedSchema)
      Gets the raw schema definition for the passed named schema.
      Parameters:
      namedSchema - The named schema.
      Returns:
      the raw schema definition, or null if the named schema is not registered.
    • getDefinitions

      @Nonnull public Map<String,Schema> getDefinitions()
      Returns:
      the map of definitions that will be saved in common.json.
    • getOtherDefinitions

      @Nonnull public Map<String,Schema> getOtherDefinitions()
      Returns:
      the map of definitions that will be saved in other.json.