Class RangedProperty<T extends Number>

java.lang.Object
net.darkhax.pricklemc.common.api.config.property.ObjectProperty<T>
net.darkhax.pricklemc.common.api.config.property.RangedProperty<T>
Type Parameters:
T - The type of number.
All Implemented Interfaces:
IConfigProperty<T>

public class RangedProperty<T extends Number> extends ObjectProperty<T>
Represents a number property that can only fall within the specified range.
  • Field Details

    • ADAPTER

      public static final IPropertyAdapter<?> ADAPTER
      The adapter for ranged number properties.
  • Method Details

    • max

      @Nullable public T max()
    • writeAdditionalComments

      public void writeAdditionalComments(com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException
      Description copied from class: ObjectProperty
      Writes additional decorators to the JSON writer.
      Overrides:
      writeAdditionalComments in class ObjectProperty<T extends Number>
      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 extends Number>
      Overrides:
      validate in class ObjectProperty<T extends Number>
      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.