mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 10:38:19 +08:00
feat: Simplify the ConfigureSection functions to support more different usages.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-parent</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<version>4.0.2</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
+7
-4
@@ -53,7 +53,6 @@ public class MemorySection implements ConfigureSection {
|
||||
return createChild(new LinkedHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ConfigureSource<? extends MemorySection, ?, ?> source() {
|
||||
return this.source;
|
||||
}
|
||||
@@ -66,6 +65,10 @@ public class MemorySection implements ConfigureSection {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public char pathSeparator() {
|
||||
return source.pathSeparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<String, Object> getValues(boolean deep) {
|
||||
return Collections.unmodifiableMap(deep ? mapChildrenValues(this, null, true) : data());
|
||||
@@ -109,7 +112,7 @@ public class MemorySection implements ConfigureSection {
|
||||
}
|
||||
|
||||
private MemorySection getSectionFor(String path) {
|
||||
int index = path.indexOf(separator());
|
||||
int index = path.indexOf(pathSeparator());
|
||||
if (index == -1) return this;
|
||||
|
||||
String root = path.substring(0, index);
|
||||
@@ -123,7 +126,7 @@ public class MemorySection implements ConfigureSection {
|
||||
}
|
||||
|
||||
private String childPath(String path) {
|
||||
int index = path.indexOf(separator());
|
||||
int index = path.indexOf(pathSeparator());
|
||||
return (index == -1) ? path : path.substring(index + 1);
|
||||
}
|
||||
|
||||
@@ -138,7 +141,7 @@ public class MemorySection implements ConfigureSection {
|
||||
@Nullable String parent, boolean deep) {
|
||||
Map<String, Object> output = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, Object> entry : section.data().entrySet()) {
|
||||
String path = (parent == null ? "" : parent + separator()) + entry.getKey();
|
||||
String path = (parent == null ? "" : parent + pathSeparator()) + entry.getKey();
|
||||
output.remove(path);
|
||||
output.put(path, entry.getValue());
|
||||
if (deep && entry.getValue() instanceof MemorySection) {
|
||||
|
||||
Reference in New Issue
Block a user