Class JacksonFormat
java.lang.Object
com.github.siroshun09.configapi.format.jackson.JacksonFormat
- All Implemented Interfaces:
FileFormat<MapNode>
A
FileFormat implementation that loading/saving MapNode from/to json files using Jackson's ObjectMapper.
Supported Nodes:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JacksonFormatAn instance ofJacksonFormatthat created from a plainObjectMapper.static final JacksonFormatAn instance ofJacksonFormatthat created from aObjectMapperthat is enabled pretty printing. -
Constructor Summary
ConstructorsConstructorDescriptionJacksonFormat(@NotNull com.fasterxml.jackson.databind.ObjectMapper objectMapper) The constructor ofJacksonFormat. -
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, save, save
-
Field Details
-
DEFAULT
An instance ofJacksonFormatthat created from a plainObjectMapper. -
PRETTY_PRINTING
An instance ofJacksonFormatthat created from aObjectMapperthat is enabled pretty printing.
-
-
Constructor Details
-
JacksonFormat
public JacksonFormat(@NotNull @NotNull com.fasterxml.jackson.databind.ObjectMapper objectMapper) The constructor ofJacksonFormat.- Parameters:
objectMapper- anObjectMapperthat is used for serializing/deserializing json
-
-
Method Details
-
createDefaultPrettyPrinter
@Contract(" -> new") @NotNull public static @NotNull com.fasterxml.jackson.core.util.DefaultPrettyPrinter createDefaultPrettyPrinter()Creates aDefaultPrettyPrinterthat prints json like Gson.- Returns:
- a
DefaultPrettyPrinter
-
load
Description copied from interface:FileFormatLoads a node from a file.- Specified by:
loadin interfaceFileFormat<MapNode>- Parameters:
filepath- a filepath to load a node- Returns:
- a loaded
Node(FileFormat) - Throws:
IOException- if I/O error occurred
-
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
-