1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 18:48:20 +08:00

docs(readme): listed all supported formats.

This commit is contained in:
2023-12-24 05:11:56 +08:00
parent b77e64e6e6
commit 7884d49309
8 changed files with 437 additions and 48 deletions
+110
View 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
```
+1
View File
@@ -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);
}
}
}