1
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:
2024-01-04 21:20:56 +08:00
parent 9647591b0d
commit 0d19dc236e
3 changed files with 58 additions and 56 deletions
+19 -19
View File
@@ -11,31 +11,31 @@ import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
import java.util.UUID;
public class Sample {
@HeaderComment("Configurations for sample")
interface SampleConfig extends Configuration {
@HeaderComment("Configurations for sample")
interface SampleConfig extends Configuration {
@InlineComment("Enabled?") // Inline comment
ConfiguredValue<Boolean> ENABLED = ConfiguredValue.of(true);
@InlineComment("Enabled?") // Inline comment
ConfiguredValue<Boolean> ENABLED = ConfiguredValue.of(true);
ConfiguredList<UUID> UUIDS = ConfiguredList.builderOf(UUID.class).fromString()
.parseValue(UUID::fromString).serializeValue(UUID::toString)
.defaults(
UUID.fromString("00000000-0000-0000-0000-000000000000"),
UUID.fromString("00000000-0000-0000-0000-000000000001")
).build();
ConfiguredList<UUID> UUIDS = ConfiguredList.builderOf(UUID.class).fromString()
.parseValue(UUID::fromString).serializeValue(UUID::toString)
.defaults(
UUID.fromString("00000000-0000-0000-0000-000000000000"),
UUID.fromString("00000000-0000-0000-0000-000000000001")
).build();
interface INFO extends Configuration {
@HeaderComment("Configure your name!") // Header comment
ConfiguredValue<String> NAME = ConfiguredValue.of("Joker");
@ConfigPath("year") // Custom path
ConfiguredValue<Integer> AGE = ConfiguredValue.of(24);
}
interface INFO extends Configuration {
@HeaderComment("Configure your name!") // Header comment
ConfiguredValue<String> NAME = ConfiguredValue.of("Joker");
@ConfigPath("year") // Custom path
ConfiguredValue<Integer> AGE = ConfiguredValue.of(24);
}
}
public class Sample {
public static void main(String[] args) {
// 1. Make a configuration provider from a file.
ConfigurationProvider<?> provider = EasyConfiguration.from("config.yml");