mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-05 02:58:20 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aa4225dbba | |||
| ddd33154be | |||
| 727c26a2fb | |||
| 9c95a16d90 | |||
| 92c05f1a59 | |||
| 739ed41885 | |||
| a66da01996 | |||
| 6dc0447502 | |||
| c49d904665 | |||
| b756074ddc | |||
| 9e3dff3e95 | |||
| fd01d9b7ef | |||
| 0f8383bbf3 | |||
| 1232c7c4da | |||
| 7ac39da4e9 | |||
| bf89f583db | |||
| 03c69ba3a2 | |||
| d9cbd1a283 | |||
| 96e90dd71b | |||
| a9f3d829bd |
+3
-3
@@ -5,12 +5,12 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.5.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package cc.carm.lib.configuration.core.builder;
|
package cc.carm.lib.configuration.core.builder;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.ConfigValue;
|
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public abstract class AbstractConfigBuilder<T, B extends AbstractConfigBuilder<T, B, P>, P extends ConfigurationProvider<?>> {
|
public abstract class AbstractConfigBuilder<T, B extends AbstractConfigBuilder<T, B, P>, P extends ConfigurationProvider<?>> {
|
||||||
|
|
||||||
@@ -61,4 +63,15 @@ public abstract class AbstractConfigBuilder<T, B extends AbstractConfigBuilder<T
|
|||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull B defaults(@NotNull Supplier<@Nullable T> defaultValueSupplier) {
|
||||||
|
return defaults(defaultValueSupplier.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @NotNull ValueManifest<T> buildManifest() {
|
||||||
|
return ValueManifest.of(
|
||||||
|
this.provider, this.path,
|
||||||
|
this.headerComments, this.inlineComment, this.defaultValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -65,9 +65,7 @@ public class SourceListBuilder<S, V> extends CommonConfigBuilder<List<V>, Source
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull ConfiguredList<V> build() {
|
public @NotNull ConfiguredList<V> build() {
|
||||||
return new ConfiguredList<>(
|
return new ConfiguredList<>(
|
||||||
this.provider, this.path,
|
buildManifest(), this.valueClass,
|
||||||
this.headerComments, this.inlineComment,
|
|
||||||
this.valueClass, this.defaultValue,
|
|
||||||
this.sourceParser.andThen(this.valueParser),
|
this.sourceParser.andThen(this.valueParser),
|
||||||
this.valueSerializer.andThen(sourceSerializer)
|
this.valueSerializer.andThen(sourceSerializer)
|
||||||
);
|
);
|
||||||
|
|||||||
+10
-4
@@ -2,10 +2,12 @@ package cc.carm.lib.configuration.core.builder.map;
|
|||||||
|
|
||||||
import cc.carm.lib.configuration.core.builder.CommonConfigBuilder;
|
import cc.carm.lib.configuration.core.builder.CommonConfigBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredMap;
|
import cc.carm.lib.configuration.core.value.type.ConfiguredMap;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class SourceMapBuilder<M extends Map<K, V>, S, K, V> extends CommonConfigBuilder<M, SourceMapBuilder<M, S, K, V>> {
|
public class SourceMapBuilder<M extends Map<K, V>, S, K, V> extends CommonConfigBuilder<M, SourceMapBuilder<M, S, K, V>> {
|
||||||
@@ -51,6 +53,12 @@ public class SourceMapBuilder<M extends Map<K, V>, S, K, V> extends CommonConfig
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull SourceMapBuilder<M, S, K, V> defaults(@NotNull Consumer<M> factory) {
|
||||||
|
M map = supplier.get();
|
||||||
|
factory.accept(map);
|
||||||
|
return defaults(map);
|
||||||
|
}
|
||||||
|
|
||||||
public @NotNull SourceMapBuilder<M, S, K, V> parseKey(@NotNull ConfigDataFunction<String, K> parser) {
|
public @NotNull SourceMapBuilder<M, S, K, V> parseKey(@NotNull ConfigDataFunction<String, K> parser) {
|
||||||
this.keyParser = parser;
|
this.keyParser = parser;
|
||||||
return this;
|
return this;
|
||||||
@@ -89,10 +97,8 @@ public class SourceMapBuilder<M extends Map<K, V>, S, K, V> extends CommonConfig
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull ConfiguredMap<K, V> build() {
|
public @NotNull ConfiguredMap<K, V> build() {
|
||||||
return new ConfiguredMap<>(
|
return new ConfiguredMap<>(
|
||||||
this.provider, this.path,
|
new ValueManifest<>(provider, path, headerComments, inlineComment, defaultValue),
|
||||||
this.headerComments, this.inlineComment,
|
this.supplier, this.keyClass, this.keyParser,
|
||||||
this.defaultValue, this.supplier,
|
|
||||||
this.keyClass, this.keyParser,
|
|
||||||
this.valueClass, this.sourceParser.andThen(this.valueParser),
|
this.valueClass, this.sourceParser.andThen(this.valueParser),
|
||||||
this.keySerializer, this.valueSerializer.andThen(this.sourceSerializer)
|
this.keySerializer, this.valueSerializer.andThen(this.sourceSerializer)
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-6
@@ -44,12 +44,7 @@ public class SectionValueBuilder<V>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ConfiguredSection<V> build() {
|
public @NotNull ConfiguredSection<V> build() {
|
||||||
return new ConfiguredSection<>(
|
return new ConfiguredSection<>(buildManifest(), this.valueClass, this.parser, this.serializer);
|
||||||
this.provider, this.path,
|
|
||||||
this.headerComments, this.inlineComment,
|
|
||||||
this.valueClass, this.defaultValue,
|
|
||||||
this.parser, this.serializer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -57,9 +57,7 @@ public class SourceValueBuilder<S, V> extends CommonConfigBuilder<V, SourceValue
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull ConfiguredValue<V> build() {
|
public @NotNull ConfiguredValue<V> build() {
|
||||||
return new ConfiguredValue<>(
|
return new ConfiguredValue<>(
|
||||||
this.provider, this.path,
|
buildManifest(), this.valueClass,
|
||||||
this.headerComments, this.inlineComment,
|
|
||||||
this.valueClass, this.defaultValue,
|
|
||||||
this.valueParser.compose(this.sourceParser),
|
this.valueParser.compose(this.sourceParser),
|
||||||
this.valueSerializer.andThen(sourceSerializer)
|
this.valueSerializer.andThen(sourceSerializer)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -62,6 +62,94 @@ public interface ConfigDataFunction<T, R> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static <V> @NotNull ConfigDataFunction<String, V> parseString(Class<V> valueClass) {
|
||||||
|
return (input) -> {
|
||||||
|
if (valueClass.isInstance(input)) return valueClass.cast(input);
|
||||||
|
else throw new IllegalArgumentException("Cannot cast string to " + valueClass.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Integer> intValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Integer) {
|
||||||
|
return (Integer) input;
|
||||||
|
} else if (input instanceof Number) {
|
||||||
|
return ((Number) input).intValue();
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Integer.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Short> shortValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Short) {
|
||||||
|
return (Short) input;
|
||||||
|
} else if (input instanceof Number) {
|
||||||
|
return ((Number) input).shortValue();
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Short.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Double> doubleValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Double) {
|
||||||
|
return (Double) input;
|
||||||
|
} else if (input instanceof Number) {
|
||||||
|
return ((Number) input).doubleValue();
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Double.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Byte> byteValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Byte) {
|
||||||
|
return (Byte) input;
|
||||||
|
} else if (input instanceof Number) {
|
||||||
|
return ((Number) input).byteValue();
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Byte.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Float> floatValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Float) {
|
||||||
|
return (Float) input;
|
||||||
|
} else if (input instanceof Number) {
|
||||||
|
return ((Number) input).floatValue();
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Float.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Long> longValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Long) {
|
||||||
|
return (Long) input;
|
||||||
|
} else if (input instanceof Number) {
|
||||||
|
return ((Number) input).longValue();
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Long.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
static @NotNull ConfigDataFunction<Object, Boolean> booleanValue() {
|
||||||
|
return (input) -> {
|
||||||
|
if (input instanceof Boolean) {
|
||||||
|
return (Boolean) input;
|
||||||
|
} else if (input instanceof String) {
|
||||||
|
String s = (String) input;
|
||||||
|
return Boolean.parseBoolean(s) || "yes".equalsIgnoreCase(s);
|
||||||
|
} else if (input instanceof Integer) {
|
||||||
|
return ((Integer) input) == 1;
|
||||||
|
} else throw new IllegalArgumentException("Cannot cast value to " + Boolean.class.getName());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,92 +90,39 @@ public interface ConfigValueParser<T, R> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
|
||||||
static @NotNull <T> ConfigValueParser<T, String> castToString(Class<T> clazz) {
|
|
||||||
return (input, defaultValue) -> {
|
|
||||||
if (input instanceof String) return (String) input;
|
|
||||||
else return input.toString();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Integer> intValue() {
|
static @NotNull ConfigValueParser<Object, Integer> intValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.intValue().parse(input);
|
||||||
if (input instanceof Integer) {
|
|
||||||
return (Integer) input;
|
|
||||||
} else if (input instanceof Number) {
|
|
||||||
return ((Number) input).intValue();
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Integer.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Short> shortValue() {
|
static @NotNull ConfigValueParser<Object, Short> shortValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.shortValue().parse(input);
|
||||||
if (input instanceof Short) {
|
|
||||||
return (Short) input;
|
|
||||||
} else if (input instanceof Number) {
|
|
||||||
return ((Number) input).shortValue();
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Short.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Double> doubleValue() {
|
static @NotNull ConfigValueParser<Object, Double> doubleValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.doubleValue().parse(input);
|
||||||
if (input instanceof Double) {
|
|
||||||
return (Double) input;
|
|
||||||
} else if (input instanceof Number) {
|
|
||||||
return ((Number) input).doubleValue();
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Double.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Byte> byteValue() {
|
static @NotNull ConfigValueParser<Object, Byte> byteValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.byteValue().parse(input);
|
||||||
if (input instanceof Byte) {
|
|
||||||
return (Byte) input;
|
|
||||||
} else if (input instanceof Number) {
|
|
||||||
return ((Number) input).byteValue();
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Byte.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Float> floatValue() {
|
static @NotNull ConfigValueParser<Object, Float> floatValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.floatValue().parse(input);
|
||||||
if (input instanceof Float) {
|
|
||||||
return (Float) input;
|
|
||||||
} else if (input instanceof Number) {
|
|
||||||
return ((Number) input).floatValue();
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Float.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Long> longValue() {
|
static @NotNull ConfigValueParser<Object, Long> longValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.longValue().parse(input);
|
||||||
if (input instanceof Long) {
|
|
||||||
return (Long) input;
|
|
||||||
} else if (input instanceof Number) {
|
|
||||||
return ((Number) input).longValue();
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Long.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
static @NotNull ConfigValueParser<Object, Boolean> booleanValue() {
|
static @NotNull ConfigValueParser<Object, Boolean> booleanValue() {
|
||||||
return (input, defaultValue) -> {
|
return (input, defaultValue) -> ConfigDataFunction.booleanValue().parse(input);
|
||||||
if (input instanceof Boolean) {
|
|
||||||
return (Boolean) input;
|
|
||||||
} else if (input instanceof String) {
|
|
||||||
String s = (String) input;
|
|
||||||
return Boolean.parseBoolean(s) || "yes".equalsIgnoreCase(s);
|
|
||||||
} else if (input instanceof Integer) {
|
|
||||||
return ((Integer) input) == 1;
|
|
||||||
} else throw new IllegalArgumentException("Cannot cast value to " + Boolean.class.getName());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Unmodifiable;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public abstract class ConfigurationComments {
|
public class ConfigurationComments {
|
||||||
|
|
||||||
protected final @NotNull Map<String, List<String>> headerComments = new HashMap<>();
|
protected final @NotNull Map<String, List<String>> headerComments = new HashMap<>();
|
||||||
protected final @NotNull Map<String, String> inlineComments = new HashMap<>();
|
protected final @NotNull Map<String, String> inlineComments = new HashMap<>();
|
||||||
|
|||||||
@@ -2,62 +2,34 @@ package cc.carm.lib.configuration.core.value;
|
|||||||
|
|
||||||
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public abstract class ConfigValue<T> {
|
public abstract class ConfigValue<T> extends ValueManifest<T> {
|
||||||
|
|
||||||
public static @NotNull ConfigBuilder builder() {
|
public static @NotNull ConfigBuilder builder() {
|
||||||
return new ConfigBuilder();
|
return new ConfigBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected @Nullable ConfigurationProvider<?> provider;
|
public ConfigValue(@NotNull ValueManifest<T> manifest) {
|
||||||
protected @Nullable String configPath;
|
super(manifest.provider, manifest.configPath, manifest.headerComments, manifest.inlineComment, manifest.defaultValue);
|
||||||
|
}
|
||||||
protected @Nullable List<String> headerComments;
|
|
||||||
protected @Nullable String inlineComments;
|
|
||||||
|
|
||||||
protected @Nullable T defaultValue;
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ConfigValue(@Nullable ConfigurationProvider<?> provider, @Nullable String configPath,
|
public ConfigValue(@Nullable ConfigurationProvider<?> provider, @Nullable String configPath,
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
||||||
@Nullable T defaultValue) {
|
@Nullable T defaultValue) {
|
||||||
this.provider = provider;
|
super(provider, configPath, headerComments, inlineComments, defaultValue);
|
||||||
this.configPath = configPath;
|
|
||||||
this.headerComments = headerComments;
|
|
||||||
this.inlineComments = inlineComments;
|
|
||||||
this.defaultValue = defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(@NotNull ConfigurationProvider<?> provider, boolean saveDefault, @NotNull String configPath,
|
public void initialize(@NotNull ConfigurationProvider<?> provider, boolean saveDefault, @NotNull String configPath,
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments) {
|
@Nullable List<String> headerComments, @Nullable String inlineComments) {
|
||||||
if (this.provider == null) this.provider = provider;
|
this.initialize(provider, configPath, headerComments, inlineComments);
|
||||||
if (this.configPath == null) this.configPath = configPath;
|
|
||||||
if (this.headerComments == null) this.headerComments = headerComments;
|
|
||||||
if (this.inlineComments == null) this.inlineComments = inlineComments;
|
|
||||||
if (saveDefault) setDefault();
|
if (saveDefault) setDefault();
|
||||||
|
|
||||||
if (getHeaderComments() != null) {
|
|
||||||
this.provider.setHeaderComment(getConfigPath(), getHeaderComments());
|
|
||||||
}
|
|
||||||
if (getInlineComments() != null) {
|
|
||||||
this.provider.setInlineComment(getConfigPath(), getInlineComments());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable T getDefaultValue() {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultValue(@Nullable T defaultValue) {
|
|
||||||
this.defaultValue = defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,39 +103,4 @@ public abstract class ConfigValue<T> {
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull ConfigurationProvider<?> getProvider() {
|
|
||||||
return Optional.ofNullable(this.provider)
|
|
||||||
.orElseThrow(() -> new IllegalStateException("Value(" + configPath + ") does not have a provider."));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final @NotNull ConfigurationWrapper<?> getConfiguration() {
|
|
||||||
try {
|
|
||||||
return getProvider().getConfiguration();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new IllegalStateException("Value(" + configPath + ") has not been initialized", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getConfigPath() {
|
|
||||||
return Optional.ofNullable(this.configPath)
|
|
||||||
.orElseThrow(() -> new IllegalStateException("No section path provided."));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Object getValue() {
|
|
||||||
return getConfiguration().get(getConfigPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setValue(@Nullable Object value) {
|
|
||||||
getConfiguration().set(getConfigPath(), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getInlineComments() {
|
|
||||||
return inlineComments;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unmodifiable
|
|
||||||
public @Nullable List<String> getHeaderComments() {
|
|
||||||
return headerComments;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package cc.carm.lib.configuration.core.value;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class ValueManifest<T> {
|
||||||
|
|
||||||
|
public static <V> ValueManifest<V> of(@Nullable ConfigurationProvider<?> provider, @Nullable String configPath,
|
||||||
|
@Nullable List<String> headerComments, @Nullable String inlineComments) {
|
||||||
|
return new ValueManifest<>(provider, configPath, headerComments, inlineComments, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <V> ValueManifest<V> of(@Nullable ConfigurationProvider<?> provider, @Nullable String configPath,
|
||||||
|
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
||||||
|
@Nullable V defaultValue) {
|
||||||
|
return new ValueManifest<>(provider, configPath, headerComments, inlineComments, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @Nullable ConfigurationProvider<?> provider;
|
||||||
|
protected @Nullable String configPath;
|
||||||
|
|
||||||
|
protected @Nullable List<String> headerComments;
|
||||||
|
protected @Nullable String inlineComment;
|
||||||
|
|
||||||
|
protected @Nullable T defaultValue;
|
||||||
|
|
||||||
|
public ValueManifest(@Nullable ConfigurationProvider<?> provider, @Nullable String configPath,
|
||||||
|
@Nullable List<String> headerComments, @Nullable String inlineComment,
|
||||||
|
@Nullable T defaultValue) {
|
||||||
|
this.provider = provider;
|
||||||
|
this.configPath = configPath;
|
||||||
|
this.headerComments = headerComments;
|
||||||
|
this.inlineComment = inlineComment;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initialize(@NotNull ConfigurationProvider<?> provider, @NotNull String configPath,
|
||||||
|
@Nullable List<String> headerComments, @Nullable String inlineComments) {
|
||||||
|
if (this.provider == null) this.provider = provider;
|
||||||
|
if (this.configPath == null) this.configPath = configPath;
|
||||||
|
if (this.headerComments == null) this.headerComments = headerComments;
|
||||||
|
if (this.inlineComment == null) this.inlineComment = inlineComments;
|
||||||
|
|
||||||
|
if (getHeaderComments() != null) {
|
||||||
|
this.provider.setHeaderComment(getConfigPath(), getHeaderComments());
|
||||||
|
}
|
||||||
|
if (getInlineComment() != null) {
|
||||||
|
this.provider.setInlineComment(getConfigPath(), getInlineComment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable T getDefaultValue() {
|
||||||
|
return this.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(@Nullable T defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull ConfigurationProvider<?> getProvider() {
|
||||||
|
return Optional.ofNullable(this.provider)
|
||||||
|
.orElseThrow(() -> new IllegalStateException("Value(" + configPath + ") does not have a provider."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public final @NotNull ConfigurationWrapper<?> getConfiguration() {
|
||||||
|
try {
|
||||||
|
return getProvider().getConfiguration();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new IllegalStateException("Value(" + configPath + ") has not been initialized", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getConfigPath() {
|
||||||
|
return Optional.ofNullable(this.configPath)
|
||||||
|
.orElseThrow(() -> new IllegalStateException("No section path provided."));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object getValue() {
|
||||||
|
String path = getConfigPath(); // 当未指定路径时,优先抛出异常
|
||||||
|
return getConfiguration().get(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setValue(@Nullable Object value) {
|
||||||
|
getConfiguration().set(getConfigPath(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getInlineComment() {
|
||||||
|
return inlineComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unmodifiable
|
||||||
|
public @Nullable List<String> getHeaderComments() {
|
||||||
|
return headerComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,21 +1,18 @@
|
|||||||
package cc.carm.lib.configuration.core.value.impl;
|
package cc.carm.lib.configuration.core.value.impl;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
|
||||||
import cc.carm.lib.configuration.core.value.ConfigValue;
|
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||||
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class CachedConfigValue<T> extends ConfigValue<T> {
|
public abstract class CachedConfigValue<T> extends ConfigValue<T> {
|
||||||
|
|
||||||
|
|
||||||
protected @Nullable T cachedValue;
|
protected @Nullable T cachedValue;
|
||||||
protected long parsedTime = -1;
|
protected long parsedTime = -1;
|
||||||
|
|
||||||
public CachedConfigValue(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
public CachedConfigValue(@NotNull ValueManifest<T> manifest) {
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
super(manifest);
|
||||||
@Nullable T defaultValue) {
|
|
||||||
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected T updateCache(T value) {
|
protected T updateCache(T value) {
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package cc.carm.lib.configuration.core.value.type;
|
package cc.carm.lib.configuration.core.value.type;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
|
||||||
import cc.carm.lib.configuration.core.builder.list.ConfigListBuilder;
|
import cc.carm.lib.configuration.core.builder.list.ConfigListBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class ConfiguredList<V> extends CachedConfigValue<List<V>> {
|
public class ConfiguredList<V> extends CachedConfigValue<List<V>> implements List<V> {
|
||||||
|
|
||||||
public static <V> @NotNull ConfigListBuilder<V> builder(@NotNull Class<V> valueClass) {
|
public static <V> @NotNull ConfigListBuilder<V> builder(@NotNull Class<V> valueClass) {
|
||||||
return builder().asList(valueClass);
|
return builder().asList(valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@HeaderComment
|
|
||||||
protected final @NotNull Class<V> valueClass;
|
protected final @NotNull Class<V> valueClass;
|
||||||
|
|
||||||
protected final @NotNull ConfigDataFunction<Object, V> parser;
|
protected final @NotNull ConfigDataFunction<Object, V> parser;
|
||||||
protected final @NotNull ConfigDataFunction<V, Object> serializer;
|
protected final @NotNull ConfigDataFunction<V, Object> serializer;
|
||||||
|
|
||||||
public ConfiguredList(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
public ConfiguredList(@NotNull ValueManifest<List<V>> manifest, @NotNull Class<V> valueClass,
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
|
||||||
@NotNull Class<V> valueClass, @Nullable List<V> defaultValue,
|
|
||||||
@NotNull ConfigDataFunction<Object, V> parser,
|
@NotNull ConfigDataFunction<Object, V> parser,
|
||||||
@NotNull ConfigDataFunction<V, Object> serializer) {
|
@NotNull ConfigDataFunction<V, Object> serializer) {
|
||||||
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
|
super(manifest);
|
||||||
this.valueClass = valueClass;
|
this.valueClass = valueClass;
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
this.serializer = serializer;
|
this.serializer = serializer;
|
||||||
@@ -38,8 +35,9 @@ public class ConfiguredList<V> extends CachedConfigValue<List<V>> {
|
|||||||
public @NotNull List<V> get() {
|
public @NotNull List<V> get() {
|
||||||
if (isExpired()) { // 已过时的数据,需要重新解析一次。
|
if (isExpired()) { // 已过时的数据,需要重新解析一次。
|
||||||
List<V> list = new ArrayList<>();
|
List<V> list = new ArrayList<>();
|
||||||
List<?> data = getConfiguration().getList(getConfigPath());
|
List<?> data = getConfiguration().contains(getConfigPath()) ?
|
||||||
if (data == null || data.isEmpty()) return useOrDefault(list);
|
getConfiguration().getList(getConfigPath()) : null;
|
||||||
|
if (data == null) return useOrDefault(list);
|
||||||
for (Object dataVal : data) {
|
for (Object dataVal : data) {
|
||||||
if (dataVal == null) continue;
|
if (dataVal == null) continue;
|
||||||
try {
|
try {
|
||||||
@@ -54,6 +52,25 @@ public class ConfiguredList<V> extends CachedConfigValue<List<V>> {
|
|||||||
else return new ArrayList<>();
|
else return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V get(int index) {
|
||||||
|
return get().get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> @NotNull T modifyValue(Function<List<V>, T> function) {
|
||||||
|
List<V> list = get();
|
||||||
|
T result = function.apply(list);
|
||||||
|
set(list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull List<V> modifyList(Consumer<List<V>> consumer) {
|
||||||
|
List<V> list = get();
|
||||||
|
consumer.accept(list);
|
||||||
|
set(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(@Nullable List<V> value) {
|
public void set(@Nullable List<V> value) {
|
||||||
updateCache(value);
|
updateCache(value);
|
||||||
@@ -72,5 +89,121 @@ public class ConfiguredList<V> extends CachedConfigValue<List<V>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V set(int index, V element) {
|
||||||
|
return modifyValue(list -> list.set(index, element));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return get().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return get().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(Object o) {
|
||||||
|
return get().contains(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Iterator<V> iterator() {
|
||||||
|
return get().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Object @NotNull [] toArray() {
|
||||||
|
return get().toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public <T> T @NotNull [] toArray(@NotNull T[] a) {
|
||||||
|
return get().toArray(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsAll(@NotNull Collection<?> c) {
|
||||||
|
return new HashSet<>(get()).containsAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(V v) {
|
||||||
|
modifyValue(list -> list.add(v));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(int index, V element) {
|
||||||
|
modifyList(list -> list.add(index, element));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(@NotNull Collection<? extends V> c) {
|
||||||
|
return modifyValue(list -> list.addAll(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, @NotNull Collection<? extends V> c) {
|
||||||
|
return modifyValue(list -> list.addAll(index, c));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object o) {
|
||||||
|
return modifyValue(list -> list.remove(o));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V remove(int index) {
|
||||||
|
return modifyValue(list -> list.remove(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(@NotNull Collection<?> c) {
|
||||||
|
return modifyValue(list -> list.removeAll(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(@NotNull Collection<?> c) {
|
||||||
|
return modifyValue(list -> list.retainAll(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
modifyList(List::clear);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int indexOf(Object o) {
|
||||||
|
return get().indexOf(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int lastIndexOf(Object o) {
|
||||||
|
return get().lastIndexOf(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public ListIterator<V> listIterator() {
|
||||||
|
return get().listIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public ListIterator<V> listIterator(int index) {
|
||||||
|
return get().listIterator(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public List<V> subList(int fromIndex, int toIndex) {
|
||||||
|
return get().subList(fromIndex, toIndex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,22 @@ package cc.carm.lib.configuration.core.value.type;
|
|||||||
|
|
||||||
import cc.carm.lib.configuration.core.builder.map.ConfigMapBuilder;
|
import cc.carm.lib.configuration.core.builder.map.ConfigMapBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||||
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> {
|
public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> implements Map<K, V> {
|
||||||
|
|
||||||
public static <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> builder(@NotNull Class<K> keyClass,
|
public static <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> builder(@NotNull Class<K> keyClass,
|
||||||
@NotNull Class<V> valueClass) {
|
@NotNull Class<V> valueClass) {
|
||||||
@@ -32,15 +35,17 @@ public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> {
|
|||||||
protected final @NotNull ConfigDataFunction<K, String> keySerializer;
|
protected final @NotNull ConfigDataFunction<K, String> keySerializer;
|
||||||
protected final @NotNull ConfigDataFunction<V, Object> valueSerializer;
|
protected final @NotNull ConfigDataFunction<V, Object> valueSerializer;
|
||||||
|
|
||||||
public ConfiguredMap(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
public ConfiguredMap(@NotNull ValueManifest<Map<K, V>> manifest
|
||||||
@Nullable Map<K, V> defaultValue, @NotNull Supplier<? extends Map<K, V>> supplier,
|
,
|
||||||
|
@NotNull Supplier<? extends Map<K, V>> mapObjSupplier,
|
||||||
@NotNull Class<K> keyClass, @NotNull ConfigDataFunction<String, K> keyParser,
|
@NotNull Class<K> keyClass, @NotNull ConfigDataFunction<String, K> keyParser,
|
||||||
@NotNull Class<V> valueClass, @NotNull ConfigDataFunction<Object, V> valueParser,
|
@NotNull Class<V> valueClass, @NotNull ConfigDataFunction<Object, V> valueParser,
|
||||||
@NotNull ConfigDataFunction<K, String> keySerializer,
|
@NotNull ConfigDataFunction<K, String> keySerializer,
|
||||||
@NotNull ConfigDataFunction<V, Object> valueSerializer) {
|
@NotNull ConfigDataFunction<V, Object> valueSerializer) {
|
||||||
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
|
super(manifest
|
||||||
this.supplier = supplier;
|
);
|
||||||
|
this.supplier = mapObjSupplier;
|
||||||
this.keyClass = keyClass;
|
this.keyClass = keyClass;
|
||||||
this.valueClass = valueClass;
|
this.valueClass = valueClass;
|
||||||
this.keyParser = keyParser;
|
this.keyParser = keyParser;
|
||||||
@@ -103,7 +108,12 @@ public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Map<K, V> value) {
|
public V get(Object key) {
|
||||||
|
return get().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(@Nullable Map<K, V> value) {
|
||||||
updateCache(value);
|
updateCache(value);
|
||||||
if (value == null) setValue(null);
|
if (value == null) setValue(null);
|
||||||
else {
|
else {
|
||||||
@@ -122,5 +132,78 @@ public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> @NotNull T modifyValue(Function<Map<K, V>, T> function) {
|
||||||
|
Map<K, V> m = get();
|
||||||
|
T result = function.apply(m);
|
||||||
|
set(m);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Map<K, V> modifyMap(Consumer<Map<K, V>> consumer) {
|
||||||
|
Map<K, V> m = get();
|
||||||
|
consumer.accept(m);
|
||||||
|
set(m);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return get().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return get().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsKey(Object key) {
|
||||||
|
return get().containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsValue(Object value) {
|
||||||
|
return get().containsValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public V put(K key, V value) {
|
||||||
|
return modifyValue(m -> m.put(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V remove(Object key) {
|
||||||
|
return modifyValue(m -> m.remove(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putAll(@NotNull Map<? extends K, ? extends V> m) {
|
||||||
|
modifyMap(map -> map.putAll(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
modifyMap(Map::clear);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<K> keySet() {
|
||||||
|
return get().keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Collection<V> values() {
|
||||||
|
return get().values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
@Unmodifiable
|
||||||
|
public Set<Entry<K, V>> entrySet() {
|
||||||
|
return get().entrySet();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ package cc.carm.lib.configuration.core.value.type;
|
|||||||
import cc.carm.lib.configuration.core.builder.value.SectionValueBuilder;
|
import cc.carm.lib.configuration.core.builder.value.SectionValueBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||||
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ConfiguredSection<V> extends CachedConfigValue<V> {
|
public class ConfiguredSection<V> extends CachedConfigValue<V> {
|
||||||
|
|
||||||
|
|
||||||
public static <V> @NotNull SectionValueBuilder<V> builder(@NotNull Class<V> valueClass) {
|
public static <V> @NotNull SectionValueBuilder<V> builder(@NotNull Class<V> valueClass) {
|
||||||
return builder().asValue(valueClass).fromSection();
|
return builder().asValue(valueClass).fromSection();
|
||||||
}
|
}
|
||||||
@@ -24,12 +24,10 @@ public class ConfiguredSection<V> extends CachedConfigValue<V> {
|
|||||||
protected final @NotNull ConfigValueParser<ConfigurationWrapper<?>, V> parser;
|
protected final @NotNull ConfigValueParser<ConfigurationWrapper<?>, V> parser;
|
||||||
protected final @NotNull ConfigDataFunction<V, ? extends Map<String, Object>> serializer;
|
protected final @NotNull ConfigDataFunction<V, ? extends Map<String, Object>> serializer;
|
||||||
|
|
||||||
public ConfiguredSection(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
public ConfiguredSection(@NotNull ValueManifest<V> manifest, @NotNull Class<V> valueClass,
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
|
||||||
@NotNull Class<V> valueClass, @Nullable V defaultValue,
|
|
||||||
@NotNull ConfigValueParser<ConfigurationWrapper<?>, V> parser,
|
@NotNull ConfigValueParser<ConfigurationWrapper<?>, V> parser,
|
||||||
@NotNull ConfigDataFunction<V, ? extends Map<String, Object>> serializer) {
|
@NotNull ConfigDataFunction<V, ? extends Map<String, Object>> serializer) {
|
||||||
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
|
super(manifest);
|
||||||
this.valueClass = valueClass;
|
this.valueClass = valueClass;
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
this.serializer = serializer;
|
this.serializer = serializer;
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ package cc.carm.lib.configuration.core.value.type;
|
|||||||
import cc.carm.lib.configuration.core.builder.value.ConfigValueBuilder;
|
import cc.carm.lib.configuration.core.builder.value.ConfigValueBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ConfiguredValue<V> extends CachedConfigValue<V> {
|
public class ConfiguredValue<V> extends CachedConfigValue<V> {
|
||||||
@@ -30,13 +29,10 @@ public class ConfiguredValue<V> extends CachedConfigValue<V> {
|
|||||||
protected final @NotNull ConfigValueParser<Object, V> parser;
|
protected final @NotNull ConfigValueParser<Object, V> parser;
|
||||||
protected final @NotNull ConfigDataFunction<V, Object> serializer;
|
protected final @NotNull ConfigDataFunction<V, Object> serializer;
|
||||||
|
|
||||||
public ConfiguredValue(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
public ConfiguredValue(@NotNull ValueManifest<V> manifest, @NotNull Class<V> valueClass,
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
|
||||||
@NotNull Class<V> valueClass, @Nullable V defaultValue,
|
|
||||||
@NotNull ConfigValueParser<Object, V> parser,
|
@NotNull ConfigValueParser<Object, V> parser,
|
||||||
@NotNull ConfigDataFunction<V, Object> serializer) {
|
@NotNull ConfigDataFunction<V, Object> serializer) {
|
||||||
|
super(manifest);
|
||||||
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
|
|
||||||
this.valueClass = valueClass;
|
this.valueClass = valueClass;
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
this.serializer = serializer;
|
this.serializer = serializer;
|
||||||
|
|||||||
+24
-3
@@ -5,12 +5,12 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.5.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -28,4 +28,25 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package cc.carm.lib.configuration.demo.tests;
|
package cc.carm.lib.configuration.demo.tests;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.configuration.demo.tests.model.TestModel;
|
|
||||||
import cc.carm.lib.configuration.demo.tests.conf.DemoConfiguration;
|
import cc.carm.lib.configuration.demo.tests.conf.DemoConfiguration;
|
||||||
import cc.carm.lib.configuration.demo.tests.conf.TestConfiguration;
|
import cc.carm.lib.configuration.demo.tests.conf.TestConfiguration;
|
||||||
|
import cc.carm.lib.configuration.demo.tests.model.TestModel;
|
||||||
|
import org.jetbrains.annotations.TestOnly;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,6 +14,7 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
public class ConfigurationTest {
|
public class ConfigurationTest {
|
||||||
|
|
||||||
|
@TestOnly
|
||||||
public static void testDemo(ConfigurationProvider<?> provider) {
|
public static void testDemo(ConfigurationProvider<?> provider) {
|
||||||
provider.initialize(DemoConfiguration.class);
|
provider.initialize(DemoConfiguration.class);
|
||||||
|
|
||||||
@@ -30,16 +32,25 @@ public class ConfigurationTest {
|
|||||||
System.out.println("after: " + DemoConfiguration.Sub.UUID_CONFIG_VALUE.get());
|
System.out.println("after: " + DemoConfiguration.Sub.UUID_CONFIG_VALUE.get());
|
||||||
|
|
||||||
System.out.println("> Test List:");
|
System.out.println("> Test List:");
|
||||||
DemoConfiguration.Sub.That.OPERATORS.getNotNull().forEach(System.out::println);
|
|
||||||
|
System.out.println(" Before:");
|
||||||
|
DemoConfiguration.Sub.That.OPERATORS.forEach(System.out::println);
|
||||||
List<UUID> operators = IntStream.range(0, 5).mapToObj(i -> UUID.randomUUID()).collect(Collectors.toList());
|
List<UUID> operators = IntStream.range(0, 5).mapToObj(i -> UUID.randomUUID()).collect(Collectors.toList());
|
||||||
DemoConfiguration.Sub.That.OPERATORS.set(operators);
|
DemoConfiguration.Sub.That.OPERATORS.set(operators);
|
||||||
|
System.out.println(" After:");
|
||||||
|
DemoConfiguration.Sub.That.OPERATORS.forEach(System.out::println);
|
||||||
|
|
||||||
|
System.out.println("> Clear List:");
|
||||||
|
System.out.println(" Before: size :" + DemoConfiguration.Sub.That.OPERATORS.size());
|
||||||
|
DemoConfiguration.Sub.That.OPERATORS.modifyList(List::clear);
|
||||||
|
System.out.println(" After size :" + DemoConfiguration.Sub.That.OPERATORS.size());
|
||||||
|
|
||||||
System.out.println("> Test Section:");
|
System.out.println("> Test Section:");
|
||||||
System.out.println(DemoConfiguration.MODEL_TEST.get());
|
System.out.println(DemoConfiguration.MODEL_TEST.get());
|
||||||
DemoConfiguration.MODEL_TEST.set(TestModel.random());
|
DemoConfiguration.MODEL_TEST.set(TestModel.random());
|
||||||
|
|
||||||
System.out.println("> Test Maps:");
|
System.out.println("> Test Maps:");
|
||||||
DemoConfiguration.USERS.getNotNull().forEach((k, v) -> System.out.println(k + ": " + v));
|
DemoConfiguration.USERS.forEach((k, v) -> System.out.println(k + ": " + v));
|
||||||
LinkedHashMap<Integer, UUID> data = new LinkedHashMap<>();
|
LinkedHashMap<Integer, UUID> data = new LinkedHashMap<>();
|
||||||
for (int i = 1; i <= 5; i++) {
|
for (int i = 1; i <= 5; i++) {
|
||||||
data.put(i, UUID.randomUUID());
|
data.put(i, UUID.randomUUID());
|
||||||
|
|||||||
+5
-10
@@ -12,16 +12,11 @@ import cc.carm.lib.configuration.core.value.type.ConfiguredSection;
|
|||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||||
import cc.carm.lib.configuration.demo.tests.model.TestModel;
|
import cc.carm.lib.configuration.demo.tests.model.TestModel;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
@HeaderComment({
|
@HeaderComment({"此处内容将显示在配置文件的最上方"})
|
||||||
"此处内容将显示在配置文件的最上方",
|
|
||||||
""/*添加一个空行与其他配置的注释分割*/
|
|
||||||
})
|
|
||||||
public class DemoConfiguration extends ConfigurationRoot {
|
public class DemoConfiguration extends ConfigurationRoot {
|
||||||
|
|
||||||
@ConfigPath(root = true)
|
@ConfigPath(root = true)
|
||||||
@@ -38,7 +33,7 @@ public class DemoConfiguration extends ConfigurationRoot {
|
|||||||
public static final Class<?> OTHER = OtherConfiguration.class;
|
public static final Class<?> OTHER = OtherConfiguration.class;
|
||||||
|
|
||||||
@ConfigPath("user") // 通过注解规定配置文件中的路径,若不进行注解则以变量名自动生成。
|
@ConfigPath("user") // 通过注解规定配置文件中的路径,若不进行注解则以变量名自动生成。
|
||||||
@HeaderComment({"", "Section类型数据测试"}) // 通过注解给配置添加注释。
|
@HeaderComment({"Section类型数据测试"}) // 通过注解给配置添加注释。
|
||||||
@InlineComment("Section数据也支持InlineComment注释")
|
@InlineComment("Section数据也支持InlineComment注释")
|
||||||
public static final ConfigValue<TestModel> MODEL_TEST = ConfiguredSection
|
public static final ConfigValue<TestModel> MODEL_TEST = ConfiguredSection
|
||||||
.builder(TestModel.class)
|
.builder(TestModel.class)
|
||||||
@@ -46,8 +41,8 @@ public class DemoConfiguration extends ConfigurationRoot {
|
|||||||
.parseValue((section, defaultValue) -> TestModel.deserialize(section))
|
.parseValue((section, defaultValue) -> TestModel.deserialize(section))
|
||||||
.serializeValue(TestModel::serialize).build();
|
.serializeValue(TestModel::serialize).build();
|
||||||
|
|
||||||
@HeaderComment({"", "[ID - UUID]对照表", "", "用于测试Map类型的解析与序列化保存"})
|
@HeaderComment({"[ID - UUID]对照表", "", "用于测试Map类型的解析与序列化保存"})
|
||||||
public static final ConfigValue<Map<Integer, UUID>> USERS = ConfiguredMap
|
public static final ConfiguredMap<Integer, UUID> USERS = ConfiguredMap
|
||||||
.builder(Integer.class, UUID.class).fromString()
|
.builder(Integer.class, UUID.class).fromString()
|
||||||
.parseKey(Integer::parseInt)
|
.parseKey(Integer::parseInt)
|
||||||
.parseValue(v -> Objects.requireNonNull(UUID.fromString(v)))
|
.parseValue(v -> Objects.requireNonNull(UUID.fromString(v)))
|
||||||
@@ -69,7 +64,7 @@ public class DemoConfiguration extends ConfigurationRoot {
|
|||||||
|
|
||||||
public static class That extends ConfigurationRoot {
|
public static class That extends ConfigurationRoot {
|
||||||
|
|
||||||
public static final ConfigValue<List<UUID>> OPERATORS = ConfiguredList
|
public static final ConfiguredList<UUID> OPERATORS = ConfiguredList
|
||||||
.builder(UUID.class).fromString()
|
.builder(UUID.class).fromString()
|
||||||
.parseValue(s -> Objects.requireNonNull(UUID.fromString(s)))
|
.parseValue(s -> Objects.requireNonNull(UUID.fromString(s)))
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class TestConfiguration extends ConfigurationRoot {
|
|||||||
public final ConfigValue<Double> CLASS_VALUE = ConfiguredValue.of(Double.class, 1.0D);
|
public final ConfigValue<Double> CLASS_VALUE = ConfiguredValue.of(Double.class, 1.0D);
|
||||||
|
|
||||||
@ConfigPath("test.user") // 通过注解规定配置文件中的路径,若不进行注解则以变量名自动生成。
|
@ConfigPath("test.user") // 通过注解规定配置文件中的路径,若不进行注解则以变量名自动生成。
|
||||||
@HeaderComment({"", "Section类型数据测试"}) // 通过注解给配置添加注释。
|
@HeaderComment({"Section类型数据测试"}) // 通过注解给配置添加注释。
|
||||||
@InlineComment("Section数据也支持InlineComment注释")
|
@InlineComment("Section数据也支持InlineComment注释")
|
||||||
public final ConfigValue<TestModel> TEST_MODEL = ConfiguredSection
|
public final ConfigValue<TestModel> TEST_MODEL = ConfiguredSection
|
||||||
.builder(TestModel.class)
|
.builder(TestModel.class)
|
||||||
|
|||||||
+4
-4
@@ -5,13 +5,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.5.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10</version>
|
<version>2.10.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -5,13 +5,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.5.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
|
|
||||||
|
|||||||
+11
-5
@@ -5,13 +5,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.5.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -28,17 +28,23 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>yamlcommentwriter</artifactId>
|
||||||
|
<version>1.0.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easyconfiguration-demo</artifactId>
|
<artifactId>easyconfiguration-demo</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bspfsystems</groupId>
|
<groupId>org.bspfsystems</groupId>
|
||||||
<artifactId>yamlconfiguration</artifactId>
|
<artifactId>yamlconfiguration</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>1.3.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
package cc.carm.lib.configuration.yaml;
|
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationComments;
|
|
||||||
import org.bspfsystems.yamlconfiguration.configuration.ConfigurationSection;
|
|
||||||
import org.bspfsystems.yamlconfiguration.file.FileConfiguration;
|
|
||||||
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static cc.carm.lib.configuration.yaml.YAMLConfigProvider.SEPARATOR;
|
|
||||||
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
|
||||||
public class YAMLComments extends ConfigurationComments {
|
|
||||||
|
|
||||||
public @Nullable String buildHeaderComments(@Nullable String path, @NotNull String indents) {
|
|
||||||
List<String> comments = getHeaderComment(path);
|
|
||||||
if (comments == null || comments.size() == 0) return null;
|
|
||||||
|
|
||||||
StringJoiner joiner = new StringJoiner("\n");
|
|
||||||
for (String comment : comments) {
|
|
||||||
if (comment.length() == 0) joiner.add(" ");
|
|
||||||
else joiner.add(indents + "# " + comment);
|
|
||||||
}
|
|
||||||
return joiner + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从一个文件读取配置并写入注释到某个写入器中。
|
|
||||||
* 该方法的部分源代码借鉴自 tchristofferson/ConfigUpdater 项目。
|
|
||||||
*
|
|
||||||
* @param source 源配置文件
|
|
||||||
* @param writer 配置写入器
|
|
||||||
* @throws IOException 当写入发生错误时抛出
|
|
||||||
*/
|
|
||||||
public void writeComments(@NotNull YamlConfiguration source, @NotNull BufferedWriter writer) throws IOException {
|
|
||||||
FileConfiguration temp = new YamlConfiguration(); // 该对象用于临时记录配置内容
|
|
||||||
|
|
||||||
String configHeader = buildHeaderComments(null, "");
|
|
||||||
if (configHeader != null) writer.write(configHeader);
|
|
||||||
|
|
||||||
for (String fullKey : source.getKeys(true)) {
|
|
||||||
Object currentValue = source.get(fullKey);
|
|
||||||
|
|
||||||
String indents = getIndents(fullKey);
|
|
||||||
String headerComments = buildHeaderComments(fullKey, indents);
|
|
||||||
String inlineComment = getInlineComment(fullKey);
|
|
||||||
|
|
||||||
if (headerComments != null) writer.write(headerComments);
|
|
||||||
|
|
||||||
String[] splitFullKey = fullKey.split("[" + SEPARATOR + "]");
|
|
||||||
String trailingKey = splitFullKey[splitFullKey.length - 1];
|
|
||||||
|
|
||||||
if (currentValue instanceof ConfigurationSection) {
|
|
||||||
ConfigurationSection section = (ConfigurationSection) currentValue;
|
|
||||||
writer.write(indents + trailingKey + ":");
|
|
||||||
if (inlineComment != null && inlineComment.length() > 0) {
|
|
||||||
writer.write(" # " + inlineComment);
|
|
||||||
}
|
|
||||||
if (!section.getKeys(false).isEmpty()) {
|
|
||||||
writer.write("\n");
|
|
||||||
} else {
|
|
||||||
writer.write(" {}\n");
|
|
||||||
if (indents.length() == 0) writer.write("\n");
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp.set(trailingKey, currentValue);
|
|
||||||
String yaml = temp.saveToString();
|
|
||||||
temp.set(trailingKey, null);
|
|
||||||
|
|
||||||
yaml = yaml.substring(0, yaml.length() - 1);
|
|
||||||
|
|
||||||
if (inlineComment != null && inlineComment.length() > 0) {
|
|
||||||
if (yaml.contains("\n")) {
|
|
||||||
// section为多行内容,需要 InlineComment 加在首行末尾
|
|
||||||
String[] splitLine = yaml.split("\n", 2);
|
|
||||||
yaml = splitLine[0] + " # " + inlineComment + "\n" + splitLine[1];
|
|
||||||
} else {
|
|
||||||
// 其他情况下就直接加载后面就好。
|
|
||||||
yaml += " # " + inlineComment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write(indents + yaml.replace("\n", "\n" + indents) + "\n");
|
|
||||||
if (indents.length() == 0) writer.write("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到一个键的缩进。
|
|
||||||
* 该方法的源代码来自 tchristofferson/ConfigUpdater 项目。
|
|
||||||
*
|
|
||||||
* @param key 键
|
|
||||||
* @return 该键的缩进文本
|
|
||||||
*/
|
|
||||||
protected static String getIndents(String key) {
|
|
||||||
String[] splitKey = key.split("[" + YAMLConfigProvider.SEPARATOR + "]");
|
|
||||||
return IntStream.range(1, splitKey.length).mapToObj(i -> " ").collect(Collectors.joining());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,22 +3,21 @@ package cc.carm.lib.configuration.yaml;
|
|||||||
import cc.carm.lib.configuration.core.ConfigInitializer;
|
import cc.carm.lib.configuration.core.ConfigInitializer;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationComments;
|
import cc.carm.lib.configuration.core.source.ConfigurationComments;
|
||||||
import cc.carm.lib.configuration.core.source.impl.FileConfigProvider;
|
import cc.carm.lib.configuration.core.source.impl.FileConfigProvider;
|
||||||
|
import cc.carm.lib.yamlcommentupdater.CommentedYAML;
|
||||||
|
import cc.carm.lib.yamlcommentupdater.CommentedYAMLWriter;
|
||||||
|
import org.bspfsystems.yamlconfiguration.configuration.ConfigurationSection;
|
||||||
|
import org.bspfsystems.yamlconfiguration.file.FileConfiguration;
|
||||||
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration;
|
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringWriter;
|
import java.util.List;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.util.Set;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class YAMLConfigProvider extends FileConfigProvider<YAMLSectionWrapper> {
|
public class YAMLConfigProvider extends FileConfigProvider<YAMLSectionWrapper> implements CommentedYAML {
|
||||||
|
|
||||||
protected static final char SEPARATOR = '.';
|
protected final @NotNull ConfigurationComments comments = new ConfigurationComments();
|
||||||
|
|
||||||
protected final @NotNull YAMLComments comments = new YAMLComments();
|
|
||||||
protected YamlConfiguration configuration;
|
protected YamlConfiguration configuration;
|
||||||
protected ConfigInitializer<YAMLConfigProvider> initializer;
|
protected ConfigInitializer<YAMLConfigProvider> initializer;
|
||||||
|
|
||||||
@@ -42,27 +41,18 @@ public class YAMLConfigProvider extends FileConfigProvider<YAMLSectionWrapper> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable ConfigurationComments getComments() {
|
public @NotNull ConfigurationComments getComments() {
|
||||||
return this.comments;
|
return this.comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
|
||||||
public void save() throws Exception {
|
public void save() throws Exception {
|
||||||
configuration.save(getFile());
|
try {
|
||||||
|
CommentedYAMLWriter.writeWithComments(this, this.file);
|
||||||
// tchristofferson/ConfigUpdater start
|
} catch (Exception ex) {
|
||||||
StringWriter writer = new StringWriter();
|
configuration.save(file);
|
||||||
this.comments.writeComments(configuration, new BufferedWriter(writer));
|
throw ex;
|
||||||
String value = writer.toString(); // config contents
|
|
||||||
|
|
||||||
Path toUpdatePath = getFile().toPath();
|
|
||||||
if (!value.equals(new String(Files.readAllBytes(toUpdatePath), StandardCharsets.UTF_8))) {
|
|
||||||
// if updated contents are not the same as current file contents, update
|
|
||||||
Files.write(toUpdatePath, value.getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
}
|
||||||
// tchristofferson/ConfigUpdater end
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,4 +60,31 @@ public class YAMLConfigProvider extends FileConfigProvider<YAMLSectionWrapper> {
|
|||||||
return this.initializer;
|
return this.initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeValue(@NotNull String key, @NotNull Object value) {
|
||||||
|
FileConfiguration temp = new YamlConfiguration();
|
||||||
|
temp.set(key, value);
|
||||||
|
return temp.saveToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getKeys(@Nullable String sectionKey, boolean deep) {
|
||||||
|
if (sectionKey == null) return configuration.getKeys(deep);
|
||||||
|
|
||||||
|
ConfigurationSection section = configuration.getConfigurationSection(sectionKey);
|
||||||
|
if (section == null) return null;
|
||||||
|
|
||||||
|
return section.getKeys(deep);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Object getValue(@NotNull String key) {
|
||||||
|
return configuration.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> getHeaderComments(@Nullable String key) {
|
||||||
|
return comments.getHeaderComment(key);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package cc.carm.lib.configuration.yaml;
|
package cc.carm.lib.configuration.yaml;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
|
||||||
import cc.carm.lib.configuration.yaml.builder.YAMLConfigBuilder;
|
import cc.carm.lib.configuration.yaml.builder.YAMLConfigBuilder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class YAMLValue<T> extends CachedConfigValue<T> {
|
public abstract class YAMLValue<T> extends CachedConfigValue<T> {
|
||||||
|
|
||||||
@@ -14,10 +12,8 @@ public abstract class YAMLValue<T> extends CachedConfigValue<T> {
|
|||||||
return new YAMLConfigBuilder();
|
return new YAMLConfigBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public YAMLValue(@Nullable YAMLConfigProvider provider, @Nullable String configPath,
|
public YAMLValue(@NotNull ValueManifest<T> manifest) {
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
super(manifest);
|
||||||
@Nullable T defaultValue) {
|
|
||||||
super(provider, configPath, headerComments, inlineComments, defaultValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YAMLConfigProvider getYAMLProvider() {
|
public YAMLConfigProvider getYAMLProvider() {
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ public class SerializableBuilder<T extends ConfigurationSerializable>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ConfiguredSerializable<T> build() {
|
public @NotNull ConfiguredSerializable<T> build() {
|
||||||
return new ConfiguredSerializable<>(this.provider, this.path, this.headerComments, this.inlineComment, this.valueClass, this.defaultValue);
|
return new ConfiguredSerializable<>(buildManifest(), this.valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-6
@@ -1,12 +1,11 @@
|
|||||||
package cc.carm.lib.configuration.yaml.value;
|
package cc.carm.lib.configuration.yaml.value;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.yaml.YAMLConfigProvider;
|
import cc.carm.lib.configuration.core.value.ValueManifest;
|
||||||
import cc.carm.lib.configuration.yaml.YAMLValue;
|
import cc.carm.lib.configuration.yaml.YAMLValue;
|
||||||
import org.bspfsystems.yamlconfiguration.serialization.ConfigurationSerializable;
|
import org.bspfsystems.yamlconfiguration.serialization.ConfigurationSerializable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ConfiguredSerializable<T extends ConfigurationSerializable> extends YAMLValue<T> {
|
public class ConfiguredSerializable<T extends ConfigurationSerializable> extends YAMLValue<T> {
|
||||||
@@ -22,10 +21,8 @@ public class ConfiguredSerializable<T extends ConfigurationSerializable> extends
|
|||||||
|
|
||||||
protected final @NotNull Class<T> valueClass;
|
protected final @NotNull Class<T> valueClass;
|
||||||
|
|
||||||
public ConfiguredSerializable(@Nullable YAMLConfigProvider provider, @Nullable String configPath,
|
public ConfiguredSerializable(@NotNull ValueManifest<T> manifest, @NotNull Class<T> valueClass) {
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
super(manifest);
|
||||||
@NotNull Class<T> valueClass, @Nullable T defaultValue) {
|
|
||||||
super(provider, configPath, headerComments, inlineComments, defaultValue);
|
|
||||||
this.valueClass = valueClass;
|
this.valueClass = valueClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class DemoConfigTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onTest() {
|
public void onTest() {
|
||||||
|
|
||||||
ConfigurationTest.testDemo(this.provider);
|
ConfigurationTest.testDemo(this.provider);
|
||||||
ConfigurationTest.testInner(this.provider);
|
ConfigurationTest.testInner(this.provider);
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ package config.source;
|
|||||||
|
|
||||||
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
||||||
import cc.carm.lib.configuration.core.annotation.ConfigPath;
|
import cc.carm.lib.configuration.core.annotation.ConfigPath;
|
||||||
|
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
||||||
import cc.carm.lib.configuration.core.value.ConfigValue;
|
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||||
import cc.carm.lib.configuration.demo.tests.model.AbstractModel;
|
import cc.carm.lib.configuration.demo.tests.model.AbstractModel;
|
||||||
import cc.carm.lib.configuration.yaml.value.ConfiguredSerializable;
|
import cc.carm.lib.configuration.yaml.value.ConfiguredSerializable;
|
||||||
import config.model.AnyModel;
|
import config.model.AnyModel;
|
||||||
import config.model.SomeModel;
|
import config.model.SomeModel;
|
||||||
|
|
||||||
|
@HeaderComment("以下内容用于测试序列化")
|
||||||
@ConfigPath("model-test")
|
@ConfigPath("model-test")
|
||||||
public class ModelConfiguration extends ConfigurationRoot {
|
public class ModelConfiguration extends ConfigurationRoot {
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
# Test Header
|
|
||||||
version: 1.0
|
version: 1.0
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<project.jdk.version>1.8</project.jdk.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.3.0</version>
|
<version>3.5.1</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
|
<module>demo</module>
|
||||||
<module>impl/yaml</module>
|
<module>impl/yaml</module>
|
||||||
<module>impl/json</module>
|
<module>impl/json</module>
|
||||||
<module>impl/sql</module>
|
<module>impl/sql</module>
|
||||||
<module>demo</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<name>EasyConfiguration</name>
|
<name>EasyConfiguration</name>
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>23.0.0</version>
|
<version>24.0.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.2</version>
|
<version>3.0.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useSystemClassLoader>false</useSystemClassLoader>
|
<useSystemClassLoader>false</useSystemClassLoader>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -166,7 +166,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.4.1</version>
|
<version>3.5.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<classifier>javadoc</classifier>
|
<classifier>javadoc</classifier>
|
||||||
<detectJavaApiLink>false</detectJavaApiLink>
|
<detectJavaApiLink>false</detectJavaApiLink>
|
||||||
@@ -193,10 +193,10 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.10.1</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>${project.jdk.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${project.jdk.version}</target>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<compilerArgument>-parameters</compilerArgument>
|
<compilerArgument>-parameters</compilerArgument>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Reference in New Issue
Block a user