Class Config.Value<T>

java.lang.Object
com.github.darksoulq.abyssallib.common.config.Config.Value<T>
Type Parameters:
T - The type of the value.
Enclosing class:
Config

public class Config.Value<T> extends Object
Represents a specific value within the configuration. Provides methods to get and set data with optional Codec support.
  • Constructor Details

    • Value

      public Value(String path, T defaultValue, Codec<T> codec)
      Constructs a new Config Value.
      Parameters:
      path - The YAML path.
      defaultValue - The fallback value.
      codec - The codec (can be null for primitives).
  • Method Details

    • get

      public T get()
      Retrieves the value from the configuration.
      Returns:
      The stored value, or the default if not present.
      Throws:
      RuntimeException - If a Codec.CodecException occurs during decoding.
    • set

      public void set(T value)
      Sets the value in the configuration. If a codec is present, it will be used to encode the value into a YAML-compatible format.
      Parameters:
      value - The value to store.
      Throws:
      RuntimeException - If a Codec.CodecException occurs during encoding.
    • withComment

      public Config.Value<T> withComment(String... comments)
      Adds a comment to this specific value's path.
      Parameters:
      comments - The lines of the comment.
      Returns:
      This Config.Value instance for chaining.