mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2024-09-19 20:25:51 +00:00
docs(readme): listed all supported formats.
This commit is contained in:
parent
b77e64e6e6
commit
7884d49309
110
impl/hocon/README.md
Normal file
110
impl/hocon/README.md
Normal file
@ -0,0 +1,110 @@
|
||||
# EasyConfiguration-HOCON
|
||||
|
||||
HOCON file-based implementation, compatible with all Java environments.
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Maven Dependency
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||
<id>maven</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||
<id>EasyConfiguration</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
</project>
|
||||
```
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-hocon</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
### Gradle Dependency
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
|
||||
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||
mavenCentral()
|
||||
|
||||
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
api "cc.carm.lib:easyconfiguration-hocon:[LATEST RELEASE]"
|
||||
}
|
||||
```
|
||||
|
||||
## Example file format
|
||||
|
||||
```hocon
|
||||
class-value=1.0
|
||||
# Inner Test
|
||||
inner {
|
||||
inner-value=72.0043567836829
|
||||
}
|
||||
sub {
|
||||
that {
|
||||
operators=[]
|
||||
}
|
||||
}
|
||||
test {
|
||||
# Section类型数据测试
|
||||
user {
|
||||
info {
|
||||
uuid="8aba6166-1dc3-476d-8eb6-8957434c05ba"
|
||||
}
|
||||
name=Carm
|
||||
}
|
||||
}
|
||||
test-enum=DAYS
|
||||
test-number=5555780951875134464
|
||||
# Section类型数据测试
|
||||
user {
|
||||
info {
|
||||
uuid="9ed3a8f3-ad2a-4a62-a720-5530f5d19b33"
|
||||
}
|
||||
name="9038c"
|
||||
}
|
||||
# [ID - UUID]对照表
|
||||
#
|
||||
# 用于测试Map类型的解析与序列化保存
|
||||
users {
|
||||
"1"="4bfe382e-7b9e-4dad-9314-d16ddeb99f34"
|
||||
"2"="6e587a1e-361e-43da-99ba-9de44db198dc"
|
||||
"3"=ce582c1c-d696-43d4-ab58-af40d000d656
|
||||
"4"="37b7eb1f-86b9-41c7-afa3-9ac9c75fef2c"
|
||||
"5"="2659c33a-3393-404d-960e-850fef3b23fd"
|
||||
}
|
||||
uuid-value="035e89e8-3fe8-45ed-a25d-eef0bbe8f73d"
|
||||
version=1.0
|
||||
|
||||
```
|
@ -39,6 +39,7 @@
|
||||
<version>1.4.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,8 +1,8 @@
|
||||
package online.flowerinsnow.test.easyconfiguration;
|
||||
|
||||
import cc.carm.lib.configuration.EasyConfiguration;
|
||||
import cc.carm.lib.configuration.demo.tests.ConfigurationTest;
|
||||
import cc.carm.lib.configuration.hocon.HOCONFileConfigProvider;
|
||||
import online.flowerinsnow.test.easyconfiguration.config.SimpleConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@ -11,12 +11,9 @@ public class HOCONTest {
|
||||
@Test
|
||||
public void onTest() {
|
||||
HOCONFileConfigProvider provider = EasyConfiguration.from(new File("target/hocon.conf"));
|
||||
provider.initialize(SimpleConfig.class);
|
||||
// provider.initialize(DatabaseConfiguration.class);
|
||||
|
||||
System.out.println(SimpleConfig.TEST_INT.getNotNull());
|
||||
SimpleConfig.TEST_INT.set((int) (Math.random() * 100 * 5));
|
||||
System.out.println(SimpleConfig.TEST_INT.getNotNull());
|
||||
ConfigurationTest.testDemo(provider);
|
||||
ConfigurationTest.testInner(provider);
|
||||
|
||||
try {
|
||||
provider.save();
|
||||
|
@ -1,28 +0,0 @@
|
||||
package online.flowerinsnow.test.easyconfiguration.config;
|
||||
|
||||
import cc.carm.lib.configuration.core.Configuration;
|
||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
||||
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
|
||||
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||
|
||||
public interface SimpleConfig extends Configuration {
|
||||
@HeaderComment("测试字段 int")
|
||||
ConfiguredValue<Integer> TEST_INT = ConfiguredValue.of(Integer.class, 15);
|
||||
|
||||
@HeaderComment("测试字段 List<String>")
|
||||
ConfiguredList<String> TEST_LIST_STRING = ConfiguredList.of(String.class, "li", "li", "li1");
|
||||
|
||||
@HeaderComment("测试对象")
|
||||
interface TestObject extends Configuration {
|
||||
|
||||
@HeaderComment("测试字段 Boolean")
|
||||
ConfiguredValue<Boolean> TEST_BOOLEAN = ConfiguredValue.of(Boolean.class, true);
|
||||
|
||||
@HeaderComment("inner")
|
||||
interface InnerObject extends Configuration {
|
||||
@HeaderComment("测试字段")
|
||||
public static final ConfiguredValue<Boolean> TEST_BOOLEAN_1 = ConfiguredValue.of(Boolean.class, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
107
impl/json/README.md
Normal file
107
impl/json/README.md
Normal file
@ -0,0 +1,107 @@
|
||||
# EasyConfiguration-JSON
|
||||
|
||||
JSON file-based implementation, compatible with all Java environments.
|
||||
|
||||
**Remember that JSON does not support file comments.**
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Maven Dependency
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||
<id>maven</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||
<id>EasyConfiguration</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
</project>
|
||||
```
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-json</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
### Gradle Dependency
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
|
||||
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||
mavenCentral()
|
||||
|
||||
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
api "cc.carm.lib:easyconfiguration-json:[LATEST RELEASE]"
|
||||
}
|
||||
```
|
||||
|
||||
## Example file format
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 1.0,
|
||||
"test-number": 3185496340759645184,
|
||||
"test-enum": "DAYS",
|
||||
"user": {
|
||||
"name": "774b3",
|
||||
"info": {
|
||||
"uuid": "f890b050-d3c5-4a32-a8b0-8a421ec2d4cc"
|
||||
}
|
||||
},
|
||||
"sub": {
|
||||
"that": {
|
||||
"operators": []
|
||||
}
|
||||
},
|
||||
"uuid-value": "a20c2eb2-e36b-40d7-a1ba-57826e3588c2",
|
||||
"users": {
|
||||
"1": "561f5142-8d59-4e50-855d-18638f3cfca8",
|
||||
"2": "629fadab-c625-4678-85d2-cc73cb4aa3b7",
|
||||
"3": "e29d1fb8-d8bd-4c2a-8ac0-4aaee77196dc",
|
||||
"4": "8ff8ab49-7c34-44c0-9edd-203a9d44f309",
|
||||
"5": "3c09dbff-ca37-468a-8c47-e8e52f837a54"
|
||||
},
|
||||
"inner": {
|
||||
"inner-value": 49.831712577873375
|
||||
},
|
||||
"class-value": 1.0,
|
||||
"test": {
|
||||
"user": {
|
||||
"name": "Carm",
|
||||
"info": {
|
||||
"uuid": "c3881d54-3d77-46ca-b031-2962b8b89141"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
81
impl/sql/README.md
Normal file
81
impl/sql/README.md
Normal file
@ -0,0 +1,81 @@
|
||||
# EasyConfiguration-SQL
|
||||
|
||||
SQL database implementation, support for MySQL or MariaDB.
|
||||
|
||||
## Table schema
|
||||
```mysql
|
||||
CREATE TABLE IF NOT EXISTS conf
|
||||
(
|
||||
`namespace` VARCHAR(32) NOT NULL, # 命名空间 (代表其属于谁,类似于单个配置文件地址的概念)
|
||||
`path` VARCHAR(96) NOT NULL, # 配置路径 (ConfigPath)
|
||||
`type` TINYINT UNSIGNED NOT NULL DEFAULT 0, # 数据类型 (Integer/Byte/List/Map/...)
|
||||
`value` MEDIUMTEXT, # 配置项的值 (可能为JSON格式)
|
||||
`inline_comments` TEXT, # 行内注释
|
||||
`header_comments` MEDIUMTEXT, # 顶部注释
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, # 创建时间
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`namespace`, `path`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Maven Dependency
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||
<id>maven</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||
<id>EasyConfiguration</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
</project>
|
||||
```
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-sql</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
### Gradle Dependency
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
|
||||
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||
mavenCentral()
|
||||
|
||||
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
api "cc.carm.lib:easyconfiguration-sql:[LATEST RELEASE]"
|
||||
}
|
||||
```
|
@ -1,14 +0,0 @@
|
||||
CREATE TABLE IF NOT EXISTS conf
|
||||
(
|
||||
`namespace` VARCHAR(32) NOT NULL, # 命名空间 (代表其属于谁,类似于单个配置文件地址的概念)
|
||||
`path` VARCHAR(96) NOT NULL, # 配置路径 (ConfigPath)
|
||||
`type` TINYINT UNSIGNED NOT NULL DEFAULT 0, # 数据类型 (Integer/Byte/List/Map/...)
|
||||
`value` MEDIUMTEXT, # 配置项的值 (可能为JSON格式)
|
||||
`inline_comments` TEXT, # 行内注释
|
||||
`header_comments` MEDIUMTEXT, # 顶部注释
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, # 创建时间
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`namespace`, `path`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
|
135
impl/yaml/README.md
Normal file
135
impl/yaml/README.md
Normal file
@ -0,0 +1,135 @@
|
||||
# EasyConfiguration-YAML
|
||||
|
||||
YAML file-based implementation, compatible with all Java environments.
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Maven Dependency
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||
<id>maven</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||
<id>EasyConfiguration</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
</project>
|
||||
```
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-yaml</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
### Gradle Dependency
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
|
||||
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||
mavenCentral()
|
||||
|
||||
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
api "cc.carm.lib:easyconfiguration-yaml:[LATEST RELEASE]"
|
||||
}
|
||||
```
|
||||
|
||||
## Example file format
|
||||
```yaml
|
||||
version: 1.0.0
|
||||
|
||||
test-save: false
|
||||
|
||||
test-number: 6161926779561752576
|
||||
|
||||
test-enum: DAYS
|
||||
|
||||
# Section类型数据测试
|
||||
user: # Section数据也支持InlineComment注释
|
||||
name: '35882'
|
||||
info:
|
||||
uuid: 554b79f1-7c39-4960-82d1-5514c9734417
|
||||
|
||||
uuid-value: 9a86663e-2fc7-4851-a423-c7e5d8e94a47 # This is an inline comment
|
||||
|
||||
sub:
|
||||
that:
|
||||
operators: []
|
||||
|
||||
# [ID - UUID]对照表
|
||||
|
||||
# 用于测试Map类型的解析与序列化保存
|
||||
users:
|
||||
'1': 1c055bdd-c9d1-4931-8270-3d162247f38a
|
||||
'2': 934e2b05-2417-424e-80fd-fe58c6725837
|
||||
'3': 442949a2-8345-4210-a87b-593d7168980e
|
||||
'4': 5c015453-4b5b-42e3-ad87-b9498f2dfeab
|
||||
'5': 8f9640e7-0fbd-4f73-b737-f0b707215e71
|
||||
|
||||
# Inner Test
|
||||
inner:
|
||||
inner-value: 51.223503560658166
|
||||
|
||||
class-value: 1.0
|
||||
|
||||
test:
|
||||
# Section类型数据测试
|
||||
user: # Section数据也支持InlineComment注释
|
||||
name: Carm
|
||||
info:
|
||||
uuid: 3d1ef2a0-a38b-44f3-b15f-8e3b22cb8cc6
|
||||
|
||||
# 以下内容用于测试序列化
|
||||
model-test:
|
||||
some-model:
|
||||
==: SomeModel
|
||||
num: 855
|
||||
name: 4f6b7
|
||||
any-model:
|
||||
==: AnyModel
|
||||
name: 63d05
|
||||
state: false
|
||||
models:
|
||||
- name: 481f3
|
||||
state: true
|
||||
- name: fcf3e
|
||||
state: false
|
||||
- name: '14e50'
|
||||
state: false
|
||||
model-map:
|
||||
a:
|
||||
name: 1fb9b
|
||||
state: false
|
||||
b:
|
||||
name: 5486f
|
||||
state: false
|
||||
```
|
Loading…
Reference in New Issue
Block a user