diff --git a/core/src/main/java/cc/carm/lib/configuration/adapter/ValueType.java b/core/src/main/java/cc/carm/lib/configuration/adapter/ValueType.java index 1b8616f..98bf9c5 100644 --- a/core/src/main/java/cc/carm/lib/configuration/adapter/ValueType.java +++ b/core/src/main/java/cc/carm/lib/configuration/adapter/ValueType.java @@ -169,15 +169,16 @@ public abstract class ValueType { * @return The raw type of the generic type * @throws IllegalStateException if the type is not a Class or ParameterizedType */ - public Class getRawType() { + @SuppressWarnings("unchecked") + public Class getRawType() { if (type instanceof Class) { - return (Class) type; + return (Class) type; } if (type instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) type; Type raw = pt.getRawType(); if (raw instanceof Class) { - return (Class) raw; + return (Class) raw; } } throw new IllegalStateException("Unsupported type: " + type); diff --git a/core/src/main/java/cc/carm/lib/configuration/builder/AbstractConfigBuilder.java b/core/src/main/java/cc/carm/lib/configuration/builder/AbstractConfigBuilder.java index d8f4462..81c4d68 100644 --- a/core/src/main/java/cc/carm/lib/configuration/builder/AbstractConfigBuilder.java +++ b/core/src/main/java/cc/carm/lib/configuration/builder/AbstractConfigBuilder.java @@ -9,7 +9,6 @@ import cc.carm.lib.configuration.source.meta.ConfigurationMetadata; import cc.carm.lib.configuration.value.ConfigValue; import cc.carm.lib.configuration.value.ValueManifest; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.NotNullByDefault; import org.jetbrains.annotations.Nullable; import java.util.function.BiConsumer; @@ -17,7 +16,6 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; -@NotNullByDefault public abstract class AbstractConfigBuilder< TYPE, UNIT, RESULT extends ConfigValue, HOLDER extends ConfigurationHolder, SELF extends AbstractConfigBuilder diff --git a/pom.xml b/pom.xml index 248ed67..a3b30a2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 - 1.8 + 8 ${project.jdk.version} ${project.jdk.version} UTF-8 @@ -26,7 +26,9 @@ features/validators features/text features/kotlin + features/record + providers/temp providers/yaml providers/gson providers/hocon diff --git a/providers/temp/pom.xml b/providers/temp/pom.xml new file mode 100644 index 0000000..8a95d26 --- /dev/null +++ b/providers/temp/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + configured-parent + cc.carm.lib + 4.1.6 + ../../pom.xml + + + ${project.jdk.version} + ${project.jdk.version} + UTF-8 + UTF-8 + + + configured-temp + jar + + + + + ${project.parent.groupId} + configured-core + ${project.parent.version} + compile + + + + ${project.parent.groupId} + configured-feature-section + ${project.parent.version} + compile + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + + diff --git a/providers/temp/src/main/java/cc/carm/lib/configuration/source/temp/TempConfigFactory.java b/providers/temp/src/main/java/cc/carm/lib/configuration/source/temp/TempConfigFactory.java new file mode 100644 index 0000000..a4492d7 --- /dev/null +++ b/providers/temp/src/main/java/cc/carm/lib/configuration/source/temp/TempConfigFactory.java @@ -0,0 +1,33 @@ +package cc.carm.lib.configuration.source.temp; + +import cc.carm.lib.configuration.source.ConfigurationFactory; +import cc.carm.lib.configuration.source.ConfigurationHolder; +import org.jetbrains.annotations.NotNull; + +public class TempConfigFactory + extends ConfigurationFactory, TempConfigFactory> { + + public static @NotNull TempConfigFactory create() { + return new TempConfigFactory(); + } + + @Override + protected TempConfigFactory self() { + return this; + } + + @Override + public @NotNull ConfigurationHolder build() { + + return new ConfigurationHolder(this.adapters, this.options, this.metadata, this.initializer) { + final @NotNull TempSource source = new TempSource(this); + + @Override + public @NotNull TempSource config() { + return this.source; + } + }; + } + + +} diff --git a/providers/temp/src/main/java/cc/carm/lib/configuration/source/temp/TempSource.java b/providers/temp/src/main/java/cc/carm/lib/configuration/source/temp/TempSource.java new file mode 100644 index 0000000..8d25bf1 --- /dev/null +++ b/providers/temp/src/main/java/cc/carm/lib/configuration/source/temp/TempSource.java @@ -0,0 +1,46 @@ +package cc.carm.lib.configuration.source.temp; + +import cc.carm.lib.configuration.source.ConfigurationHolder; +import cc.carm.lib.configuration.source.section.ConfigureSource; +import cc.carm.lib.configuration.source.section.SourcedSection; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; +import java.util.Objects; + +public class TempSource extends ConfigureSource, TempSource> { + + protected @Nullable SourcedSection rootSection; + + protected TempSource(@NotNull ConfigurationHolder holder) { + super(holder, 0); + this.rootSection = SourcedSection.root(this); + } + + @Override + protected @NotNull TempSource self() { + return this; + } + + @Override + public @NotNull Map original() { + return section().data(); + } + + @Override + public @NotNull SourcedSection section() { + return Objects.requireNonNull(this.rootSection, "Root section is not initialized."); + } + + @Override + public void save() throws Exception { + // Nothing to do here. + } + + @Override + protected void onReload() throws Exception { + // Also nothing to do, because this is a temporary source. + } + +}