diff --git a/api/src/main/java/javax/config/spi/ConfigValue.java b/api/src/main/java/javax/config/spi/ConfigValue.java index c0faeb1..6ff362c 100644 --- a/api/src/main/java/javax/config/spi/ConfigValue.java +++ b/api/src/main/java/javax/config/spi/ConfigValue.java @@ -27,7 +27,9 @@ package javax.config.spi; +import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; /** * Accessor to a configured value. @@ -44,12 +46,31 @@ public interface ConfigValue { * Sets the type of the configuration entry to the given class and returns this builder. * The default type of a ConfigValue is {@code String}. * + *

Usage: + *

+     * Integer timeout = config.access("some.timeout")
+     *                         .as(Integer.class)
+     *                         .getValue();
+     * 
+ * + * * @param clazz The target type * @param The target type * @return This builder as a typed ConfigValue */ ConfigValue as(Class clazz); + /** + * Declare the ConfigValue to return a List of the given Type. + * When getting value it will be split on each comma (',') character. + * If a comma is contained in the values it must get escaped with a preceding backslash ("\,"). + * Any backslash needs to get escaped via double-backslash ("\\"). + * Note that in property files this leads to "\\\\" as properties escape themselves. + * + * @return a ConfigValue for a list of configured comma separated values + */ + ConfigValue> asList(); + /** * Sets the type of the configuration entry to the given class, sets the converter to the one given and * returns this builder. If a converter is provided for one of the types supported by @@ -110,11 +131,12 @@ public interface ConfigValue { ConfigValue withLookupChain(String... postfixNames); /** - * Whether to log picking up any value changes as INFO. + * A user can register a Consumer which gets notified whenever + * a config change got detected. * * @return This builder */ - ConfigValue logChanges(boolean logChanges); + ConfigValue onChange(Consumer changedValueConsumer); /** * Returns the converted resolved filtered value.