Class GsonConfigurationLoader
java.lang.Object
org.spongepowered.configurate.loader.AbstractConfigurationLoader<BasicConfigurationNode>
org.spongepowered.configurate.gson.GsonConfigurationLoader
- All Implemented Interfaces:
ConfigurationNodeFactory<BasicConfigurationNode>,ConfigurationLoader<BasicConfigurationNode>
public final class GsonConfigurationLoader
extends AbstractConfigurationLoader<BasicConfigurationNode>
A loader for JSON-formatted configurations, using the GSON library for
parsing and generation.
- Since:
- 4.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.spongepowered.configurate.loader.AbstractConfigurationLoader
CONFIGURATE_LINE_PATTERN, CONFIGURATE_LINE_SEPARATOR, sink, source, SYSTEM_LINE_SEPARATOR -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull GsonConfigurationLoader.Builderbuilder()Creates a newGsonConfigurationLoaderbuilder.protected voidPerform format-specific validation of a node.createNode(ConfigurationOptions options) Create an empty node with the provided options.static TypeSerializerCollectionGet aTypeSerializerCollectionfor handling Gson types.protected voidloadInternal(BasicConfigurationNode node, BufferedReader reader) Using a created node, attempt to read a configuration file.protected voidsaveInternal(ConfigurationNode node, Writer writer) Perform a save of the node to the provided writer.Methods inherited from class org.spongepowered.configurate.loader.AbstractConfigurationLoader
canLoad, canSave, defaultCommentHandler, defaultOptions, load, loadToReference, save, writeHeaderInternalMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.spongepowered.configurate.loader.ConfigurationLoader
loadMethods inherited from interface org.spongepowered.configurate.ConfigurationNodeFactory
createNode, createNode, createNode, toListCollector, toListCollector, toMapCollector, toMapCollector
-
Method Details
-
builder
Creates a newGsonConfigurationLoaderbuilder.- Returns:
- a new builder
- Since:
- 4.0.0
-
gsonSerializers
Get aTypeSerializerCollectionfor handling Gson types.Currently, this serializer can handle:
JsonElementand its subtypes:JsonArray,JsonObject,JsonPrimitive, andJsonNull
- Returns:
- gson type serializers
- Since:
- 4.1.0
-
checkCanWrite
Description copied from class:AbstractConfigurationLoaderPerform format-specific validation of a node.This method will be called before a writer is opened, allowing the loader to perform any basic validation it may need to before it opens a writer replacing an existing file.
- Overrides:
checkCanWritein classAbstractConfigurationLoader<BasicConfigurationNode>- Parameters:
node- the node to write- Throws:
ConfigurateException- if any invalid data is present
-
loadInternal
protected void loadInternal(BasicConfigurationNode node, BufferedReader reader) throws ParsingException Description copied from class:AbstractConfigurationLoaderUsing a created node, attempt to read a configuration file.The header will already have been read if applicable.
- Specified by:
loadInternalin classAbstractConfigurationLoader<BasicConfigurationNode>- Parameters:
node- node to load intoreader- reader to load from- Throws:
ParsingException- if an error occurs at any stage of loading
-
saveInternal
Description copied from class:AbstractConfigurationLoaderPerform a save of the node to the provided writer.- Specified by:
saveInternalin classAbstractConfigurationLoader<BasicConfigurationNode>- Parameters:
node- node to savewriter- writer to output to- Throws:
ConfigurateException- if any of the node's data is unsavable
-
createNode
Description copied from interface:ConfigurationNodeFactoryCreate an empty node with the provided options.Node options may be overridden if the factory enforces specific requirements on options.
- Parameters:
options- node options- Returns:
- newly created empty node
-