- 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 Weight
. If no weight is
explicitly assigned, the value of 100.0 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' weight 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 weight than the
current filter will not have executed. Developers should keep this
in mind while writing filter init
methods.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault ConfigItem
apply
(Config.Key key, ConfigItem itemPolicy) Filters an elementary config value before it is made available to the application via theConfig
API.apply
(Config.Key key, String stringValue) Filters an elementary config value before it is made available to the application via theConfig
API.default void
Initializes the filter using theConfig
instance which the filter will affect onceConfig.Builder.build
completes.
-
Method Details
-
apply
Filters an elementary config value before it is made available to the application via theConfig
API.- Parameters:
key
- configurationkey
associated with theConfig
nodestringValue
- original value to be filtered, nevernull
- Returns:
- original value or filtered (changed) value, never
null
-
apply
Filters an elementary config value before it is made available to the application via theConfig
API. ReturnsConfigItem
object which contains filtered config value and specific value settings.- Parameters:
key
- configurationkey
associated with theConfig
nodeitemPolicy
- original item policy- Returns:
- new item policy object with the filtered config value
-
init
Initializes the filter using theConfig
instance which the filter will affect onceConfig.Builder.build
completes.The config system propagates any thrown exception to the application so its invocation of
Config.Builder#build
fails.- Parameters:
config
-Config
instance under construction
-