Interface ConfigurationReference<N extends ConfigurationNode>
- Type Parameters:
- N- the type of node to work with
- All Superinterfaces:
- AutoCloseable
- Since:
- 4.0.0
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresenting the phase where an error occurred.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()errors()A stream that will receive errors that occur while loading or saving to this reference.static <N extends ScopedConfigurationNode<N>>
 ConfigurationReference<N>fixed(ConfigurationLoader<? extends N> loader) Create a new configuration reference that will only update when loaded.Get the node at the given path, relative to the root node.Get the node at the given path, relative to the root node.voidload()Reload a configuration using the provided loader.ConfigurationLoader<? extends N>loader()Get the loader this reference uses to load and save its node.node()Get the base node this reference refers to.default <T> ValueReference<T,N> referenceTo(io.leangen.geantyref.TypeToken<T> type, Object... path) Create a reference to the node at the provided path.default <T> ValueReference<T,N> referenceTo(io.leangen.geantyref.TypeToken<T> type, NodePath path) Create a reference to the node at the provided path.<T> ValueReference<T,N> referenceTo(io.leangen.geantyref.TypeToken<T> type, NodePath path, @Nullable T defaultValue) Create a reference to the node at the provided path.default <T> ValueReference<T,N> referenceTo(Class<T> type, Object... path) Create a reference to the node at the provided path.default <T> ValueReference<T,N> referenceTo(Class<T> type, NodePath path) Create a reference to the node at the provided path.<T> ValueReference<T,N> referenceTo(Class<T> type, NodePath path, @Nullable T defaultValue) Create a reference to the node at the provided path.voidsave()Save this configuration using the provided loader.voidsave(ConfigurationNode newNode) Update the configuration node pointed to by this reference, and save it using the reference's loader.Save this configuration using the provided loader.default voidUpdate the value of the node at the given path, using the root node as a base.default <T> voidSet the value of the node atpathto the given value.default <T> voidSet the value of the node atpathto the given value.default voidUpdate the value of the node at the given path, using the root node as a base.default <T> voidSet the value of the node atpathto the given value.default <T> voidSet the value of the node atpathto the given value.updateAsync(Function<N, ? extends N> updater) Update this configuration using the provided function, returning aPublisherwhich will complete with the result of the operation.updates()Access thePublisherthat will broadcast update events, providing the newly created node.static <T extends ScopedConfigurationNode<T>>
 ConfigurationReference<T>watching(Function<Path, ConfigurationLoader<? extends T>> loaderCreator, Path file, WatchServiceListener listener) Create a new configuration reference that will automatically update when triggered by the providedWatchServiceListener.
- 
Method Details- 
fixedstatic <N extends ScopedConfigurationNode<N>> ConfigurationReference<N> fixed(ConfigurationLoader<? extends N> loader) throws ConfigurateException Create a new configuration reference that will only update when loaded.- Type Parameters:
- N- the type of node
- Parameters:
- loader- the loader to load and save from
- Returns:
- the newly created reference, with an initial load performed
- Throws:
- ConfigurateException- if the configuration contained fails to load
- Since:
- 4.0.0
 
- 
watchingstatic <T extends ScopedConfigurationNode<T>> ConfigurationReference<T> watching(Function<Path, ConfigurationLoader<? extends T>> loaderCreator, Path file, WatchServiceListener listener) throws ConfigurateExceptionCreate a new configuration reference that will automatically update when triggered by the providedWatchServiceListener.- Type Parameters:
- T- the node type
- Parameters:
- loaderCreator- a function that can create a- ConfigurationLoader
- file- the file to load this configuration from
- listener- the watch service listener that will receive events
- Returns:
- the created reference
- Throws:
- ConfigurateException- if the underlying loader fails to load a configuration
- Since:
- 4.0.0
- See Also:
 
- 
loadReload a configuration using the provided loader.If the load fails, this reference will continue pointing to old configuration values. - Throws:
- ConfigurateException- when an error occurs
- Since:
- 4.0.0
 
- 
saveSave this configuration using the provided loader.- Throws:
- ConfigurateException- when an error occurs in the underlying IO
- Since:
- 4.0.0
 
- 
saveUpdate the configuration node pointed to by this reference, and save it using the reference's loader.Even if the loader fails to save this new node, the node pointed to by this reference will be updated. - Parameters:
- newNode- the new node to save
- Throws:
- ConfigurateException- when an error occurs within the loader
- Since:
- 4.0.0
 
- 
saveAsyncSave this configuration using the provided loader. Any errors will be submitted to subscribers of the returned publisher.- Returns:
- publisher providing an event when the save is complete
- Since:
- 4.0.0
 
- 
updateAsyncUpdate this configuration using the provided function, returning aPublisherwhich will complete with the result of the operation. The update function will be called asynchronously, and will be saved to this reference's loader when complete.- Parameters:
- updater- update function
- Returns:
- publisher providing an event when the update is complete
- Since:
- 4.0.0
 
- 
nodeGet the base node this reference refers to.- Returns:
- the node
- Since:
- 4.0.0
 
- 
loaderConfigurationLoader<? extends N> loader()Get the loader this reference uses to load and save its node.- Returns:
- the loader
- Since:
- 4.0.0
 
- 
getGet the node at the given path, relative to the root node.- Parameters:
- path- the path, a series of path elements
- Returns:
- a child node
- Since:
- 4.0.0
- See Also:
 
- 
getGet the node at the given path, relative to the root node.- Parameters:
- path- the path, a series of path elements
- Returns:
- a child node
- Since:
- 4.0.0
- See Also:
 
- 
setUpdate the value of the node at the given path, using the root node as a base.- Parameters:
- path- the path to get the child at
- value- the value to set the child node to
- Throws:
- SerializationException- when unable to write the provided value
- Since:
- 4.0.0
 
- 
setSet the value of the node atpathto the given value.This uses the appropriate TypeSerializerto serialize the data if it's not directly supported by the provided configuration.- Type Parameters:
- T- the type parameter for the value
- Parameters:
- path- the path to set the value at
- type- the type of data to serialize
- value- the value to set
- Throws:
- IllegalArgumentException- if a raw type is provided
- SerializationException- if thrown by the serialization mechanism
- Since:
- 4.0.0
 
- 
setdefault <T> void set(Object[] path, io.leangen.geantyref.TypeToken<T> type, @Nullable T value) throws SerializationException Set the value of the node atpathto the given value.This uses the appropriate TypeSerializerto serialize the data if it's not directly supported by the provided configuration.- Type Parameters:
- T- the type parameter for the value
- Parameters:
- path- the path to set the value at
- type- the type of data to serialize
- value- the value to set
- Throws:
- SerializationException- if thrown by the serialization mechanism
- Since:
- 4.0.0
 
- 
setUpdate the value of the node at the given path, using the root node as a base.- Parameters:
- path- the path to get the child at
- value- the value to set the child node to
- Throws:
- SerializationException
- Since:
- 4.0.0
 
- 
setSet the value of the node atpathto the given value.This uses the appropriate TypeSerializerto serialize the data if it's not directly supported by the provided configuration.- Type Parameters:
- T- the type parameter for the value
- Parameters:
- path- the path to set the value at
- type- the type of data to serialize
- value- the value to set
- Throws:
- SerializationException- if thrown by the serialization mechanism
- Since:
- 4.0.0
 
- 
setdefault <T> void set(NodePath path, io.leangen.geantyref.TypeToken<T> type, @Nullable T value) throws SerializationException Set the value of the node atpathto the given value.This uses the appropriate TypeSerializerto serialize the data if it's not directly supported by the provided configuration.- Type Parameters:
- T- the type parameter for the value
- Parameters:
- path- the path to set the value at
- type- the type of data to serialize
- value- the value to set
- Throws:
- SerializationException- if thrown by the serialization mechanism
- Since:
- 4.0.0
 
- 
referenceTodefault <T> ValueReference<T,N> referenceTo(io.leangen.geantyref.TypeToken<T> type, Object... path) throws SerializationException Create a reference to the node at the provided path. The value will be deserialized according to the provided TypeToken.The returned reference will update with reloads of and changes to the value of the provided configuration. Any serialization errors encountered will be submitted to the errors()stream.- Type Parameters:
- T- the value type
- Parameters:
- type- the value's type
- path- the path from the root node to the node containing the value
- Returns:
- a deserializing reference to the node at the given path
- Throws:
- SerializationException- if a type serializer could not be found for the provided type
- Since:
- 4.0.0
 
- 
referenceTodefault <T> ValueReference<T,N> referenceTo(Class<T> type, Object... path) throws SerializationException Create a reference to the node at the provided path. The value will be deserialized according to type of the providedClass.The returned reference will update with reloads of and changes to the value of the provided configuration. Any serialization errors encountered will be submitted to the errors()stream.- Type Parameters:
- T- the value type
- Parameters:
- type- the value's type
- path- the path from the root node to the node containing the value
- Returns:
- a deserializing reference to the node at the given path
- Throws:
- SerializationException- if a type serializer could not be found for the provided type
- Since:
- 4.0.0
 
- 
referenceTodefault <T> ValueReference<T,N> referenceTo(io.leangen.geantyref.TypeToken<T> type, NodePath path) throws SerializationException Create a reference to the node at the provided path. The value will be deserialized according to the providedTypeToken.The returned reference will update with reloads of and changes to the value of the provided configuration. Any serialization errors encountered will be submitted to the errors()stream.- Type Parameters:
- T- the value type
- Parameters:
- type- the value's type
- path- the path from the root node to the node containing the value
- Returns:
- a deserializing reference to the node at the given path
- Throws:
- SerializationException- if a type serializer could not be found for the provided type
- Since:
- 4.0.0
 
- 
referenceTodefault <T> ValueReference<T,N> referenceTo(Class<T> type, NodePath path) throws SerializationException Create a reference to the node at the provided path. The value will be deserialized according to type of the providedClass.The returned reference will update with reloads of and changes to the value of the provided configuration. Any serialization errors encountered will be submitted to the errors()stream.- Type Parameters:
- T- the value type
- Parameters:
- type- the value's type
- path- the path from the root node to the node containing the value
- Returns:
- a deserializing reference to the node at the given path
- Throws:
- SerializationException- if a type serializer could not be found for the provided type
- Since:
- 4.0.0
 
- 
referenceTo<T> ValueReference<T,N> referenceTo(io.leangen.geantyref.TypeToken<T> type, NodePath path, @Nullable T defaultValue) throws SerializationException Create a reference to the node at the provided path. The value will be deserialized according to the providedTypeToken.The returned reference will update with reloads of and changes to the value of the provided configuration. Any serialization errors encountered will be submitted to the errors()stream.- Type Parameters:
- T- the value type
- Parameters:
- type- the value's type.
- path- the path from the root node to the node containing the value
- defaultValue- the value to use when there is no data present in the targeted node.
- Returns:
- a deserializing reference to the node at the given path
- Throws:
- SerializationException- if a type serializer could not be found for the provided type
- Since:
- 4.0.0
 
- 
referenceTo<T> ValueReference<T,N> referenceTo(Class<T> type, NodePath path, @Nullable T defaultValue) throws SerializationException Create a reference to the node at the provided path. The value will be deserialized according to type of the providedClass.The returned reference will update with reloads of and changes to the value of the provided configuration. Any serialization errors encountered will be submitted to the errors()stream.- Type Parameters:
- T- value type
- Parameters:
- type- value's type
- path- path from the root node to the node containing the value
- defaultValue- value to use when there is no data present in the targeted node.
- Returns:
- a deserializing reference to the node at the given path
- Throws:
- SerializationException- if a type serializer could not be found for the provided type
- Since:
- 4.0.0
 
- 
updatesAccess thePublisherthat will broadcast update events, providing the newly created node. The returned publisher will be transaction-aware, i.e. anyTransactionalSubscriberattached will progress through their phases appropriately- Returns:
- the publisher
- Since:
- 4.0.0
 
- 
errorsA stream that will receive errors that occur while loading or saving to this reference.- Returns:
- the publisher
- Since:
- 4.0.0
 
- 
closevoid close()- Specified by:
- closein interface- AutoCloseable
 
 
-