Interface ConfigFilter<T,U>
- Type Parameters:
T
- The input typeU
- The output type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A functional interface for functions that validate config input and optionally convert it to a new output type.
ConfigFilters are intended to be chained together with withFilter(ConfigFilter).
See ConfigFilterResult for information on the return type of this function.
ConfigFilters are intended to be chained together with withFilter(ConfigFilter).
See ConfigFilterResult for information on the return type of this function.
-
Method Summary
Modifier and TypeMethodDescriptionChecks that the input is valid and optionally converts it to a new type.static <X> ConfigFilter
<X, X> A "null" filter that does nothing.static <X> ConfigFilter
<X, X> Returns a ConfigFilter that runs the providedConsumer
and passes.default ConfigFilter
<T, U> Runs aConsumer
with the output of this filter.
Useful for retrieving the value of a filter.default <V> ConfigFilter
<T, V> withFilter
(ConfigFilter<U, V> filter) Returns a filter that takes in the input ofthis
and returns the output of the supplied filter.
Useful for chaining multiple filters together into one filter.
-
Method Details
-
filter
Checks that the input is valid and optionally converts it to a new type.- Parameters:
input
- the input to filter- Returns:
- a
ConfigFilterResult
containing whether this filter passed and the new type it was converted to
-
withFilter
Returns a filter that takes in the input ofthis
and returns the output of the supplied filter.
Useful for chaining multiple filters together into one filter.- Type Parameters:
V
- the type that the new filter returns- Parameters:
filter
- a filter that takes the output ofthis
and returns a new type- Returns:
- a filter that takes the input of
this
and returns the output of the supplied filter - Throws:
NullPointerException
- if filter is null
-
thenRun
-
run
-
nullFilter
A "null" filter that does nothing. It will always pass with its input as its output.- Type Parameters:
X
- the type of the filter input and output- Returns:
- a filter that passes with its input as its output
-