Package io.confound.config
Interface ConfigurationManager
-
- All Known Implementing Classes:
AbstractConfigurationManager
public interface ConfigurationManager
A strategy for retrieving and storing configurations.- Author:
- Garret Wilson
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
invalidate()
Invalidates any cached information about the managed configuration.boolean
isRequired()
Returns whether this configuration manager requires a configuration to be determined.default boolean
isStale(Parameters parameters)
Determines whether the currently managed configuration is stale.java.util.Optional<Configuration>
loadConfiguration(Configuration parentConfiguration)
Loads a configuration.void
saveConfiguration(Parameters parameters)
Saves the configuration.
-
-
-
Method Detail
-
isRequired
boolean isRequired()
Returns whether this configuration manager requires a configuration to be determined. If a configuration is required, attempting to load a configuration will throw an exception if a configuration cannot be determined; otherwise, it will returnOptional.empty()
.- Returns:
true
if a configuration is required and this manager will always return a configuration and throw an exception if one cannot be determined.- See Also:
loadConfiguration(Configuration)
-
loadConfiguration
java.util.Optional<Configuration> loadConfiguration(@Nullable Configuration parentConfiguration) throws java.io.IOException, ConfigurationException
Loads a configuration.It is imperative that the configuration manager assign the given parent configuration, if any, to the loaded configuration so that chained configuration resolution will work.
After this method has been called, it is expected that
isStale(Parameters)
would returnfalse
barring concurrent changes.- Parameters:
parentConfiguration
- The parent configuration to use for fallback lookup, ornull
if there is no parent configuration.- Returns:
- The loaded configuration.
- Throws:
java.io.IOException
- if an I/O error occurs loading the configuration.ConfigurationException
- If there is invalid data or invalid state preventing the configuration from being loaded.
-
saveConfiguration
void saveConfiguration(@Nonnull Parameters parameters) throws java.io.IOException
Saves the configuration.- Parameters:
parameters
- The configuration parameters to save.- Throws:
java.io.IOException
- if an error occurs saving the configuration.
-
isStale
default boolean isStale(@Nonnull Parameters parameters) throws java.io.IOException
Determines whether the currently managed configuration is stale.If this method returns
false
, the caller should callinvalidate()
before reloading the configuration.- Parameters:
parameters
- The currently loaded parameters.- Returns:
- Whether the currently loaded parameters are stale and need to be reloaded.
- Throws:
java.io.IOException
- if an error occurs checking the configuration.
-
invalidate
default void invalidate()
Invalidates any cached information about the managed configuration.The default implementation does nothing.
-
-