java.lang.Object
de.Keyle.MyPet.api.util.configuration.settings.Settings

public class Settings extends Object
Parsed key=value bag from a Requirement or LeashFlag string like "MinHealth:min=20:max=50". Typed accessors do the parsing so callers never touch raw strings or write their own try/catch.

The parser distinguishes two token shapes:

  • Constructor Details

    • Settings

      public Settings(String flagName)
      Creates an empty bag for the named flag or requirement. Call load(String) to populate it.
      Parameters:
      flagName - the flag or requirement these settings belong to
  • Method Details

    • getName

      public String getName()
      Returns the flag or requirement these settings belong to.
      Returns:
      the name passed to the constructor
    • load

      public void load(String settingsString)
      Parse a settings string (everything after the leading flag name and its first colon — e.g. "min=20:max=50" or "50%"). Tokens of the form k=v become keyed entries; tokens without = become positional entries.
      Parameters:
      settingsString - the colon-separated token list
    • contains

      public boolean contains(String key)
      Reports whether a k=v entry exists for key, case-insensitively.
      Parameters:
      key - the key to look for
      Returns:
      true if a keyed entry exists
    • get

      public Optional<Setting> get(String key)
      Looks up the k=v entry for key, case-insensitively.
      Parameters:
      key - the key to look for
      Returns:
      the entry, or empty if there is none
    • getInt

      public OptionalInt getInt(String key)
      Parses the value of key=v as an int.
      Parameters:
      key - the key to read
      Returns:
      the parsed value, or empty if absent or unparseable
    • getDouble

      public OptionalDouble getDouble(String key)
      Parses the value of key=v as a double.
      Parameters:
      key - the key to read
      Returns:
      the parsed value, or empty if absent or unparseable
    • getBoolean

      public Optional<Boolean> getBoolean(String key)
      Parses the value of key=v as a boolean, accepting only "true" and "false".
      Parameters:
      key - the key to read
      Returns:
      the parsed value, or empty if absent or anything else
    • getString

      public Optional<String> getString(String key)
      Returns the raw string value of key=v.
      Parameters:
      key - the key to read
      Returns:
      the value, or empty if the key is absent
    • entries

      public List<Setting> entries()
      Unmodifiable view of every parsed entry in input order, including positional tokens. Use this when the parsing logic doesn't fit a single keyed lookup (positional values, suffix detection, multi-value iteration).
      Returns:
      every parsed entry, in input order