Package org.springframework.boot.json
Interface JsonWriter.ValueProcessor<T>
- Type Parameters:
T
- the value type
- Enclosing interface:
- JsonWriter<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback interface that can be
applied
to JsonWriter.Members
to process values before they are written. Typically used to filter values, for
example to reduce superfluous information or sanitize sensitive data.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> JsonWriter.ValueProcessor<T>
of
(Class<? extends T> type, UnaryOperator<T> action) Factory method to crate a newJsonWriter.ValueProcessor
that applies the given action.static <T> JsonWriter.ValueProcessor<T>
of
(UnaryOperator<T> action) Factory method to crate a newJsonWriter.ValueProcessor
that applies the given action.processValue
(JsonWriter.MemberPath path, T value) Process the value at the given path.default JsonWriter.ValueProcessor<T>
Return a new processor from this one that only applies to member with values that match the given predicate.default JsonWriter.ValueProcessor<T>
whenHasPath
(String path) Return a new processor from this one that only applied to members with the given path.default JsonWriter.ValueProcessor<T>
whenHasPath
(Predicate<JsonWriter.MemberPath> predicate) Return a new processor from this one that only applied to members that match the given path predicate.default JsonWriter.ValueProcessor<T>
whenHasUnescapedPath
(String path) Return a new processor from this one that only applied to members with the given path (ignoring escape characters).default JsonWriter.ValueProcessor<T>
whenInstanceOf
(Class<?> type) Return a new processor from this one that only applies to member with values of the given type.
-
Method Details
-
processValue
Process the value at the given path.- Parameters:
path
- the path of the member containing the valuevalue
- the value being written (may benull
)- Returns:
- the processed value
-
whenHasUnescapedPath
Return a new processor from this one that only applied to members with the given path (ignoring escape characters).- Parameters:
path
- the patch to match- Returns:
- a new
JsonWriter.ValueProcessor
that only applies when the path matches
-
whenHasPath
Return a new processor from this one that only applied to members with the given path.- Parameters:
path
- the patch to match- Returns:
- a new
JsonWriter.ValueProcessor
that only applies when the path matches
-
whenHasPath
Return a new processor from this one that only applied to members that match the given path predicate.- Parameters:
predicate
- the predicate that must match- Returns:
- a new
JsonWriter.ValueProcessor
that only applies when the predicate matches
-
whenInstanceOf
Return a new processor from this one that only applies to member with values of the given type.- Parameters:
type
- the type that must match- Returns:
- a new
JsonWriter.ValueProcessor
that only applies when value is the given type.
-
when
Return a new processor from this one that only applies to member with values that match the given predicate.- Parameters:
predicate
- the predicate that must match- Returns:
- a new
JsonWriter.ValueProcessor
that only applies when the predicate matches
-
of
Factory method to crate a newJsonWriter.ValueProcessor
that applies the given action.- Type Parameters:
T
- the value type- Parameters:
type
- the value typeaction
- the action to apply- Returns:
- a new
JsonWriter.ValueProcessor
instance
-
of
Factory method to crate a newJsonWriter.ValueProcessor
that applies the given action.- Type Parameters:
T
- the value type- Parameters:
action
- the action to apply- Returns:
- a new
JsonWriter.ValueProcessor
instance
-