mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2024-09-19 20:25:51 +00:00
feat(value): 单独提出 ”ValueManifest“ 以解决每个实现类中初始参数复杂的问题,方便后续开发。
This commit is contained in:
parent
9c95a16d90
commit
727c26a2fb
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
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;
|
||||||
@ -66,4 +67,11 @@ public abstract class AbstractConfigBuilder<T, B extends AbstractConfigBuilder<T
|
|||||||
return defaults(defaultValueSupplier.get());
|
return defaults(defaultValueSupplier.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected @NotNull ValueManifest<T> buildManifest() {
|
||||||
|
return ValueManifest.of(
|
||||||
|
this.provider, this.path,
|
||||||
|
this.headerComments, this.inlineComment, this.defaultValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
);
|
);
|
||||||
|
@ -2,6 +2,7 @@ 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;
|
||||||
|
|
||||||
@ -96,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)
|
||||||
);
|
);
|
||||||
|
@ -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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -2,7 +2,7 @@ package cc.carm.lib.configuration.core.value.type;
|
|||||||
|
|
||||||
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;
|
||||||
@ -22,12 +22,10 @@ public class ConfiguredList<V> extends CachedConfigValue<List<V>> implements Lis
|
|||||||
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;
|
||||||
|
@ -2,14 +2,17 @@ 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 org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -32,15 +35,17 @@ public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> implements
|
|||||||
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;
|
||||||
|
@ -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;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -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() {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -15,7 +15,7 @@
|
|||||||
<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.4.0</version>
|
<version>3.5.0</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>demo</module>
|
<module>demo</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user