mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 10:38:19 +08:00
feat: Split MapSection and MemorySection
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-parent</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>4.0.4</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-parent</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>4.0.4</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-parent</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>4.0.4</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
+4
-1
@@ -10,9 +10,12 @@ public abstract class MapSection<R extends MapSection<R>> implements ConfigureSe
|
||||
protected final @NotNull Map<String, Object> data;
|
||||
protected final @Nullable R parent;
|
||||
|
||||
protected MapSection(@NotNull Map<?, ?> data, @Nullable R parent) {
|
||||
protected MapSection(@Nullable R parent) {
|
||||
this.parent = parent;
|
||||
this.data = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public void migrate(Map<?, ?> data) {
|
||||
for (Map.Entry<?, ?> entry : data.entrySet()) {
|
||||
String key = (entry.getKey() == null) ? "null" : entry.getKey().toString();
|
||||
if (entry.getValue() instanceof Map) {
|
||||
|
||||
+7
-7
@@ -8,22 +8,22 @@ import java.util.Map;
|
||||
|
||||
public class MemorySection extends MapSection<MemorySection> {
|
||||
|
||||
|
||||
public static @NotNull MemorySection root(@NotNull ConfigureSource<? extends MemorySection, ?, ?> source) {
|
||||
return new MemorySection(source, new LinkedHashMap<>(), null);
|
||||
}
|
||||
|
||||
public static @NotNull MemorySection root(@NotNull ConfigureSource<? extends MemorySection, ?, ?> source,
|
||||
@Nullable Map<?, ?> data) {
|
||||
return new MemorySection(source, data == null ? new LinkedHashMap<>() : data, null);
|
||||
@Nullable Map<?, ?> raw) {
|
||||
return new MemorySection(source, raw == null ? new LinkedHashMap<>() : raw, null);
|
||||
}
|
||||
|
||||
protected final @NotNull ConfigureSource<? extends MemorySection, ?, ?> source;
|
||||
|
||||
protected MemorySection(@NotNull ConfigureSource<? extends MemorySection, ?, ?> source,
|
||||
@NotNull Map<?, ?> data, @Nullable MemorySection parent) {
|
||||
super(data, parent);
|
||||
@NotNull Map<?, ?> raw, @Nullable MemorySection parent) {
|
||||
super(parent);
|
||||
this.source = source;
|
||||
migrate(raw);
|
||||
}
|
||||
|
||||
public @NotNull ConfigureSource<? extends MemorySection, ?, ?> source() {
|
||||
@@ -32,7 +32,7 @@ public class MemorySection extends MapSection<MemorySection> {
|
||||
|
||||
@Override
|
||||
public char pathSeparator() {
|
||||
return source.pathSeparator();
|
||||
return source().pathSeparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,7 +42,7 @@ public class MemorySection extends MapSection<MemorySection> {
|
||||
|
||||
@Override
|
||||
protected @NotNull MemorySection createChild(@NotNull Map<?, ?> data) {
|
||||
return new MemorySection(source, data, this);
|
||||
return new MemorySection(source(), data, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-parent</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>4.0.4</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-parent</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>4.0.4</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
Reference in New Issue
Block a user