public class ConfigUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JSON_EXTENSION
Default extension of json files
|
Constructor and Description |
---|
ConfigUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
loadConfig(java.nio.file.Path directory,
java.lang.String name,
com.google.gson.Gson gson,
java.util.function.Function<com.google.gson.stream.JsonWriter,T> write,
java.util.function.Function<java.io.BufferedReader,T> read)
Load and create a config file if not already there from a default value.
|
static <T> T |
loadConfig(java.nio.file.Path directory,
java.lang.String name,
com.google.gson.Gson gson,
T defaultValue,
java.util.function.BiConsumer<com.google.gson.stream.JsonWriter,T> write,
java.util.function.Function<java.io.BufferedReader,T> read)
Load and create a config file if not already there from a default value.
|
static <T> T |
loadConfig(java.nio.file.Path directory,
java.lang.String name,
java.lang.String extension,
com.google.gson.Gson gson,
java.util.function.Function<com.google.gson.stream.JsonWriter,T> write,
java.util.function.Function<java.io.BufferedReader,T> read)
Load and create a config file if not already there from a default value.
|
static <T> T |
loadConfig(java.nio.file.Path directory,
java.lang.String name,
java.lang.String extension,
com.google.gson.Gson gson,
T defaultValue,
java.util.function.BiConsumer<com.google.gson.stream.JsonWriter,T> write,
java.util.function.Function<java.io.BufferedReader,T> read)
Load and create a config file if not already there from a default value.
|
public static final java.lang.String JSON_EXTENSION
public static <T> T loadConfig(java.nio.file.Path directory, java.lang.String name, com.google.gson.Gson gson, java.util.function.Function<com.google.gson.stream.JsonWriter,T> write, java.util.function.Function<java.io.BufferedReader,T> read) throws java.io.IOException
Gson
for serialization and
deserialization. The extension of the file is automatically JSON_EXTENSION
T
- Class to load with gsondirectory
- Path of the directory where the file isname
- The file without the extensiongson
- Gson instance with possible registered serializerwrite
- Function that should write the default values to the JsonWriter
and return the the default
instanceread
- Function that should read the values from BufferedReader
and deserialize them and return a new
instance of the class with the new valuesjava.io.IOException
public static <T> T loadConfig(java.nio.file.Path directory, java.lang.String name, java.lang.String extension, com.google.gson.Gson gson, java.util.function.Function<com.google.gson.stream.JsonWriter,T> write, java.util.function.Function<java.io.BufferedReader,T> read) throws java.io.IOException
Gson
for serialization and
deserialization.T
- Class to load with gsondirectory
- Path of the directory where the file isname
- The file without the extensionextension
- Extension of the filegson
- Gson instance with possible registered serializerwrite
- Function
that should write the default values to the JsonWriter
and return the the
default instanceread
- Function
that should read the values from BufferedReader
and deserialize them and return
a new instance of the class with the new valuesjava.io.IOException
public static <T> T loadConfig(java.nio.file.Path directory, java.lang.String name, com.google.gson.Gson gson, T defaultValue, java.util.function.BiConsumer<com.google.gson.stream.JsonWriter,T> write, java.util.function.Function<java.io.BufferedReader,T> read) throws java.io.IOException
Gson
for serialization and
deserialization. The extension of the file is automatically JSON_EXTENSION
T
- Class to load with gsondirectory
- Path of the directory where the file isname
- The file without the extensiongson
- Gson instance with possible registered serializerdefaultValue
- The default instance of the class that should be written if no config file is presentwrite
- BiConsumer
that should write the default values to the JsonWriter
read
- Function
that should read the values from BufferedReader
and deserialize them and return
a new instance of the class with the new valuesjava.io.IOException
public static <T> T loadConfig(java.nio.file.Path directory, java.lang.String name, java.lang.String extension, com.google.gson.Gson gson, T defaultValue, java.util.function.BiConsumer<com.google.gson.stream.JsonWriter,T> write, java.util.function.Function<java.io.BufferedReader,T> read) throws java.io.IOException
Gson
for serialization and
deserialization.T
- Class to load with gsondirectory
- Path of the directory where the file isname
- The file without the extensionextension
- Extension of the filegson
- Gson instance with possible registered serializerdefaultValue
- The default instance of the class that should be written if no config file is presentwrite
- BiConsumer
that should write the default values to the JsonWriter
read
- Function
that should read the values from BufferedReader
and deserialize them and return
a new instance of the class with the new valuesjava.io.IOException