Class GsonFormat
java.lang.Object
com.github.siroshun09.configapi.format.gson.GsonFormat
- All Implemented Interfaces:
FileFormat<MapNode>
A
FileFormat
implementation that loading/saving MapNode
from/to json files using Gson
.
Supported Node
s:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final GsonFormat
An instance ofGsonFormat
that created from a plainGsonBuilder
.static final GsonFormat
An instance ofGsonFormat
that created from aGsonBuilder
that set pretty printing. -
Constructor Summary
ConstructorDescriptionGsonFormat
(@NotNull com.google.gson.GsonBuilder gsonBuilder) Creates a newGsonFormat
from theGsonBuilder
. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.siroshun09.configapi.core.file.FileFormat
load, load, save, save
-
Field Details
-
DEFAULT
An instance ofGsonFormat
that created from a plainGsonBuilder
. -
PRETTY_PRINTING
An instance ofGsonFormat
that created from aGsonBuilder
that set pretty printing.
-
-
Constructor Details
-
GsonFormat
public GsonFormat(@NotNull @NotNull com.google.gson.GsonBuilder gsonBuilder) Creates a newGsonFormat
from theGsonBuilder
.- Parameters:
gsonBuilder
- theGsonBuilder
-
-
Method Details
-
load
Description copied from interface:FileFormat
Loads a node from aReader
.- Specified by:
load
in interfaceFileFormat<MapNode>
- Parameters:
reader
- aReader
to load a node- Returns:
- a loaded
Node
(FileFormat
) - Throws:
IOException
- if I/O error occurred
-
save
public void save(@NotNull @NotNull MapNode node, @NotNull @NotNull Writer writer) throws IOException Description copied from interface:FileFormat
Saves a node to aWriter
.- Specified by:
save
in interfaceFileFormat<MapNode>
- Parameters:
node
- a rootNode
(FileFormat
) to savewriter
- aWriter
to write a node- Throws:
IOException
- if I/O error occurred
-