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 addSelf(String)
and addSelf()
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 TypeMethodDescription<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.<V> JsonWriter.Member<V>
Add a new member with an extracted value.<V> JsonWriter.Member<V>
Add a new member with a supplied value.The member is added without a name, so one of theMember.using(...)
methods must be used to complete the configuration.<V> JsonWriter.Member<V>
add
(V value) 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 givenMap
to the JSON.addSelf()
Add a new member with access to the instance being written.Add a new member with access to the instance being written.
-
Method Details
-
addSelf
Add a new member with access to the instance being written.- Parameters:
name
- the member name- Returns:
- the added
JsonWriter.Member
which 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.Member
which 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.Member
which 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.Member
which may be configured further
-
addSelf
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.Member
which may be configured further
-
add
Add a new member with a static value. The member is added without a name, so 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.Member
which may be configured further
-
add
Add a new member with a supplied value.The member is added without a name, so 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.Member
which may be configured further
-
add
Add a new member with an extracted value. The member is added without a name, so 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.Member
which may be configured further
-
addMapEntries
Add all entries from the givenMap
to 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.Member
which may be configured further
-