Interface JsonBuilder.JsonObjectBuilder
- All Superinterfaces:
BiConsumer<String,,com.google.gson.JsonElement> Consumer<Map.Entry<String,com.google.gson.JsonElement>>
- Enclosing class:
- JsonBuilder
JsonObject builder utility-
Method Summary
Modifier and TypeMethodDescriptiondefault voiddefault voiddefault JsonBuilder.JsonObjectBuilderAdds a property with the given name and value without copying.Adds a property with the given name and value.default JsonBuilder.JsonObjectBuilderAdds a boolean property, wrapping the value viaJsonBuilder.primitive(Boolean).default JsonBuilder.JsonObjectBuilderAdds a character property, wrapping the value viaJsonBuilder.primitive(Character).default JsonBuilder.JsonObjectBuilderAdds a number property, wrapping the value viaJsonBuilder.primitive(Number).default JsonBuilder.JsonObjectBuilderAdds a string property, wrapping the value viaJsonBuilder.primitive(String).default JsonBuilder.JsonObjectBuilderaddAll(com.google.gson.JsonObject object) Adds all entries from anotherJsonObjectwithout copying.default JsonBuilder.JsonObjectBuilderaddAll(com.google.gson.JsonObject object, boolean deepCopy) Adds all entries from anotherJsonObject.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderAdds all entries from the iterable without copying.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderAdds all entries from the iterable.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderAdds all entries from the stream without copying.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderAdds all entries from the stream.default JsonBuilder.JsonObjectBuilderaddAllBooleans(Iterable<Map.Entry<String, Boolean>> iterable) Adds all boolean entries from the iterable, wrapping each value viaJsonBuilder.primitive(Boolean).default JsonBuilder.JsonObjectBuilderaddAllBooleansIfAbsent(Iterable<Map.Entry<String, Boolean>> iterable) Adds all boolean entries from the iterable, skipping any whose key is already present.default JsonBuilder.JsonObjectBuilderaddAllCharacters(Iterable<Map.Entry<String, Character>> iterable) Adds all character entries from the iterable, wrapping each value viaJsonBuilder.primitive(Character).default JsonBuilder.JsonObjectBuilderaddAllCharactersIfAbsent(Iterable<Map.Entry<String, Character>> iterable) Adds all character entries from the iterable, skipping any whose key is already present.default JsonBuilder.JsonObjectBuilderaddAllIfAbsent(com.google.gson.JsonObject object) Adds all entries from anotherJsonObjectwithout copying, skipping any whose key is already present.default JsonBuilder.JsonObjectBuilderaddAllIfAbsent(com.google.gson.JsonObject object, boolean deepCopy) Adds all entries from anotherJsonObject, skipping any whose key is already present.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderaddAllIfAbsent(Iterable<Map.Entry<String, T>> iterable) Adds all entries from the iterable without copying, skipping any whose key is already present.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderaddAllIfAbsent(Iterable<Map.Entry<String, T>> iterable, boolean deepCopy) Adds all entries from the iterable, skipping any whose key is already present.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderaddAllIfAbsent(Stream<Map.Entry<String, T>> stream) Adds all entries from the stream without copying, skipping any whose key is already present.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonObjectBuilderaddAllIfAbsent(Stream<Map.Entry<String, T>> stream, boolean deepCopy) Adds all entries from the stream, skipping any whose key is already present.default <T extends Number>
JsonBuilder.JsonObjectBuilderaddAllNumbers(Iterable<Map.Entry<String, T>> iterable) Adds all number entries from the iterable, wrapping each value viaJsonBuilder.primitive(Number).default <T extends Number>
JsonBuilder.JsonObjectBuilderaddAllNumbersIfAbsent(Iterable<Map.Entry<String, T>> iterable) Adds all number entries from the iterable, skipping any whose key is already present.default JsonBuilder.JsonObjectBuilderaddAllStrings(Iterable<Map.Entry<String, String>> iterable) Adds all string entries from the iterable, wrapping each value viaJsonBuilder.primitive(String).default JsonBuilder.JsonObjectBuilderaddAllStringsIfAbsent(Iterable<Map.Entry<String, String>> iterable) Adds all string entries from the iterable, skipping any whose key is already present.default JsonBuilder.JsonObjectBuilderaddIfAbsent(String property, com.google.gson.JsonElement value) Adds a property only if no property with the same name is already present, without copying.addIfAbsent(String property, com.google.gson.JsonElement value, boolean copy) Adds a property only if no property with the same name is already present.default JsonBuilder.JsonObjectBuilderaddIfAbsent(String property, Boolean value) Adds a boolean property only if no property with the same name is already present.default JsonBuilder.JsonObjectBuilderaddIfAbsent(String property, Character value) Adds a character property only if no property with the same name is already present.default JsonBuilder.JsonObjectBuilderaddIfAbsent(String property, Number value) Adds a number property only if no property with the same name is already present.default JsonBuilder.JsonObjectBuilderaddIfAbsent(String property, String value) Adds a string property only if no property with the same name is already present.com.google.gson.JsonObjectbuild()Returns the builtJsonObject.Methods inherited from interface java.util.function.BiConsumer
andThen
-
Method Details
-
accept
-
accept
- Specified by:
acceptin interfaceBiConsumer<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
copyis true,JsonObjectandJsonArrayvalues are deep copied before being added; otherwise the element is referenced directly.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNullcopy- 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)withcopy = false.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Adds a string property, wrapping the value viaJsonBuilder.primitive(String).- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Adds a number property, wrapping the value viaJsonBuilder.primitive(Number).- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Adds a boolean property, wrapping the value viaJsonBuilder.primitive(Boolean).- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Adds a character property, wrapping the value viaJsonBuilder.primitive(Character).- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- 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
copyis true,JsonObjectandJsonArrayvalues are deep copied before being added; otherwise the element is referenced directly.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNullcopy- 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)withcopy = false.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
addIfAbsent
Adds a string property only if no property with the same name is already present.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
addIfAbsent
Adds a number property only if no property with the same name is already present.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
addIfAbsent
Adds a boolean property only if no property with the same name is already present.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- Returns:
- this builder
-
addIfAbsent
Adds a character property only if no property with the same name is already present.- Parameters:
property- the property namevalue- the value to add, ornullto addJsonNull- 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
nullkey or anullentry itself are skipped. IfdeepCopyis true, object and array values are deep copied before being added.- Type Parameters:
T- the element type- Parameters:
iterable- the entries to adddeepCopy- 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)withdeepCopy = 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
nullkey or anullentry itself are skipped. IfdeepCopyis true, object and array values are deep copied before being added.- Type Parameters:
T- the element type- Parameters:
stream- the entries to adddeepCopy- 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)withdeepCopy = false.- Type Parameters:
T- the element type- Parameters:
stream- the entries to add- Returns:
- this builder
-
addAll
Adds all entries from anotherJsonObject.If
deepCopyis true, object and array values are deep copied before being added.- Parameters:
object- the source objectdeepCopy- whether to deep copy object and array values- Returns:
- this builder
-
addAll
Adds all entries from anotherJsonObjectwithout copying.Equivalent to calling
addAll(JsonObject, boolean)withdeepCopy = false.- Parameters:
object- the source object- Returns:
- this builder
-
addAllStrings
Adds all string entries from the iterable, wrapping each value viaJsonBuilder.primitive(String).Entries with a
nullkey or anullentry 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 viaJsonBuilder.primitive(Number).Entries with a
nullkey or anullentry itself are skipped.- Type Parameters:
T- the number type- Parameters:
iterable- the entries to add- Returns:
- this builder
-
addAllBooleans
Adds all boolean entries from the iterable, wrapping each value viaJsonBuilder.primitive(Boolean).Entries with a
nullkey or anullentry 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 viaJsonBuilder.primitive(Character).Entries with a
nullkey or anullentry 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
nullkey or anullentry itself are skipped. IfdeepCopyis true, object and array values are deep copied before being added.- Type Parameters:
T- the element type- Parameters:
iterable- the entries to adddeepCopy- 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)withdeepCopy = 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
nullkey or anullentry itself are skipped. IfdeepCopyis true, object and array values are deep copied before being added.- Type Parameters:
T- the element type- Parameters:
stream- the entries to adddeepCopy- 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)withdeepCopy = 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 anotherJsonObject, skipping any whose key is already present.If
deepCopyis true, object and array values are deep copied before being added.- Parameters:
object- the source objectdeepCopy- whether to deep copy object and array values- Returns:
- this builder
-
addAllIfAbsent
Adds all entries from anotherJsonObjectwithout copying, skipping any whose key is already present.Equivalent to calling
addAllIfAbsent(JsonObject, boolean)withdeepCopy = 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 anullkey or anullentry 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 anullkey or anullentry 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 anullkey or anullentry 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 anullkey or anullentry itself are skipped.- Parameters:
iterable- the entries to add- Returns:
- this builder
-
build
com.google.gson.JsonObject build()Returns the builtJsonObject.- Returns:
- the built object
-