mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 10:38:19 +08:00
feat: Implement more sections functions
This commit is contained in:
+5
-14
@@ -8,14 +8,6 @@ import java.util.*;
|
||||
|
||||
public abstract class MapSection<R extends MapSection<R>> implements ConfigureSection {
|
||||
|
||||
public static RawMapSection of() {
|
||||
return new RawMapSection(new LinkedHashMap<>(), null);
|
||||
}
|
||||
|
||||
public static RawMapSection of(@NotNull Map<?, ?> data) {
|
||||
return new RawMapSection(data, null);
|
||||
}
|
||||
|
||||
protected final @NotNull Map<String, Object> data;
|
||||
protected final @Nullable R parent;
|
||||
|
||||
@@ -57,6 +49,11 @@ public abstract class MapSection<R extends MapSection<R>> implements ConfigureSe
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return data.isEmpty();
|
||||
}
|
||||
|
||||
@UnmodifiableView
|
||||
public @NotNull Map<String, Object> rawMap() {
|
||||
Map<String, Object> output = new LinkedHashMap<>();
|
||||
@@ -118,12 +115,6 @@ public abstract class MapSection<R extends MapSection<R>> implements ConfigureSe
|
||||
return section == this ? data.get(path) : section.get(childPath(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ConfigureSection getSection(@NotNull String path) {
|
||||
Object val = get(path);
|
||||
return (val instanceof ConfigureSection) ? (ConfigureSection) val : null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private R getSectionFor(String path) {
|
||||
int index = path.indexOf(pathSeparator());
|
||||
|
||||
+18
-1
@@ -3,10 +3,27 @@ package cc.carm.lib.configuration.source.section;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RawMapSection extends MapSection<RawMapSection> {
|
||||
|
||||
|
||||
public static RawMapSection of() {
|
||||
return of((RawMapSection) null);
|
||||
}
|
||||
|
||||
public static RawMapSection of(@NotNull Map<?, ?> data) {
|
||||
return of(data, null);
|
||||
}
|
||||
|
||||
public static RawMapSection of(@Nullable RawMapSection parent) {
|
||||
return of(new LinkedHashMap<>(), parent);
|
||||
}
|
||||
|
||||
public static RawMapSection of(@NotNull Map<?, ?> data, @Nullable RawMapSection parent) {
|
||||
return new RawMapSection(data, parent);
|
||||
}
|
||||
|
||||
protected RawMapSection(@NotNull Map<?, ?> raw, @Nullable RawMapSection parent) {
|
||||
super(parent);
|
||||
migrate(raw);
|
||||
|
||||
Reference in New Issue
Block a user