@FunctionalInterface public interface ConfigFilter
String) values
before they are returned via the Config API.
The application can register filters with a builder by invoking
Config.Builder#addFilter(ConfigFilter) or Config.Builder#addFilter(java.util.function.Function). The
config system also locates filters using the Java
ServiceLoader mechanism and automatically adds them to
every Builder unless the application disables this feature for a
given Builder by invoking
Config.Builder#disableFilterServices().
A filter can specify a Priority. If no priority is
explicitly assigned, the value of 100 is assumed.
Config instance during its initialization
should do so in its init(Config) method,
not
in its constructor. The Config.Builder.build() method invokes each
filter's `init` method according to the filters' priority order and just
before returning the new Config instance to the application.
If a filter's init method uses Config#get to retrieve config
information, then -- as always -- the config system will invoke the
apply method on every filter which the application added to the
builder. But the init methods of filters with lower priority than the
current filter will not have executed. Developers should keep this
in mind while writing filter init methods.
Config.Builder#addFilter(ConfigFilter),
Config.Builder#addFilter(java.util.function.Function)| Modifier and Type | Field and Description |
|---|---|
static int |
PRIORITY
Default priority of the filter if registered by
Config.Builder automatically. |
| Modifier and Type | Method and Description |
|---|---|
String |
apply(Config.Key key,
String stringValue)
Filters an elementary config value before it is made available to the
application via the
Config API. |
default void |
init(Config config)
Initializes the filter using the
Config instance which the filter
will affect once Config.Builder.build completes. |
static final int PRIORITY
Config.Builder automatically.String apply(Config.Key key, String stringValue)
Config API.key - configuration key associated with the
Config nodestringValue - original value to be filtered, never nullnulldefault void init(Config config)
Config instance which the filter
will affect once Config.Builder.build completes.
The config system propagates any thrown exception to the application so its
invocation of Config.Builder#build fails.
config - Config instance under constructionCopyright © 2018–2019 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.