Class ObjectProperty<T>

java.lang.Object
net.darkhax.pricklemc.common.api.config.property.ObjectProperty<T>
All Implemented Interfaces:
IConfigProperty<T>
Direct Known Subclasses:
AbstractArrayProperty, CodecProperty, ConfigObjectProperty, RangedProperty, RegexStringProperty

public class ObjectProperty<T> extends Object implements IConfigProperty<T>
  • Field Details

    • FALLBACK_ADAPTER

      public static final IPropertyAdapter<ObjectProperty<?>> FALLBACK_ADAPTER
      The property adapter that is used when a field does not have an explicit property adapter.
  • Constructor Details

  • Method Details

    • comment

      public IComment comment()
      Gets the comment for the property.
      Returns:
      The comment for the property.
    • defaultValue

      public T defaultValue()
      Gets the default value for the property. This is generally the value that the field was initialized with.
      Returns:
      The default value for the property.
    • writeDefaultValue

      public boolean writeDefaultValue()
      Checks if the default value should be written as a decorator.
      Returns:
      Should the default value be written?
    • value

      public T value()
      Gets the current value of the property.
      Specified by:
      value in interface IConfigProperty<T>
      Returns:
      The current value of the property.
    • read

      public void read(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Description copied from interface: IConfigProperty
      Reads the value from the JSON and applies it to the parent object.
      Specified by:
      read in interface IConfigProperty<T>
      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

      public void write(com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Description copied from interface: IConfigProperty
      Writes the value to the JSON writer.
      Specified by:
      write in interface IConfigProperty<T>
      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.
    • writeValue

      public void writeValue(T value, com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Writes a value to the JSON writer.
      Parameters:
      value - The value to be written.
      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 - A fatal exception may be thrown if the value could not be written.
    • readValue

      public T readValue(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Reads a value from the JSON reader.
      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.
      Returns:
      The value that was read from the reader.
      Throws:
      IOException - A fatal exception may be thrown if the value could not be read.
    • writeDefaultValue

      public void writeDefaultValue(com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Handles writing the default 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 - A fatal exception may be thrown if the value could not be written.
    • writeAdditionalComments

      public void writeAdditionalComments(com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Writes additional decorators 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 - A fatal exception may be thrown if the decorators could not be written.
    • validate

      public boolean validate(T value) throws IllegalArgumentException
      Description copied from interface: IConfigProperty
      Validates if a value is valid for the property.
      Specified by:
      validate in interface IConfigProperty<T>
      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.