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

feat(mongo): Finished source for MongoDB #105

This commit is contained in:
2025-02-26 23:49:32 +08:00
parent 6f28abebb9
commit f74d5d29f9
16 changed files with 263 additions and 22 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>easyconfiguration-parent</artifactId>
<version>4.0.7</version>
<version>4.0.8</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
@@ -98,6 +98,11 @@ public abstract class AbstractMapSection<R extends AbstractMapSection<R>> implem
return Collections.unmodifiableMap(deep ? mappingValues(this, null, true, String.valueOf(pathSeparator())) : data());
}
@Override
public @NotNull @UnmodifiableView Set<String> getKeys(boolean deep) {
return Collections.unmodifiableSet(deep ? mappingKeys(this, null, true, String.valueOf(pathSeparator())) : data().keySet());
}
@Override
public void set(@NotNull String path, @Nullable Object value) {
if (value instanceof Map) value = createSection(path, (Map<?, ?>) value);
@@ -157,5 +162,17 @@ public abstract class AbstractMapSection<R extends AbstractMapSection<R>> implem
return output;
}
protected static Set<String> mappingKeys(@NotNull AbstractMapSection<?> section, @Nullable String parent, boolean deep, String pathSeparator) {
Set<String> keys = new LinkedHashSet<>();
for (Map.Entry<String, Object> entry : section.data().entrySet()) {
String path = (parent == null ? "" : parent + pathSeparator) + entry.getKey();
keys.add(path);
if (deep && entry.getValue() instanceof AbstractMapSection<?>) {
keys.addAll(mappingKeys((AbstractMapSection<?>) entry.getValue(), path, true, pathSeparator));
}
}
return keys;
}
}