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 Nodes:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GsonFormatAn instance ofGsonFormatthat created from a plainGsonBuilder.static final GsonFormatAn instance ofGsonFormatthat created from aGsonBuilderthat set pretty printing. -
Constructor Summary
ConstructorsConstructorDescriptionGsonFormat(@NotNull com.google.gson.GsonBuilder gsonBuilder) Creates a newGsonFormatfrom theGsonBuilder. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.siroshun09.configapi.core.file.FileFormat
load, load, save, save
-
Field Details
-
DEFAULT
An instance ofGsonFormatthat created from a plainGsonBuilder. -
PRETTY_PRINTING
An instance ofGsonFormatthat created from aGsonBuilderthat set pretty printing.
-
-
Constructor Details
-
GsonFormat
public GsonFormat(@NotNull @NotNull com.google.gson.GsonBuilder gsonBuilder) Creates a newGsonFormatfrom theGsonBuilder.- Parameters:
gsonBuilder- theGsonBuilder
-
-
Method Details
-
load
Description copied from interface:FileFormatLoads a node from aReader.- Specified by:
loadin interfaceFileFormat<MapNode>- Parameters:
reader- aReaderto 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:FileFormatSaves a node to aWriter.- Specified by:
savein interfaceFileFormat<MapNode>- Parameters:
node- a rootNode(FileFormat) to savewriter- aWriterto write a node- Throws:
IOException- if I/O error occurred
-