Package ninja.leaping.configurate.loader
Interface ConfigurationLoader<NodeType extends ConfigurationNode>
- Type Parameters:
NodeType
- TheConfigurationNode
type produced by the loader
- All Known Implementing Classes:
AbstractConfigurationLoader
,GsonConfigurationLoader
,HoconConfigurationLoader
,JSONConfigurationLoader
,XMLConfigurationLoader
,YAMLConfigurationLoader
public interface ConfigurationLoader<NodeType extends ConfigurationNode>
Represents an object which can load and save
ConfigurationNode
objects in a specific
configuration format.
An abstract implementation is provided by AbstractConfigurationLoader
.
-
Method Summary
Modifier and Type Method Description default boolean
canLoad()
Gets if this loader is capable of loading configurations.default boolean
canSave()
Gets if this loader is capable of saving configurations.default @NonNull NodeType
createEmptyNode()
Return an empty node of the most appropriate type for this loader, using the default options.@NonNull NodeType
createEmptyNode(@NonNull ConfigurationOptions options)
Return an empty node of the most appropriate type for this loader@NonNull ConfigurationOptions
getDefaultOptions()
Gets the defaultConfigurationOptions
used by the loader.default @NonNull NodeType
load()
Attempts to load aConfigurationNode
using this loader, from the defined source.@NonNull NodeType
load(@NonNull ConfigurationOptions options)
Attempts to load aConfigurationNode
using this loader, from the defined source.default ConfigurationReference<NodeType>
loadToReference()
Attempts to load data from the defined source into aConfigurationReference
.void
save(@NonNull ConfigurationNode node)
Attempts to save aConfigurationNode
using this loader, to the defined sink.
-
Method Details
-
getDefaultOptions
Gets the defaultConfigurationOptions
used by the loader.New nodes will be created using the default options if a specific set is not defined.
- Returns:
- The default options
-
load
Attempts to load aConfigurationNode
using this loader, from the defined source.The resultant node represents the root of the configuration being loaded.
The
default options
will be used to construct the resultant configuration nodes.- Returns:
- The newly constructed node
- Throws:
IOException
- if any sort of error occurs with reading or parsing the configuration
-
loadToReference
Attempts to load data from the defined source into aConfigurationReference
. The returned reference will not reload automatically.- Returns:
- The created reference
- Throws:
IOException
- when an error occurs within the loader- See Also:
to create an auto-reloading configuration.
-
load
Attempts to load aConfigurationNode
using this loader, from the defined source.The resultant node represents the root of the configuration being loaded.
- Parameters:
options
- The options to load with- Returns:
- The newly constructed node
- Throws:
IOException
- if any sort of error occurs with reading or parsing the configuration
-
save
Attempts to save aConfigurationNode
using this loader, to the defined sink.- Parameters:
node
- The node to save- Throws:
IOException
- if any sort of error occurs with writing or generating the configuration
-
createEmptyNode
Return an empty node of the most appropriate type for this loader, using the default options.- Returns:
- The appropriate node type
-
createEmptyNode
Return an empty node of the most appropriate type for this loader- Parameters:
options
- The options to use with this node. Must not be null (seeConfigurationOptions.defaults()
)- Returns:
- The appropriate node type
-
canLoad
Gets if this loader is capable of loading configurations.- Returns:
- If this loader can load
-
canSave
Gets if this loader is capable of saving configurations.- Returns:
- If this loader can save
-