mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 18:48:20 +08:00
docs(sample): Add sample codes. 🥚
This commit is contained in:
@@ -49,8 +49,6 @@ Check out all code demonstrations [HERE](demo/src/main/java/cc/carm/lib/configur
|
|||||||
For more examples, see the [Development Guide](.doc/README.md).
|
For more examples, see the [Development Guide](.doc/README.md).
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public class Sample {
|
|
||||||
|
|
||||||
@HeaderComment("Configurations for sample")
|
@HeaderComment("Configurations for sample")
|
||||||
interface SampleConfig extends Configuration {
|
interface SampleConfig extends Configuration {
|
||||||
|
|
||||||
@@ -74,7 +72,10 @@ public class Sample {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
public class Sample {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// 1. Make a configuration provider from a file.
|
// 1. Make a configuration provider from a file.
|
||||||
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");
|
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");
|
||||||
@@ -84,7 +85,6 @@ public class Sample {
|
|||||||
SampleConfig.ENABLED.set(false);
|
SampleConfig.ENABLED.set(false);
|
||||||
System.out.println("Your name is " + SampleConfig.INFO.NAME.getNotNull() + " !");
|
System.out.println("Your name is " + SampleConfig.INFO.NAME.getNotNull() + " !");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
+7
-5
@@ -42,9 +42,8 @@ README LANGUAGES [ [English](README.md) | [**中文**](README_CN.md) ]
|
|||||||
|
|
||||||
您可以 [点击这里](demo/src/main/java/cc/carm/lib/configuration/demo) 直接查看现有的代码演示,更多复杂情况演示详见 [开发介绍](.doc/README.md) 。
|
您可以 [点击这里](demo/src/main/java/cc/carm/lib/configuration/demo) 直接查看现有的代码演示,更多复杂情况演示详见 [开发介绍](.doc/README.md) 。
|
||||||
|
|
||||||
```java
|
|
||||||
public class Sample {
|
|
||||||
|
|
||||||
|
```java
|
||||||
@HeaderComment("Configurations for sample")
|
@HeaderComment("Configurations for sample")
|
||||||
interface SampleConfig extends Configuration {
|
interface SampleConfig extends Configuration {
|
||||||
|
|
||||||
@@ -65,9 +64,13 @@ public class Sample {
|
|||||||
|
|
||||||
@ConfigPath("year") // 自定义配置路径,若不定义,则按照默认规则生成
|
@ConfigPath("year") // 自定义配置路径,若不定义,则按照默认规则生成
|
||||||
ConfiguredValue<Integer> AGE = ConfiguredValue.of(24);
|
ConfiguredValue<Integer> AGE = ConfiguredValue.of(24);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
public class Sample {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// 1. 生成一个 “Provider” 用于给配置类提供源配置的文件。
|
// 1. 生成一个 “Provider” 用于给配置类提供源配置的文件。
|
||||||
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");
|
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");
|
||||||
@@ -77,7 +80,6 @@ public class Sample {
|
|||||||
SampleConfig.ENABLED.set(false);
|
SampleConfig.ENABLED.set(false);
|
||||||
System.out.println("Your name is " + SampleConfig.INFO.NAME.getNotNull() + " !");
|
System.out.println("Your name is " + SampleConfig.INFO.NAME.getNotNull() + " !");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Sample {
|
|
||||||
|
|
||||||
@HeaderComment("Configurations for sample")
|
@HeaderComment("Configurations for sample")
|
||||||
interface SampleConfig extends Configuration {
|
interface SampleConfig extends Configuration {
|
||||||
|
|
||||||
@@ -36,6 +34,8 @@ public class Sample {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Sample {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// 1. Make a configuration provider from a file.
|
// 1. Make a configuration provider from a file.
|
||||||
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");
|
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");
|
||||||
|
|||||||
Reference in New Issue
Block a user