Class ConfigOption<T>
java.lang.Object
dev.prozilla.pine.common.property.VariableProperty<T>
dev.prozilla.pine.common.property.MutableProperty<T>
dev.prozilla.pine.common.property.observable.ObservableProperty<T>
dev.prozilla.pine.core.state.config.ConfigOption<T>
- Type Parameters:
T
- Type of the value of the option
- All Implemented Interfaces:
Destructible
Represents an option of the application's configuration.
- See Also:
-
Field Summary
Fields inherited from class dev.prozilla.pine.common.property.observable.ObservableProperty
logger
Fields inherited from class dev.prozilla.pine.common.property.VariableProperty
random
-
Constructor Summary
ConstructorsConstructorDescriptionConfigOption
(T value) Creates a config option without a validator.ConfigOption
(T value, Predicate<T> validator) Creates a config option with a validator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyFrom
(ConfigOption<T> otherOption) Copies the value of another option to this option.void
copyTo
(ConfigOption<T> otherOption) Copies the value of this option to another option.boolean
isValidValue
(T value) Checks whether a value is a valid value for this option.void
reset()
Resets this option to its initial value.boolean
Sets the value of this option.Methods inherited from class dev.prozilla.pine.common.property.observable.ObservableProperty
addObserver, destroy, getLogger, onValueChange, read, removeObserver, setLogger
Methods inherited from class dev.prozilla.pine.common.property.MutableProperty
getValue
Methods inherited from class dev.prozilla.pine.common.property.VariableProperty
exists, hasValue
-
Constructor Details
-
ConfigOption
Creates a config option without a validator.- Parameters:
value
- Initial value
-
ConfigOption
Creates a config option with a validator.- Parameters:
value
- Initial value- Throws:
IllegalArgumentException
- Ifvalidator
does not evaluate totrue
for the initial value.
-
-
Method Details
-
setValue
Sets the value of this option.- Overrides:
setValue
in classMutableProperty<T>
- Parameters:
value
- New value for this option- Returns:
true
if the value was changed.
-
copyTo
Copies the value of this option to another option. -
copyFrom
Copies the value of another option to this option. -
isValidValue
Checks whether a value is a valid value for this option.- Parameters:
value
- Value to check.- Returns:
- True if the value is valid
-
reset
public void reset()Resets this option to its initial value.
-