TheElectronWill/night-config
关于
Powerful java configuration library for toml, yaml, hocon, json and in-memory configurations. Serialization/deserialization framework.
开发工具实测星标增长
- 24小时
- 0
- 7天
- +2
- 15天
- +3
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
Introduction
NightConfig is a powerful yet easy-to-use java configuration library, written in Java 8.
It supports the following formats:
How to use
Glimpse
// Simple builder:
FileConfig conf = FileConfig.of("the/file/config.toml");
// Advanced builder, default resource, autosave and much more (-> cf the wiki)
CommentedFileConfig config = CommentedFileConfig.builder("myConfig.toml").defaultResource("defaultConfig.toml").autosave().build();
config.load(); // This actually reads the config
String name = config.get("username"); // Generic return type!
List<String> names = config.get("users_list"); // Generic return type!
long id = config.getLong("account.id"); // Compound path: key "id" in subconfig "account"
int points = config.getIntOrElse("account.score", defaultScore); // Default value
config.set("account.score", points*2);
String comment = config.getComment("user");
// NightConfig saves the config's comments (for TOML and HOCON)
// config.save(); not needed here thanks to autosave()
config.close(); // Close the FileConfig once you're done with it :)
Running the examples
Each file in examples/src/main/java has a main function and shows how to use NightConfig for many different use cases.
To run an example:
- Clone this repository.
cdto it- Run
./gradlew examples:run -PmainClass=${CLASS}by replacing${CLASS}with the example of your choice.
For example, to run FileConfigExample.java:
./gradlew examples:run -PmainClass=FileConfigExample
The file be compiled automatically, and the given main class will be executed.
Project building
NightConfig is built with Gradle. The project is divided in several modules, the "core" module plus one module per supported configuration format. Please read the wiki for more information.
The releases are available on Maven Central and JitPack.
Old Android modules
Older versions of Android (before Android Oreo) didn't provide the packages java.util.function and java.nio.file, which NightConfig heavily uses.
To attempt to mitigate these issues, I made a special version of each modules, suffixed with _android, that you could use instead of the regular modules.
These old _android modules are deprecated and will no longer receive updates.
The maintainance burden of these modules is not worth it, and these versions of Android have reached end of life since several years already.
探索相关项目
加载中…