diff --git a/avaje-config/src/main/java/io/avaje/config/Configuration.java b/avaje-config/src/main/java/io/avaje/config/Configuration.java index a90196b..e60af56 100644 --- a/avaje-config/src/main/java/io/avaje/config/Configuration.java +++ b/avaje-config/src/main/java/io/avaje/config/Configuration.java @@ -491,6 +491,11 @@ default boolean enabled(String key, boolean enabledDefault) { */ void reloadSources(); + /** + * Return the property keys in this configuration. + */ + Set keys(); + /** * Return the number of configuration properties. */ diff --git a/avaje-config/src/main/java/io/avaje/config/CoreConfiguration.java b/avaje-config/src/main/java/io/avaje/config/CoreConfiguration.java index 5e3bf00..1c39f1c 100644 --- a/avaje-config/src/main/java/io/avaje/config/CoreConfiguration.java +++ b/avaje-config/src/main/java/io/avaje/config/CoreConfiguration.java @@ -204,6 +204,11 @@ public Configuration forPath(String pathPrefix) { return new CoreConfiguration(this, newEntryMap, dotPrefix); } + @Override + public Set keys() { + return properties.entries.keys(); + } + @Override public ListValue list() { return listValue; diff --git a/avaje-config/src/main/java/io/avaje/config/CoreEntry.java b/avaje-config/src/main/java/io/avaje/config/CoreEntry.java index 63373c6..30f71f5 100644 --- a/avaje-config/src/main/java/io/avaje/config/CoreEntry.java +++ b/avaje-config/src/main/java/io/avaje/config/CoreEntry.java @@ -162,6 +162,10 @@ private boolean putIfChanged(String key, String value, String source) { return false; } + Set keys() { + return entryMap.keySet(); + } + boolean containsKey(String key) { return entryMap.containsKey(key); } diff --git a/avaje-config/src/test/java/io/avaje/config/CoreConfigurationTest.java b/avaje-config/src/test/java/io/avaje/config/CoreConfigurationTest.java index b9d3f0d..b979f97 100644 --- a/avaje-config/src/test/java/io/avaje/config/CoreConfigurationTest.java +++ b/avaje-config/src/test/java/io/avaje/config/CoreConfigurationTest.java @@ -80,6 +80,7 @@ void forPath() { CoreConfiguration base = createSample(); Configuration foo = base.forPath("foo"); + assertThat(foo.keys()).contains("bar", "t", "f"); assertThat(foo.size()).isEqualTo(3); assertThat(foo.getInt("bar")).isEqualTo(42); assertThat(foo.getBool("t")).isTrue();