Settings library handle multiple data formats as configuration in a flexible way:
- Node templates and transformation.
- Node value substitution in non-compatible formats (like json and yaml).
- Fallback format reader.
- Iterable nodes.
- Data update parameters.
- Comparable paths to get nodes.
- Multi-layer node values.
Currently supporting the formats:
Take in count this library is not focused as an object serializer, the main purpose is making flexible interactions with multiple data formats at the same time.
It also has simple methods to get nodes as multiple data types if you want to implement your own object serializer.
// Load settings from Map
Map<String, Object> map = new HashMap<>();
map.put("key", "value");
map.put("otherkey", 1234);
Settings settings = new Settings();
settings.merge(map);
// Settings from any file named "myfile", the format can be any supported format.
// If file doesn't exist, the optional file "myfile.json" inside .jar will be used.
SettingsData<Settings> data = SettingsData.of("myfile.*").or(DataType.INPUT_STREAM, "myfile.json");
// Load settings by providing a parent folder.
// Also, optional file will be saved inside the folder if original file doesn't exist
File folder = new File("folder");
Settings settings = data.load(folder, true);Settings contains the following artifacts:
settings- The main project.settings-gson- JSON loader using gson library.settings-hocon- HOCON loadersettings-toml- TOML loadersettings-yaml- YAML laoder
build.gradle
dependencies {
implementation 'com.saicone:settings:1.0.6'
}build.gradle.kts
dependencies {
implementation("com.saicone:settings:1.0.6")
}pom.xml
<dependencies>
<dependency>
<groupId>com.saicone</groupId>
<artifactId>settings</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
</dependencies>Note
This project use Types library to convert data types, if you relocate the package make sure to relocate com.saicone.types package as well.