Class Setting
java.lang.Object
de.Keyle.MyPet.api.util.configuration.settings.Setting
One token parsed out of a
Settings string. Either a keyed entry
(e.g. "min=20" — key "min", value "20") or a
positional entry (e.g. "50%" — key "50%", value absent).
Prefer the typed accessors (getInt(), getDouble(),
getBoolean()). asString() is kept as an escape hatch for
values that carry custom syntax the typed accessors don't model (e.g. a
% suffix).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()Raw string content of this entry.ParsesasString()as a boolean.ParsesasString()as a double.getInt()ParsesasString()as an int.getKey()Original-case key.
-
Constructor Details
-
Setting
Creates a positional entry, one with no=in it.- Parameters:
key- the whole token
-
Setting
Creates a keyed entry parsed fromk=v.- Parameters:
key- the left-hand sidevalue- the right-hand side
-
-
Method Details
-
getKey
Original-case key. For a keyed entry this is the LHS ofk=v; for a positional entry this is the whole token.- Returns:
- the key, in its original casing
-
asString
Raw string content of this entry. For a keyed entry returns the value; for a positional entry returns the key. Use this when the typed accessors don't fit (custom syntax, suffix detection, etc.).- Returns:
- the entry's string content
-
getInt
ParsesasString()as an int.- Returns:
- the parsed value, or empty if it does not parse
-
getDouble
ParsesasString()as a double.- Returns:
- the parsed value, or empty if it does not parse
-
getBoolean
- Returns:
- the parsed value, or empty for anything else
-