- All Known Implementing Classes:
EncryptionFilter,EncryptionFilterService,OverrideConfigFilter,ValueResolvingFilter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
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.
Initializing Filters
Any filter that uses theConfig 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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault priority of the filter if registered byConfig.Builderautomatically. -
Method Summary
Modifier and TypeMethodDescriptionapply(Config.Key key, String stringValue) Filters an elementary config value before it is made available to the application via theConfigAPI.default voidInitializes the filter using theConfiginstance which the filter will affect onceConfig.Builder.buildcompletes.
-
Field Details
-
PRIORITY
static final int PRIORITYDefault priority of the filter if registered byConfig.Builderautomatically.- See Also:
-
-
Method Details
-
apply
Filters an elementary config value before it is made available to the application via theConfigAPI.- Parameters:
key- configurationkeyassociated with theConfignodestringValue- original value to be filtered, nevernull- Returns:
- original value or filtered (changed) value, never
null
-
init
Initializes the filter using theConfiginstance which the filter will affect onceConfig.Builder.buildcompletes.The config system propagates any thrown exception to the application so its invocation of
Config.Builder#buildfails.- Parameters:
config-Configinstance under construction
-