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
+1 -1
View File
@@ -48,4 +48,4 @@
</plugins>
</build>
</project>
</project>
@@ -42,12 +42,12 @@ public interface CommentableMeta {
static void register(@NotNull ConfigurationInitializer initializer) {
initializer.registerAnnotation(
HeaderComments.class, HEADER,
a -> Arrays.asList(a.value())
HeaderComments.class, HEADER,
a -> Arrays.asList(a.value())
);
initializer.registerAnnotation(
FooterComments.class, FOOTER,
a -> Arrays.asList(a.value())
FooterComments.class, FOOTER,
a -> Arrays.asList(a.value())
);
initializer.registerAnnotation(InlineComment.class, INLINE, a -> {
Map<String, String> map = new HashMap<>();
+1 -1
View File
@@ -47,4 +47,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
@@ -9,8 +9,8 @@ import java.io.File;
import java.nio.file.Path;
public abstract class FileConfigFactory<SOURCE extends FileConfigSource<?, ?, SOURCE>,
HOLDER extends ConfigurationHolder<SOURCE>, SELF extends FileConfigFactory<SOURCE, HOLDER, SELF>>
extends ConfigurationFactory<SOURCE, HOLDER, SELF> {
HOLDER extends ConfigurationHolder<SOURCE>, SELF extends FileConfigFactory<SOURCE, HOLDER, SELF>>
extends ConfigurationFactory<SOURCE, HOLDER, SELF> {
protected @NotNull File file;
@@ -17,7 +17,7 @@ import java.nio.file.Files;
import java.util.Objects;
public abstract class FileConfigSource<SECTION extends ConfigureSection, ORIGINAL, SELF extends FileConfigSource<SECTION, ORIGINAL, SELF>>
extends ConfigureSource<SECTION, ORIGINAL, SELF> {
extends ConfigureSource<SECTION, ORIGINAL, SELF> {
protected final @NotNull File file;
protected final @Nullable String resourcePath;
@@ -116,7 +116,7 @@ public abstract class FileConfigSource<SECTION extends ConfigureSection, ORIGINA
}
protected void saveResource(@NotNull String resourcePath, boolean replace)
throws IOException, IllegalArgumentException {
throws IOException, IllegalArgumentException {
Objects.requireNonNull(resourcePath, "ResourcePath cannot be null");
if (resourcePath.isEmpty()) throw new IllegalArgumentException("ResourcePath cannot be empty");
@@ -1,7 +1,5 @@
package cc.carm.lib.configuration.source.option;
import cc.carm.lib.configuration.source.option.ConfigurationOption;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -11,7 +9,7 @@ public interface FileConfigOptions {
* The charset of the file.
*/
ConfigurationOption<Charset> CHARSET = ConfigurationOption.of(StandardCharsets.UTF_8);
/**
* Whether to copy files from resource if exists.
*/
+1 -1
View File
@@ -117,4 +117,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
+1 -1
View File
@@ -48,4 +48,4 @@
</plugins>
</build>
</project>
</project>
+1 -1
View File
@@ -57,4 +57,4 @@
</plugins>
</build>
</project>
</project>
@@ -27,8 +27,8 @@ public class ConfiguredText<MSG, RECEIVER> extends ConfiguredValue<TextContents>
public static final ValueType<TextContents> TEXT_TYPE = ValueType.of(TextContents.class);
public static final ValueAdapter<TextContents> TEXT_ADAPTER = new ValueAdapter<>(TEXT_TYPE,
(h, t, d) -> d.serialize(),
(h, t, d) -> TextContents.deserialize(d)
(h, t, d) -> d.serialize(),
(h, t, d) -> TextContents.deserialize(d)
);
protected final @NotNull BiFunction<RECEIVER, String, String> parser;
@@ -51,8 +51,8 @@ public class ConfiguredText<MSG, RECEIVER> extends ConfiguredValue<TextContents>
public PreparedText<MSG, RECEIVER> prepare(@NotNull Object... values) {
return new PreparedText<MSG, RECEIVER>(resolve(), this.params)
.parser(this.parser).compiler(this.compiler)
.dispatcher(this.dispatcher).placeholders(values);
.parser(this.parser).compiler(this.compiler)
.dispatcher(this.dispatcher).placeholders(values);
}
/**
@@ -120,7 +120,7 @@ public class ConfiguredText<MSG, RECEIVER> extends ConfiguredValue<TextContents>
}
public abstract static class Builder<MSG, RECEIVER, SELF extends Builder<MSG, RECEIVER, SELF>>
extends AbstractConfigBuilder<TextContents, TextContents, ConfiguredText<MSG, RECEIVER>, ConfigurationHolder<?>, SELF> {
extends AbstractConfigBuilder<TextContents, TextContents, ConfiguredText<MSG, RECEIVER>, ConfigurationHolder<?>, SELF> {
protected @NotNull TextContents.Builder defaultBuilder = TextContents.builder();
protected @NotNull String[] params = new String[0];
@@ -21,7 +21,7 @@ import java.util.function.Function;
import java.util.function.UnaryOperator;
public abstract class ContentHandler<RECEIVER, SELF extends ContentHandler<RECEIVER, SELF>>
implements Replaceable<RECEIVER, SELF>, Insertable<RECEIVER, SELF> {
implements Replaceable<RECEIVER, SELF>, Insertable<RECEIVER, SELF> {
protected BiFunction<RECEIVER, String, String> parser = (receiver, value) -> value;
protected String lineSeparator = System.lineSeparator();
@@ -1,6 +1,5 @@
package cc.carm.lib.configuration.value.text.function;
import cc.carm.lib.configuration.value.text.data.TextContents;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@@ -11,7 +11,7 @@ import java.util.function.BiFunction;
import java.util.function.Consumer;
public abstract class TextParser<RECEIVER, SELF extends TextParser<RECEIVER, SELF>>
extends ContentHandler<RECEIVER, SELF> {
extends ContentHandler<RECEIVER, SELF> {
public abstract TextContents texts();
@@ -29,7 +29,7 @@ public class AppendLineInserter<RECEIVER> extends ContentInserter<RECEIVER> {
* </ul>
*/
public static final @NotNull Pattern APPEND_PATTERN = Pattern.compile(
"^(?:\\{(?<prefix>.*)})?#(?<id>.*)#(?:\\{(?<above>-?\\d+)(?:,(?<down>-?\\d+))?})?$"
"^(?:\\{(?<prefix>.*)})?#(?<id>.*)#(?:\\{(?<above>-?\\d+)(?:,(?<down>-?\\d+))?})?$"
);
public AppendLineInserter(int priority) {
@@ -50,9 +50,9 @@ public class AppendLineInserter<RECEIVER> extends ContentInserter<RECEIVER> {
String prefix = Optional.ofNullable(matcher.group("prefix")).orElse("");
int offsetAbove = Optional.ofNullable(matcher.group("above"))
.map(Integer::parseInt).orElse(0);
.map(Integer::parseInt).orElse(0);
int offsetDown = Optional.ofNullable(matcher.group("down"))
.map(Integer::parseInt).orElse(offsetAbove); // If offsetDown is not set, use offsetAbove
.map(Integer::parseInt).orElse(offsetAbove); // If offsetDown is not set, use offsetAbove
List<String> contents = new ArrayList<>();
@@ -23,7 +23,7 @@ public class OptionalLineInserter<RECEIVER> extends ContentInserter<RECEIVER> {
* </ul>
*/
public static final @NotNull Pattern OPTIONAL_PATTERN = Pattern.compile(
"^\\?\\[(?<id>.+)](?<content>.*)$"
"^\\?\\[(?<id>.+)](?<content>.*)$"
);
public OptionalLineInserter(int priority) {
@@ -12,9 +12,9 @@ import java.util.List;
public class ConfigTest {
public static final String[] WEBSITES = new String[]{
"https://carm.cc",
"https://www.baidu.com",
"https://www.google.com"
"https://carm.cc",
"https://www.baidu.com",
"https://www.google.com"
};
@Test
@@ -27,10 +27,10 @@ public class ConfigTest {
System.out.println("--------------------------");
List<String> str = AppMessages.WELCOME.prepare()
.placeholders("Carm")
.insert("guidance")
.insert("websites", WEBSITES)
.compile(System.out);
.placeholders("Carm")
.insert("guidance")
.insert("websites", WEBSITES)
.compile(System.out);
System.out.println("--------------------------");
@@ -33,17 +33,17 @@ public class ParseTest {
TextContents textContents = new TextContents(lines, optional);
PreparedText<String, PrintStream> msg = new PreparedText<String, PrintStream>(textContents)
.dispatcher((p, s) -> s.forEach(p::println))
.parser((p, s) -> s)
.compiler((p, s) -> s)
.replace( // Custom replacer, replace $UUID$ with Random UUID
"$UUID$", () -> UUID.randomUUID().toString()
);
.dispatcher((p, s) -> s.forEach(p::println))
.parser((p, s) -> s)
.compiler((p, s) -> s)
.replace( // Custom replacer, replace $UUID$ with Random UUID
"$UUID$", () -> UUID.randomUUID().toString()
);
msg.placeholder("name", "Carm")
.insert("guidance")
.insert("click")
.insert("websites", "Baidu", "Bilibili", "Google");
.insert("guidance")
.insert("click")
.insert("websites", "Baidu", "Bilibili", "Google");
System.out.println("----------------------------");
@@ -7,22 +7,22 @@ import cc.carm.lib.configuration.annotation.ConfigPath;
public interface AppMessages extends Configuration {
ConfiguredMsg WELCOME = ConfiguredMsg.builder()
.defaults(
"Hello, %(name)",
"#more-creating#{1}",
"This is a test message",
"#guidance#",
"{- }#websites#{0,1}",
"Thanks for your reading!")
.optional("guidance", "To get more information for %(name), see:")
.params("name").build();
.defaults(
"Hello, %(name)",
"#more-creating#{1}",
"This is a test message",
"#guidance#",
"{- }#websites#{0,1}",
"Thanks for your reading!")
.optional("guidance", "To get more information for %(name), see:")
.params("name").build();
ConfiguredMsg NO_PERMISSION = ConfiguredMsg.builder()
.defaults("Sorry! But you don't have permissions to do this.")
.build();
.defaults("Sorry! But you don't have permissions to do this.")
.build();
ConfiguredMsg NOT_AVAILABLE = ConfiguredMsg.builder()
.defaults("Error! Service is not available now.", "Please contact your system manager.")
.build();
.defaults("Error! Service is not available now.", "Please contact your system manager.")
.build();
}
@@ -20,11 +20,11 @@ public class ConfiguredMsg extends ConfiguredText<String, PrintStream> {
public ConfiguredMsg(@NotNull ValueManifest<TextContents, TextContents> manifest,
@NotNull String[] params) {
super(
manifest,
(p, s) -> s,
(p, s) -> s,
(p, s) -> s.forEach(p::println),
params
manifest,
(p, s) -> s,
(p, s) -> s,
(p, s) -> s.forEach(p::println),
params
);
}
+1 -1
View File
@@ -48,4 +48,4 @@
</plugins>
</build>
</project>
</project>
+1 -1
View File
@@ -48,4 +48,4 @@
</plugins>
</build>
</project>
</project>