T - The type of value this class holdspublic interface ConfigLeaf<T> extends ConfigNode, Property<T>, Commentable
ConfigNode with some value of type T.ConfigNodeImpl,
ConfigLeafBuilder,
ConfigAggregateBuilder| Modifier and Type | Method and Description |
|---|---|
default boolean |
accepts(T value)
Returns
true if this property can be set to the given value. |
java.util.List<Constraint<? super T>> |
getConstraints()
Returns the list of constraints for this item.
|
T |
getDefaultValue()
Returns the default value for this item.
|
java.util.function.BiConsumer<T,T> |
getListener()
Returns the listener for this item.
|
java.lang.Class<T> |
getType()
Returns a class object representing the type of values this node can hold.
|
T |
getValue()
Returns this
ConfigLeaf's current value. |
boolean |
setValue(T value)
Sets the value held by this
ConfigLeaf. |
getNamegetCommentboolean setValue(T value)
ConfigLeaf.
If the value does not satisfy this setting's constraints,
the current value is not updated and the method returns false.
setValue in interface Property<T>value - the new value this ConfigLeaf should holdtrue if this property changed as a result of the call, and false otherwise.accepts(Object)T getValue()
ConfigLeaf's current value.
If no successful call to setValue(Object) has been made,
this method returns this node's default value.
java.lang.Class<T> getType()
The returned class object can be used for various runtime type checks, as well as constraint configuration.
default boolean accepts(T value)
true if this property can be set to the given value.
A value is accepted if it satisfies every constraint
this setting has. Note that some constraints such as FinalConstraint
will cause even the current value to be rejected.
accepts in interface Property<T>value - the value to checktrue if this property accepts the given value, false otherwise.setValue(Object),
getConstraints()@Nonnull java.util.function.BiConsumer<T,T> getListener()
When this item's value changes, the consumer will be called with the old value as first argument and the new value as second argument.
@Nullable T getDefaultValue()
@Nonnull java.util.List<Constraint<? super T>> getConstraints()
For a call to setValue(T) to pass (and such, return true), the value must satisfy all constraints in this list.