Package org.springframework.boot.json
Class JsonWriter.Members<T>
java.lang.Object
org.springframework.boot.json.JsonWriter.Members<T>
- Type Parameters:
T- the type that will be written
- Enclosing interface:
- JsonWriter<T>
Callback used to configure JSON members. Individual members can be declared using
the various
add(...) methods. Typically, members are declared with a
"name" and a Function that will extract the value from the
instance. Members can also be declared using a static value or a Supplier.
The add(String) and add() methods may be used to access the
actual instance being written.
Members can be added without a name when a Member.using(...) method
is used to complete the definition.
Members can filtered using Member.when methods and adapted to different
types using Member.as(...).
-
Method Summary
Modifier and TypeMethodDescriptionadd()Add a new member with access to the instance being written.Add a new member with access to the instance being written.<V> JsonWriter.Member<V>Add a new member with an extracted value.<V> JsonWriter.Member<V>Add a new member with a supplied value.<V> JsonWriter.Member<V>Add a new member with a static value.<M extends Map<K,V>, K, V>
JsonWriter.Member<M>addMapEntries(Function<T, M> extractor) Add all entries from the givenMapto the JSON.voidapplyingNameProcessor(JsonWriter.NameProcessor nameProcessor) Add the aJsonWriter.NameProcessorto be applied when the JSON is written.voidapplyingPathFilter(Predicate<JsonWriter.MemberPath> predicate) Add a filter that will be used to restrict the members written to the JSON.voidapplyingValueProcessor(JsonWriter.ValueProcessor<?> valueProcessor) Add the aJsonWriter.ValueProcessorto be applied when the JSON is written.<V> JsonWriter.Member<V>Add members from an extracted value.<V> JsonWriter.Member<V>Add members from a supplied value.<V> JsonWriter.Member<V>from(V value) Add members from a static value.
-
Method Details
-
add
Add a new member with access to the instance being written.- Parameters:
name- the member name- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
add
Add a new member with a static value.- Type Parameters:
V- the value type- Parameters:
name- the member namevalue- the member value- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
add
Add a new member with a supplied value.- Type Parameters:
V- the value type- Parameters:
name- the member namesupplier- a supplier of the value- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
add
Add a new member with an extracted value.- Type Parameters:
V- the value type- Parameters:
name- the member nameextractor- a function to extract the value- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
add
Add a new member with access to the instance being written. The member is added without a name, so one of theMember.using(...)methods must be used to complete the configuration.- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
addMapEntries
Add all entries from the givenMapto the JSON.- Type Parameters:
M- the map typeK- the key typeV- the value type- Parameters:
extractor- a function to extract the map- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
from
Add members from a static value. One of theMember.using(...)methods must be used to complete the configuration.- Type Parameters:
V- the value type- Parameters:
value- the member value- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
from
Add members from a supplied value. One of theMember.using(...)methods must be used to complete the configuration.- Type Parameters:
V- the value type- Parameters:
supplier- a supplier of the value- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
from
Add members from an extracted value. One of theMember.using(...)methods must be used to complete the configuration.- Type Parameters:
V- the value type- Parameters:
extractor- a function to extract the value- Returns:
- the added
JsonWriter.Memberwhich may be configured further
-
applyingPathFilter
Add a filter that will be used to restrict the members written to the JSON.- Parameters:
predicate- the predicate used to filter members
-
applyingNameProcessor
Add the aJsonWriter.NameProcessorto be applied when the JSON is written.- Parameters:
nameProcessor- the name processor to add
-
applyingValueProcessor
Add the aJsonWriter.ValueProcessorto be applied when the JSON is written.- Parameters:
valueProcessor- the value processor to add
-