1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 10:38:19 +08:00

feat(section): Add original method

This commit is contained in:
2025-02-21 02:00:36 +08:00
parent ba66220f92
commit d8191b7c6d
@@ -2,6 +2,7 @@ package cc.carm.lib.configuration.source.section;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;
import java.util.*; import java.util.*;
@@ -48,6 +49,19 @@ public abstract class MapSection<R extends MapSection<R>> implements ConfigureSe
return this.data; return this.data;
} }
@UnmodifiableView
public @NotNull Map<String, Object> original() {
Map<String, Object> output = new LinkedHashMap<>();
for (Map.Entry<String, Object> entry : this.data.entrySet()) {
if (entry.getValue() instanceof MapSection<?>) {
output.put(entry.getKey(), ((MapSection<?>) entry.getValue()).original());
} else {
output.put(entry.getKey(), entry.getValue());
}
}
return output;
}
public @Nullable R parent() { public @Nullable R parent() {
return this.parent; return this.parent;
} }