1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 10:38:19 +08:00

style: Reformatted code with .editorconfig

This commit is contained in:
2025-05-14 04:22:48 +08:00
parent 76d276436b
commit a4abfb733a
86 changed files with 1140 additions and 450 deletions
@@ -26,8 +26,8 @@ import java.nio.charset.StandardCharsets;
import java.util.*;
public class YAMLSource
extends FileConfigSource<SourcedSection, Map<String, Object>, YAMLSource>
implements CommentedSection {
extends FileConfigSource<SourcedSection, Map<String, Object>, YAMLSource>
implements CommentedSection {
protected final @NotNull YamlConstructor yamlConstructor;
protected final @NotNull YamlRepresenter yamlRepresenter;
@@ -109,9 +109,9 @@ public class YAMLSource
@Override
public void save() throws Exception {
CommentedYAMLWriter writer = new CommentedYAMLWriter(
String.valueOf(this.pathSeparator()),
dumperOptions().getIndent(),
holder.option(CommentableOptions.COMMENT_EMPTY_VALUE)
String.valueOf(this.pathSeparator()),
dumperOptions().getIndent(),
holder.option(CommentableOptions.COMMENT_EMPTY_VALUE)
);
try {
fileWriter(w -> w.write(writer.saveToString(this)));
@@ -23,11 +23,11 @@ public interface SampleConfig extends Configuration {
@HeaderComments({"[ UUID >-----------------------------------", "A lot of UUIDs"})
@FooterComments("[ UUID >-----------------------------------")
ConfiguredList<UUID> UUIDS = ConfiguredList.builderOf(UUID.class).fromString()
.parse(UUID::fromString).serialize(UUID::toString)
.defaults(
UUID.fromString("00000000-0000-0000-0000-000000000000"),
UUID.fromString("00000000-0000-0000-0000-000000000001")
).build();
.parse(UUID::fromString).serialize(UUID::toString)
.defaults(
UUID.fromString("00000000-0000-0000-0000-000000000000"),
UUID.fromString("00000000-0000-0000-0000-000000000001")
).build();
@ConfigPath("info") // Custom path
interface INFO extends Configuration {
@@ -10,9 +10,9 @@ public class SampleTest {
public void test() {
// 1. Make a configuration provider from a file.
ConfigurationHolder<?> holder = YAMLConfigFactory.from("target/config.yml")
.resourcePath("configs/sample.yml")
.indent(2) // Optional: Set the indentation of the configuration file.
.build();
.resourcePath("configs/sample.yml")
.indent(2) // Optional: Set the indentation of the configuration file.
.build();
// 2. Initialize the configuration classes or instances.
holder.initialize(SampleConfig.class);