Interface JsonBuilder.JsonObjectBuilder

All Superinterfaces:
BiConsumer<String,com.google.gson.JsonElement>, Consumer<Map.Entry<String,com.google.gson.JsonElement>>
Enclosing class:
JsonBuilder

public static interface JsonBuilder.JsonObjectBuilder extends BiConsumer<String,com.google.gson.JsonElement>, Consumer<Map.Entry<String,com.google.gson.JsonElement>>
A JsonObject builder utility
  • Method Details

    • accept

      default void accept(Map.Entry<String,com.google.gson.JsonElement> entry)
      Specified by:
      accept in interface Consumer<Map.Entry<String,com.google.gson.JsonElement>>
    • accept

      default void accept(String property, com.google.gson.JsonElement value)
      Specified by:
      accept in interface BiConsumer<String,com.google.gson.JsonElement>
    • add

      JsonBuilder.JsonObjectBuilder add(String property, @Nullable com.google.gson.JsonElement value, boolean copy)
      Adds a property with the given name and value.

      If copy is true, JsonObject and JsonArray values are deep copied before being added; otherwise the element is referenced directly.

      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      copy - whether to deep copy object and array values
      Returns:
      this builder
    • add

      default JsonBuilder.JsonObjectBuilder add(String property, @Nullable com.google.gson.JsonElement value)
      Adds a property with the given name and value without copying.

      Equivalent to calling add(String, JsonElement, boolean) with copy = false.

      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • add

      default JsonBuilder.JsonObjectBuilder add(String property, @Nullable String value)
      Adds a string property, wrapping the value via JsonBuilder.primitive(String).
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • add

      default JsonBuilder.JsonObjectBuilder add(String property, @Nullable Number value)
      Adds a number property, wrapping the value via JsonBuilder.primitive(Number).
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • add

      default JsonBuilder.JsonObjectBuilder add(String property, @Nullable Boolean value)
      Adds a boolean property, wrapping the value via JsonBuilder.primitive(Boolean).
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • add

      default JsonBuilder.JsonObjectBuilder add(String property, @Nullable Character value)
      Adds a character property, wrapping the value via JsonBuilder.primitive(Character).
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • addIfAbsent

      JsonBuilder.JsonObjectBuilder addIfAbsent(String property, @Nullable com.google.gson.JsonElement value, boolean copy)
      Adds a property only if no property with the same name is already present.

      If copy is true, JsonObject and JsonArray values are deep copied before being added; otherwise the element is referenced directly.

      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      copy - whether to deep copy object and array values
      Returns:
      this builder
    • addIfAbsent

      default JsonBuilder.JsonObjectBuilder addIfAbsent(String property, @Nullable com.google.gson.JsonElement value)
      Adds a property only if no property with the same name is already present, without copying.

      Equivalent to calling addIfAbsent(String, JsonElement, boolean) with copy = false.

      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • addIfAbsent

      default JsonBuilder.JsonObjectBuilder addIfAbsent(String property, @Nullable String value)
      Adds a string property only if no property with the same name is already present.
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • addIfAbsent

      default JsonBuilder.JsonObjectBuilder addIfAbsent(String property, @Nullable Number value)
      Adds a number property only if no property with the same name is already present.
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • addIfAbsent

      default JsonBuilder.JsonObjectBuilder addIfAbsent(String property, @Nullable Boolean value)
      Adds a boolean property only if no property with the same name is already present.
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • addIfAbsent

      default JsonBuilder.JsonObjectBuilder addIfAbsent(String property, @Nullable Character value)
      Adds a character property only if no property with the same name is already present.
      Parameters:
      property - the property name
      value - the value to add, or null to add JsonNull
      Returns:
      this builder
    • addAll

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAll(Iterable<Map.Entry<String,T>> iterable, boolean deepCopy)
      Adds all entries from the iterable.

      Entries with a null key or a null entry itself are skipped. If deepCopy is true, object and array values are deep copied before being added.

      Type Parameters:
      T - the element type
      Parameters:
      iterable - the entries to add
      deepCopy - whether to deep copy object and array values
      Returns:
      this builder
    • addAll

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAll(Iterable<Map.Entry<String,T>> iterable)
      Adds all entries from the iterable without copying.

      Equivalent to calling addAll(Iterable, boolean) with deepCopy = false.

      Type Parameters:
      T - the element type
      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAll

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAll(Stream<Map.Entry<String,T>> stream, boolean deepCopy)
      Adds all entries from the stream.

      Entries with a null key or a null entry itself are skipped. If deepCopy is true, object and array values are deep copied before being added.

      Type Parameters:
      T - the element type
      Parameters:
      stream - the entries to add
      deepCopy - whether to deep copy object and array values
      Returns:
      this builder
    • addAll

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAll(Stream<Map.Entry<String,T>> stream)
      Adds all entries from the stream without copying.

      Equivalent to calling addAll(Stream, boolean) with deepCopy = false.

      Type Parameters:
      T - the element type
      Parameters:
      stream - the entries to add
      Returns:
      this builder
    • addAll

      default JsonBuilder.JsonObjectBuilder addAll(com.google.gson.JsonObject object, boolean deepCopy)
      Adds all entries from another JsonObject.

      If deepCopy is true, object and array values are deep copied before being added.

      Parameters:
      object - the source object
      deepCopy - whether to deep copy object and array values
      Returns:
      this builder
    • addAll

      default JsonBuilder.JsonObjectBuilder addAll(com.google.gson.JsonObject object)
      Adds all entries from another JsonObject without copying.

      Equivalent to calling addAll(JsonObject, boolean) with deepCopy = false.

      Parameters:
      object - the source object
      Returns:
      this builder
    • addAllStrings

      default JsonBuilder.JsonObjectBuilder addAllStrings(Iterable<Map.Entry<String,String>> iterable)
      Adds all string entries from the iterable, wrapping each value via JsonBuilder.primitive(String).

      Entries with a null key or a null entry itself are skipped.

      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllNumbers

      default <T extends Number> JsonBuilder.JsonObjectBuilder addAllNumbers(Iterable<Map.Entry<String,T>> iterable)
      Adds all number entries from the iterable, wrapping each value via JsonBuilder.primitive(Number).

      Entries with a null key or a null entry itself are skipped.

      Type Parameters:
      T - the number type
      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllBooleans

      default JsonBuilder.JsonObjectBuilder addAllBooleans(Iterable<Map.Entry<String,Boolean>> iterable)
      Adds all boolean entries from the iterable, wrapping each value via JsonBuilder.primitive(Boolean).

      Entries with a null key or a null entry itself are skipped.

      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllCharacters

      default JsonBuilder.JsonObjectBuilder addAllCharacters(Iterable<Map.Entry<String,Character>> iterable)
      Adds all character entries from the iterable, wrapping each value via JsonBuilder.primitive(Character).

      Entries with a null key or a null entry itself are skipped.

      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllIfAbsent

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAllIfAbsent(Iterable<Map.Entry<String,T>> iterable, boolean deepCopy)
      Adds all entries from the iterable, skipping any whose key is already present.

      Entries with a null key or a null entry itself are skipped. If deepCopy is true, object and array values are deep copied before being added.

      Type Parameters:
      T - the element type
      Parameters:
      iterable - the entries to add
      deepCopy - whether to deep copy object and array values
      Returns:
      this builder
    • addAllIfAbsent

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAllIfAbsent(Iterable<Map.Entry<String,T>> iterable)
      Adds all entries from the iterable without copying, skipping any whose key is already present.

      Equivalent to calling addAllIfAbsent(Iterable, boolean) with deepCopy = false.

      Type Parameters:
      T - the element type
      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllIfAbsent

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAllIfAbsent(Stream<Map.Entry<String,T>> stream, boolean deepCopy)
      Adds all entries from the stream, skipping any whose key is already present.

      Entries with a null key or a null entry itself are skipped. If deepCopy is true, object and array values are deep copied before being added.

      Type Parameters:
      T - the element type
      Parameters:
      stream - the entries to add
      deepCopy - whether to deep copy object and array values
      Returns:
      this builder
    • addAllIfAbsent

      default <T extends com.google.gson.JsonElement> JsonBuilder.JsonObjectBuilder addAllIfAbsent(Stream<Map.Entry<String,T>> stream)
      Adds all entries from the stream without copying, skipping any whose key is already present.

      Equivalent to calling addAllIfAbsent(Stream, boolean) with deepCopy = false.

      Type Parameters:
      T - the element type
      Parameters:
      stream - the entries to add
      Returns:
      this builder
    • addAllIfAbsent

      default JsonBuilder.JsonObjectBuilder addAllIfAbsent(com.google.gson.JsonObject object, boolean deepCopy)
      Adds all entries from another JsonObject, skipping any whose key is already present.

      If deepCopy is true, object and array values are deep copied before being added.

      Parameters:
      object - the source object
      deepCopy - whether to deep copy object and array values
      Returns:
      this builder
    • addAllIfAbsent

      default JsonBuilder.JsonObjectBuilder addAllIfAbsent(com.google.gson.JsonObject object)
      Adds all entries from another JsonObject without copying, skipping any whose key is already present.

      Equivalent to calling addAllIfAbsent(JsonObject, boolean) with deepCopy = false.

      Parameters:
      object - the source object
      Returns:
      this builder
    • addAllStringsIfAbsent

      default JsonBuilder.JsonObjectBuilder addAllStringsIfAbsent(Iterable<Map.Entry<String,String>> iterable)
      Adds all string entries from the iterable, skipping any whose key is already present.

      Each value is wrapped via JsonBuilder.primitive(String). Entries with a null key or a null entry itself are skipped.

      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllNumbersIfAbsent

      default <T extends Number> JsonBuilder.JsonObjectBuilder addAllNumbersIfAbsent(Iterable<Map.Entry<String,T>> iterable)
      Adds all number entries from the iterable, skipping any whose key is already present.

      Each value is wrapped via JsonBuilder.primitive(Number). Entries with a null key or a null entry itself are skipped.

      Type Parameters:
      T - the number type
      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllBooleansIfAbsent

      default JsonBuilder.JsonObjectBuilder addAllBooleansIfAbsent(Iterable<Map.Entry<String,Boolean>> iterable)
      Adds all boolean entries from the iterable, skipping any whose key is already present.

      Each value is wrapped via JsonBuilder.primitive(Boolean). Entries with a null key or a null entry itself are skipped.

      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • addAllCharactersIfAbsent

      default JsonBuilder.JsonObjectBuilder addAllCharactersIfAbsent(Iterable<Map.Entry<String,Character>> iterable)
      Adds all character entries from the iterable, skipping any whose key is already present.

      Each value is wrapped via JsonBuilder.primitive(Character). Entries with a null key or a null entry itself are skipped.

      Parameters:
      iterable - the entries to add
      Returns:
      this builder
    • build

      com.google.gson.JsonObject build()
      Returns the built JsonObject.
      Returns:
      the built object