Interface IConfigProperty<T>

Type Parameters:
T - The type of data held by the property.
All Known Implementing Classes:
AbstractArrayProperty, ArrayProperty, CodecProperty, CollectionArrayProperty, ConfigObjectProperty, ObjectProperty, RangedProperty, RegexStringProperty

public interface IConfigProperty<T>
Represents a field that has been mapped to a config property. The config property is responsible for serializing, validating, and applying the value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    read(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger)
    Reads the value from the JSON and applies it to the parent object.
    boolean
    validate(T value)
    Validates if a value is valid for the property.
    Gets the value held by the property.
    void
    write(com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger)
    Writes the value to the JSON writer.
  • Method Details

    • value

      T value()
      Gets the value held by the property.
      Returns:
      The value held by the property.
    • read

      void read(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Reads the value from the JSON and applies it to the parent object.
      Parameters:
      reader - A reader containing a stream of JSON data.
      resolver - Resolves properties with GSON or config properties.
      logger - A log instance used to log warnings and errors encountered when the value is read.
      Throws:
      IOException - Fatal errors should be thrown if invalid data is encountered.
    • write

      void write(com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Writes the value to the JSON writer.
      Parameters:
      writer - A writer to write JSON data to.
      resolver - Resolves properties with GSON or config properties.
      logger - A log instance used to log warnings and errors encountered when saving the value.
      Throws:
      IOException - Fatal errors should be thrown if the property can not be written.
    • validate

      boolean validate(T value) throws IllegalArgumentException
      Validates if a value is valid for the property.
      Parameters:
      value - The value to validate.
      Returns:
      If the value is true or not. Invalid properties will not be applied when reading the value from JSON.
      Throws:
      IllegalArgumentException - Generally a fatal exception should be raised when the value is invalid.