1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 18:48:20 +08:00

feat: Implement more sections functions

This commit is contained in:
2025-02-21 16:17:12 +08:00
parent d543530305
commit 3473ef2247
4 changed files with 47 additions and 15 deletions
@@ -71,14 +71,6 @@ public abstract class MapSection<R extends MapSection<R>> implements ConfigureSe
return this.parent;
}
/**
* Get the path separator for the section.
*
* @return The path separator
*/
public char pathSeparator() {
return '.';
}
@Override
public @NotNull Map<String, Object> getValues(boolean deep) {
@@ -124,11 +116,6 @@ public abstract class MapSection<R extends MapSection<R>> implements ConfigureSe
return (R) data().computeIfAbsent(root, k -> createChild());
}
private String childPath(String path) {
int index = path.indexOf(pathSeparator());
return (index == -1) ? path : path.substring(index + 1);
}
/**
* Map the values of the children of the section to the output map.
*
@@ -1,6 +1,38 @@
package cc.carm.lib.configuration.source.section;
public class ShadedSection {
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;
import java.util.Collections;
import java.util.Map;
public class ShadedSection implements ConfigureSection {
@Override
public @Nullable ConfigureSection parent() {
return null;
}
@Override
public @NotNull @UnmodifiableView Map<String, Object> getValues(boolean deep) {
return Collections.emptyMap();
}
@Override
public void set(@NotNull String path, @Nullable Object value) {
}
@Override
public void remove(@NotNull String path) {
}
@Override
public @Nullable Object get(@NotNull String path) {
return null;
}
}
@@ -35,7 +35,6 @@ public class ShadeTest {
data.put("cards", Arrays.asList("33333", "55555")); // 应当直接覆盖原先的List
});
}
}