Interface ValueReference<T>
- Type Parameters:
T
- The type of value to return
- All Superinterfaces:
Publisher<T>
public interface ValueReference<T> extends Publisher<T>
A pointer to a node within a configuration tree.
This value will update automatically with changes to the underlying configuration file. Subscribers will be provided the current value upon subscription, followed by any changes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ninja.leaping.configurate.reactive.Publisher
Publisher.Cached<V>
-
Method Summary
Modifier and Type Method Description @Nullable T
get()
Get the current value at this nodeConfigurationNode
getNode()
Get the node this value reference points to.boolean
set(@Nullable T value)
Set the new value of this node.boolean
setAndSave(@Nullable T value)
Set the new value of this node and save the underlying configurationPublisher<Boolean>
setAndSaveAsync(@Nullable T value)
Set the new value of this node and save the underlying configuration asynchronously on the executor of the owningConfigurationReference
boolean
update(Function<@Nullable T,? extends T> action)
Update this value and the underlying node, without saving.Publisher<Boolean>
updateAsync(Function<T,? extends T> action)
Update, performing the action and save on the executor of the owningConfigurationReference
.Methods inherited from interface ninja.leaping.configurate.reactive.Publisher
cache, cache, getExecutor, hasSubscribers, map, subscribe
-
Method Details
-
get
Get the current value at this nodeAny deserialization failures will be submitted to the owning
ConfigurationReference
's error callback- Returns:
- the deserialized value, or null if deserialization fails.
-
set
Set the new value of this node. The configuration won't be saved.Any serialization errors will be provided to the error callback of the owning
ConfigurationReference
- Parameters:
value
- The value- Returns:
- true if successful, false if serialization fails
-
setAndSave
Set the new value of this node and save the underlying configurationAny serialization errors will be provided to the error callback of the owning
ConfigurationReference
- Parameters:
value
- The value- Returns:
- true if successful, false if serialization fails
-
setAndSaveAsync
Set the new value of this node and save the underlying configuration asynchronously on the executor of the owningConfigurationReference
Any serialization errors will be submitted to subscribers of the returned
Publisher
- Parameters:
value
- The value- Returns:
- true if successful, false if serialization fails
-
update
Update this value and the underlying node, without saving.Any serialization errors will be provided to the error callback of the owning
ConfigurationReference
- Parameters:
action
- to transform this node's value- Returns:
- whether this update was successful
-
updateAsync
Update, performing the action and save on the executor of the owningConfigurationReference
. Any errors that occur while saving will be passed along to any subscribers.The updated value will only be exposed if the changes are successful.
- Parameters:
action
- to transform this node's value- Returns:
- whether this update was successful
-
getNode
Get the node this value reference points to.- Returns:
- The node
-