diff --git a/core/src/main/java/cc/carm/lib/configuration/source/section/ConfigureSection.java b/core/src/main/java/cc/carm/lib/configuration/source/section/ConfigureSection.java index e77199b..be89b21 100644 --- a/core/src/main/java/cc/carm/lib/configuration/source/section/ConfigureSection.java +++ b/core/src/main/java/cc/carm/lib/configuration/source/section/ConfigureSection.java @@ -155,7 +155,7 @@ public interface ConfigureSection { void remove(@NotNull String path); /** - * Check if the value of given path is present. + * Check if the given path is present. *

* Path separator depends on holder's * {@link cc.carm.lib.configuration.source.option.StandardOptions#PATH_SEPARATOR} @@ -164,6 +164,19 @@ public interface ConfigureSection { * @return True if the value is present, false otherwise. */ default boolean contains(@NotNull String path) { + return getKeys(true).contains(path); + } + + /** + * Check if the value of given path is present. + *

+ * Path separator depends on holder's + * {@link cc.carm.lib.configuration.source.option.StandardOptions#PATH_SEPARATOR} + * + * @param path The path to check. + * @return True if the value is present, false otherwise. + */ + default boolean containsValue(@NotNull String path) { return get(path) != null; } diff --git a/features/section/src/main/java/cc/carm/lib/configuration/source/section/MapSection.java b/features/section/src/main/java/cc/carm/lib/configuration/source/section/MapSection.java index d73e4c6..6d8eab6 100644 --- a/features/section/src/main/java/cc/carm/lib/configuration/source/section/MapSection.java +++ b/features/section/src/main/java/cc/carm/lib/configuration/source/section/MapSection.java @@ -45,6 +45,16 @@ public abstract class MapSection> implements ConfigureSe return createChild(new LinkedHashMap<>()); } + @Override + public boolean contains(@NotNull String path) { + R section = getSectionFor(path); + if (section == this) { + return this.data().containsKey(path); + } else { + return section.contains(childPath(path)); + } + } + public @NotNull Map data() { return this.data; } @@ -136,4 +146,5 @@ public abstract class MapSection> implements ConfigureSe return output; } + }