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

public abstract class ApiJsonBuilder<T extends ApiJsonBuilder<T>> extends Object
Common base class for builders that construct a JSON object.
  • Constructor Details

    • ApiJsonBuilder

      protected ApiJsonBuilder()
      Default constructor.
  • Method Details

    • toJson

      public Optional<JsonObject> toJson(JsonBuilderFactory factory)
      Create a JSON object from this builder.
      Parameters:
      factory - builder factory to create objects
      Returns:
      JSON object or empty
    • me

      protected T me()
      Can be returned by subclasses that can be subclassed again.
      Returns:
      this instance as a subclass type
    • preBuild

      protected void preBuild(JsonBuilderFactory factory, JsonObjectBuilder payload)
      Called before adding properties defined in this request.
      Parameters:
      factory - json factory
      payload - payload builder
    • postBuild

      protected void postBuild(JsonBuilderFactory factory, JsonObjectBuilder payload)
      Called after adding properties defined in this request.
      Parameters:
      factory - json factory
      payload - payload builder
    • addToArray

      protected T addToArray(String name, String element)
      Add an element to an array.
      Parameters:
      name - key in the json payload
      element - element of the array
      Returns:
      updated request
    • addToArray

      protected T addToArray(String name, int element)
      Add an element to an array.
      Parameters:
      name - key in the json payload
      element - element of the array
      Returns:
      updated request
    • addToArray

      protected T addToArray(String name, long element)
      Add an element to an array.
      Parameters:
      name - key in the json payload
      element - element of the array
      Returns:
      updated request
    • addToArray

      protected T addToArray(String name, double element)
      Add an element to an array.
      Parameters:
      name - key in the json payload
      element - element of the array
      Returns:
      updated request
    • addToArray

      protected T addToArray(String name, boolean element)
      Add an element to an array.
      Parameters:
      name - key in the json payload
      element - element of the array
      Returns:
      updated request
    • add

      protected T add(String name, String value)
      Add custom string to payload. If such a name is already added, it will be replaced.
      Parameters:
      name - json key
      value - json String value
      Returns:
      updated request
    • add

      protected T add(String name, int value)
      Add custom int to payload. If such a name is already added, it will be replaced.
      Parameters:
      name - json key
      value - json value
      Returns:
      updated request
    • add

      protected T add(String name, double value)
      Add custom double to payload. If such a name is already added, it will be replaced.
      Parameters:
      name - json key
      value - json value
      Returns:
      updated request
    • add

      protected T add(String name, long value)
      Add custom long to payload. If such a name is already added, it will be replaced.
      Parameters:
      name - json key
      value - json value
      Returns:
      updated request
    • add

      protected T add(String name, boolean value)
      Add custom boolean to payload. If such a name is already added, it will be replaced.
      Parameters:
      name - json key
      value - json value
      Returns:
      updated request
    • add

      protected T add(String name, ApiJsonBuilder<?> object)
      Add a custom object to payload.
      Parameters:
      name - json key
      object - json value
      Returns:
      updated request
    • addBase64

      protected T addBase64(String name, Base64Value base64Value)
      Add a string encoded with base64.
      Parameters:
      name - json key
      base64Value - base64 data
      Returns:
      updated request
    • emptyArray

      protected T emptyArray(String name)
      Configure an empty array.
      Parameters:
      name - name of the property
      Returns:
      updated builder
    • addToArray

      protected T addToArray(String name, ApiJsonBuilder<?> element)
      Add an object to an array.
      Parameters:
      name - name of the nested property
      element - a ApiJsonBuilder of the element of the array
      Returns:
      updated builder
    • addToObject

      protected T addToObject(String name, String key, String value)
      Add a key/value pair to a named object.
      Parameters:
      name - name of the object to create under the root
      key - key of the nested property
      value - value of the nested property
      Returns:
      updated builder
    • addToObject

      protected T addToObject(String name, String key, int value)
      Add a key/value pair to a named object.
      Parameters:
      name - name of the object to create under the root
      key - key of the nested property
      value - value of the nested property
      Returns:
      updated builder
    • addToObject

      protected T addToObject(String name, String key, long value)
      Add a key/value pair to a named object.
      Parameters:
      name - name of the object to create under the root
      key - key of the nested property
      value - value of the nested property
      Returns:
      updated builder
    • addToObject

      protected T addToObject(String name, String key, double value)
      Add a key/value pair to a named object.
      Parameters:
      name - name of the object to create under the root
      key - key of the nested property
      value - value of the nested property
      Returns:
      updated builder
    • addToObject

      protected T addToObject(String name, String key, boolean value)
      Add a key/value pair to a named object.
      Parameters:
      name - name of the object to create under the root
      key - key of the nested property
      value - value of the nested property
      Returns:
      updated builder