Class ApiJsonBuilder<T extends ApiJsonBuilder<T>>
java.lang.Object
io.helidon.integrations.common.rest.ApiJsonBuilder<T>
- Type Parameters:
T
- type of the subclass
- Direct Known Subclasses:
ApiJsonRequest
,DecryptBatch.BatchEntry
,EncryptBatch.BatchEntry
Common base class for builders that construct a JSON object.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected T
Add custom boolean to payload.protected T
Add custom double to payload.protected T
Add custom int to payload.protected T
Add custom long to payload.protected T
add
(String name, ApiJsonBuilder<?> object) Add a custom object to payload.protected T
Add custom string to payload.protected T
addBase64
(String name, Base64Value base64Value) Add a string encoded with base64.protected T
addToArray
(String name, boolean element) Add an element to an array.protected T
addToArray
(String name, double element) Add an element to an array.protected T
addToArray
(String name, int element) Add an element to an array.protected T
addToArray
(String name, long element) Add an element to an array.protected T
addToArray
(String name, ApiJsonBuilder<?> element) Add an object to an array.protected T
addToArray
(String name, String element) Add an element to an array.protected T
addToObject
(String name, String key, boolean value) Add a key/value pair to a named object.protected T
addToObject
(String name, String key, double value) Add a key/value pair to a named object.protected T
addToObject
(String name, String key, int value) Add a key/value pair to a named object.protected T
addToObject
(String name, String key, long value) Add a key/value pair to a named object.protected T
addToObject
(String name, String key, String value) Add a key/value pair to a named object.protected T
emptyArray
(String name) Configure an empty array.protected T
me()
Can be returned by subclasses that can be subclassed again.protected void
postBuild
(JsonBuilderFactory factory, JsonObjectBuilder payload) Called after adding properties defined in this request.protected void
preBuild
(JsonBuilderFactory factory, JsonObjectBuilder payload) Called before adding properties defined in this request.toJson
(JsonBuilderFactory factory) Create a JSON object from this builder.
-
Constructor Details
-
ApiJsonBuilder
protected ApiJsonBuilder()Default constructor.
-
-
Method Details
-
toJson
Create a JSON object from this builder.- Parameters:
factory
- builder factory to create objects- Returns:
- JSON object or empty
-
me
Can be returned by subclasses that can be subclassed again.- Returns:
- this instance as a subclass type
-
preBuild
Called before adding properties defined in this request.- Parameters:
factory
- json factorypayload
- payload builder
-
postBuild
Called after adding properties defined in this request.- Parameters:
factory
- json factorypayload
- payload builder
-
addToArray
Add an element to an array.- Parameters:
name
- key in the json payloadelement
- element of the array- Returns:
- updated request
-
addToArray
Add an element to an array.- Parameters:
name
- key in the json payloadelement
- element of the array- Returns:
- updated request
-
addToArray
Add an element to an array.- Parameters:
name
- key in the json payloadelement
- element of the array- Returns:
- updated request
-
addToArray
Add an element to an array.- Parameters:
name
- key in the json payloadelement
- element of the array- Returns:
- updated request
-
addToArray
Add an element to an array.- Parameters:
name
- key in the json payloadelement
- element of the array- Returns:
- updated request
-
add
Add custom string to payload. If such a name is already added, it will be replaced.- Parameters:
name
- json keyvalue
- json String value- Returns:
- updated request
-
add
Add custom int to payload. If such a name is already added, it will be replaced.- Parameters:
name
- json keyvalue
- json value- Returns:
- updated request
-
add
Add custom double to payload. If such a name is already added, it will be replaced.- Parameters:
name
- json keyvalue
- json value- Returns:
- updated request
-
add
Add custom long to payload. If such a name is already added, it will be replaced.- Parameters:
name
- json keyvalue
- json value- Returns:
- updated request
-
add
Add custom boolean to payload. If such a name is already added, it will be replaced.- Parameters:
name
- json keyvalue
- json value- Returns:
- updated request
-
add
Add a custom object to payload.- Parameters:
name
- json keyobject
- json value- Returns:
- updated request
-
addBase64
Add a string encoded with base64.- Parameters:
name
- json keybase64Value
- base64 data- Returns:
- updated request
-
emptyArray
Configure an empty array.- Parameters:
name
- name of the property- Returns:
- updated builder
-
addToArray
Add an object to an array.- Parameters:
name
- name of the nested propertyelement
- aApiJsonBuilder
of the element of the array- Returns:
- updated builder
-
addToObject
Add a key/value pair to a named object.- Parameters:
name
- name of the object to create under the rootkey
- key of the nested propertyvalue
- value of the nested property- Returns:
- updated builder
-
addToObject
Add a key/value pair to a named object.- Parameters:
name
- name of the object to create under the rootkey
- key of the nested propertyvalue
- value of the nested property- Returns:
- updated builder
-
addToObject
Add a key/value pair to a named object.- Parameters:
name
- name of the object to create under the rootkey
- key of the nested propertyvalue
- value of the nested property- Returns:
- updated builder
-
addToObject
Add a key/value pair to a named object.- Parameters:
name
- name of the object to create under the rootkey
- key of the nested propertyvalue
- value of the nested property- Returns:
- updated builder
-
addToObject
Add a key/value pair to a named object.- Parameters:
name
- name of the object to create under the rootkey
- key of the nested propertyvalue
- value of the nested property- Returns:
- updated builder
-