Class Container<C>
java.lang.Object
com.thewinterframework.configurate.Container<C>
- Type Parameters:
C- the type of the configuration object
A container for a configuration file.
-
Method Summary
Modifier and TypeMethodDescriptionget()Gets the configuration object.org.spongepowered.configurate.ConfigurationNodegetNode()Gets the configuration node.static <C> Container<C> Loads a configuration file.static <C> Container<C> Loads a configuration file.static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options) Loads a configuration file.static org.spongepowered.configurate.ConfigurationNodeloadNode(Class<?> clazz, org.slf4j.Logger logger, Path path, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options) Loads a configuration node.booleanreload()Reloads the configuration file.booleansave()Saves the current configuration to the file.booleanupdate(UnaryOperator<C> updater) Updates the configuration object using the provided updater function.
-
Method Details
-
reload
public boolean reload()Reloads the configuration file.- Returns:
trueif the save was successful,falseotherwise
-
get
Gets the configuration object. -
getNode
public org.spongepowered.configurate.ConfigurationNode getNode()Gets the configuration node.- Returns:
- the configuration node
-
update
Updates the configuration object using the provided updater function.- Parameters:
updater- the function to apply to the current config- Returns:
trueif the update and save were successful,falseotherwise
-
save
public boolean save()Saves the current configuration to the file.- Returns:
trueif the save was successful,falseotherwise
-
load
public static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options) throws IOException Loads a configuration file.- Type Parameters:
C- the type of the configuration object- Parameters:
logger- the loggerpath- the path to the configuration fileclazz- the class of the configuration objectfile- the name of the configuration fileoptions- the configuration options- Returns:
- the container
- Throws:
IOException- if an I/O error occurs
-
loadNode
public static org.spongepowered.configurate.ConfigurationNode loadNode(Class<?> clazz, org.slf4j.Logger logger, Path path, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options) throws IOException Loads a configuration node.- Parameters:
logger- the loggerpath- the path to the configuration filefile- the name of the configuration fileoptions- the configuration options- Returns:
- the configuration node
- Throws:
IOException- if an I/O error occurs
-
load
public static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file) throws IOException Loads a configuration file.- Type Parameters:
C- the type of the configuration object- Parameters:
logger- the loggerpath- the path to the configuration fileclazz- the class of the configuration objectfile- the name of the configuration file- Returns:
- the container
- Throws:
IOException- if an I/O error occurs
-
load
public static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, Class<?> clazzLoader) throws IOException Loads a configuration file.- Type Parameters:
C- the type of the configuration object- Parameters:
logger- the loggerpath- the path to the configuration fileclazz- the class of the configuration objectfile- the name of the configuration fileclazzLoader- the class loader- Returns:
- the container
- Throws:
IOException
-