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
@@ -30,6 +30,15 @@ public interface ConfigureSection {
@Contract(pure = true)
@Nullable ConfigureSection parent();
/**
* Get the path separator for the section.
*
* @return The path separator
*/
default char pathSeparator() {
return '.';
}
/**
* Gets if this section is a root section.
*
@@ -706,6 +715,11 @@ public interface ConfigureSection {
return stream(path).map(parser);
}
default String childPath(String path) {
int index = path.indexOf(pathSeparator());
return (index == -1) ? path : path.substring(index + 1);
}
static <T, C extends Collection<T>> @NotNull C parseCollection(
@Nullable List<?> data,
@NotNull Supplier<C> constructor,