From 7884d4930968bc4ae52d10f6f05e500ae552615e Mon Sep 17 00:00:00 2001 From: carm Date: Sun, 24 Dec 2023 05:11:56 +0800 Subject: [PATCH] docs(readme): listed all supported formats. --- impl/hocon/README.md | 110 ++++++++++++++ impl/hocon/pom.xml | 1 + .../test/easyconfiguration/HOCONTest.java | 9 +- .../config/SimpleConfig.java | 28 ---- impl/json/README.md | 107 ++++++++++++++ impl/sql/README.md | 81 +++++++++++ impl/sql/table_schem.sql | 14 -- impl/yaml/README.md | 135 ++++++++++++++++++ 8 files changed, 437 insertions(+), 48 deletions(-) create mode 100644 impl/hocon/README.md delete mode 100644 impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/config/SimpleConfig.java create mode 100644 impl/json/README.md create mode 100644 impl/sql/README.md delete mode 100644 impl/sql/table_schem.sql create mode 100644 impl/yaml/README.md diff --git a/impl/hocon/README.md b/impl/hocon/README.md new file mode 100644 index 0000000..17c1e8a --- /dev/null +++ b/impl/hocon/README.md @@ -0,0 +1,110 @@ +# EasyConfiguration-HOCON + +HOCON file-based implementation, compatible with all Java environments. + +## Dependencies + +### Maven Dependency + +```xml + + + + + + + maven + Maven Central + https://repo1.maven.org/maven2 + + + + + EasyConfiguration + GitHub Packages + https://maven.pkg.github.com/CarmJos/EasyConfiguration + + + + +``` + +```xml + + + + + cc.carm.lib + easyconfiguration-hocon + [LATEST RELEASE] + compile + + + +``` + +### 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 + +``` diff --git a/impl/hocon/pom.xml b/impl/hocon/pom.xml index f14f000..5652c4f 100644 --- a/impl/hocon/pom.xml +++ b/impl/hocon/pom.xml @@ -39,6 +39,7 @@ 1.4.3 compile + diff --git a/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/HOCONTest.java b/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/HOCONTest.java index 716df5c..693120b 100644 --- a/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/HOCONTest.java +++ b/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/HOCONTest.java @@ -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(); diff --git a/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/config/SimpleConfig.java b/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/config/SimpleConfig.java deleted file mode 100644 index 9201a6b..0000000 --- a/impl/hocon/src/test/java/online/flowerinsnow/test/easyconfiguration/config/SimpleConfig.java +++ /dev/null @@ -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 TEST_INT = ConfiguredValue.of(Integer.class, 15); - - @HeaderComment("测试字段 List") - ConfiguredList TEST_LIST_STRING = ConfiguredList.of(String.class, "li", "li", "li1"); - - @HeaderComment("测试对象") - interface TestObject extends Configuration { - - @HeaderComment("测试字段 Boolean") - ConfiguredValue TEST_BOOLEAN = ConfiguredValue.of(Boolean.class, true); - - @HeaderComment("inner") - interface InnerObject extends Configuration { - @HeaderComment("测试字段") - public static final ConfiguredValue TEST_BOOLEAN_1 = ConfiguredValue.of(Boolean.class, true); - } - - } -} diff --git a/impl/json/README.md b/impl/json/README.md new file mode 100644 index 0000000..7a7a1f2 --- /dev/null +++ b/impl/json/README.md @@ -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 + + + + + + + maven + Maven Central + https://repo1.maven.org/maven2 + + + + + EasyConfiguration + GitHub Packages + https://maven.pkg.github.com/CarmJos/EasyConfiguration + + + + +``` + +```xml + + + + + cc.carm.lib + easyconfiguration-json + [LATEST RELEASE] + compile + + + +``` + +### 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" + } + } + } +} +``` diff --git a/impl/sql/README.md b/impl/sql/README.md new file mode 100644 index 0000000..2bdf1e3 --- /dev/null +++ b/impl/sql/README.md @@ -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 + + + + + + + maven + Maven Central + https://repo1.maven.org/maven2 + + + + + EasyConfiguration + GitHub Packages + https://maven.pkg.github.com/CarmJos/EasyConfiguration + + + + +``` + +```xml + + + + + cc.carm.lib + easyconfiguration-sql + [LATEST RELEASE] + compile + + + +``` + +### 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]" +} +``` \ No newline at end of file diff --git a/impl/sql/table_schem.sql b/impl/sql/table_schem.sql deleted file mode 100644 index e6fc958..0000000 --- a/impl/sql/table_schem.sql +++ /dev/null @@ -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; - diff --git a/impl/yaml/README.md b/impl/yaml/README.md new file mode 100644 index 0000000..82429b0 --- /dev/null +++ b/impl/yaml/README.md @@ -0,0 +1,135 @@ +# EasyConfiguration-YAML + +YAML file-based implementation, compatible with all Java environments. + +## Dependencies + +### Maven Dependency + +```xml + + + + + + + maven + Maven Central + https://repo1.maven.org/maven2 + + + + + EasyConfiguration + GitHub Packages + https://maven.pkg.github.com/CarmJos/EasyConfiguration + + + + +``` + +```xml + + + + + cc.carm.lib + easyconfiguration-yaml + [LATEST RELEASE] + compile + + + +``` + +### 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 +```