Package dev.demeng.pluginbase.gson
Interface JsonBuilder.JsonArrayBuilder
- All Superinterfaces:
Consumer<com.google.gson.JsonElement>
- Enclosing class:
- JsonBuilder
A
JsonArray builder utility-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaccept(com.google.gson.JsonElement value) default JsonBuilder.JsonArrayBuilderadd(com.google.gson.JsonElement value) Appends an element to the array without copying.add(com.google.gson.JsonElement value, boolean copy) Appends an element to the array.default JsonBuilder.JsonArrayBuilderAppends a boolean element, wrapping the value viaJsonBuilder.primitive(Boolean).default JsonBuilder.JsonArrayBuilderAppends a character element, wrapping the value viaJsonBuilder.primitive(Character).default JsonBuilder.JsonArrayBuilderAppends a number element, wrapping the value viaJsonBuilder.primitive(Number).default JsonBuilder.JsonArrayBuilderAppends a string element, wrapping the value viaJsonBuilder.primitive(String).default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonArrayBuilderAppends all elements from the iterable without copying.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonArrayBuilderAppends all elements from the iterable.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonArrayBuilderAppends all elements from the stream without copying.default <T extends com.google.gson.JsonElement>
JsonBuilder.JsonArrayBuilderAppends all elements from the stream.default JsonBuilder.JsonArrayBuilderaddBooleans(Iterable<Boolean> iterable) Appends all booleans from the iterable, wrapping each value viaJsonBuilder.primitive(Boolean).default JsonBuilder.JsonArrayBuilderaddCharacters(Iterable<Character> iterable) Appends all characters from the iterable, wrapping each value viaJsonBuilder.primitive(Character).default <T extends Number>
JsonBuilder.JsonArrayBuilderaddNumbers(Iterable<T> iterable) Appends all numbers from the iterable, wrapping each value viaJsonBuilder.primitive(Number).default JsonBuilder.JsonArrayBuilderaddStrings(Iterable<String> iterable) Appends all strings from the iterable, wrapping each value viaJsonBuilder.primitive(String).com.google.gson.JsonArraybuild()Returns the builtJsonArray.
-
Method Details
-
accept
default void accept(com.google.gson.JsonElement value) -
add
Appends an element to the array.If
copyis true,JsonObjectandJsonArrayvalues are deep copied before being added; otherwise the element is referenced directly.- Parameters:
value- the element to add, ornullto addJsonNullcopy- whether to deep copy object and array values- Returns:
- this builder
-
add
Appends an element to the array without copying.Equivalent to calling
add(JsonElement, boolean)withcopy = false.- Parameters:
value- the element to add, ornullto addJsonNull- Returns:
- this builder
-
add
Appends a string element, wrapping the value viaJsonBuilder.primitive(String).- Parameters:
value- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Appends a number element, wrapping the value viaJsonBuilder.primitive(Number).- Parameters:
value- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Appends a boolean element, wrapping the value viaJsonBuilder.primitive(Boolean).- Parameters:
value- the value to add, ornullto addJsonNull- Returns:
- this builder
-
add
Appends a character element, wrapping the value viaJsonBuilder.primitive(Character).- Parameters:
value- the value to add, ornullto addJsonNull- Returns:
- this builder
-
addAll
default <T extends com.google.gson.JsonElement> JsonBuilder.JsonArrayBuilder addAll(Iterable<T> iterable, boolean copy) Appends all elements from the iterable.If
copyis true, object and array values are deep copied before being added.- Type Parameters:
T- the element type- Parameters:
iterable- the elements to addcopy- whether to deep copy object and array values- Returns:
- this builder
-
addAll
default <T extends com.google.gson.JsonElement> JsonBuilder.JsonArrayBuilder addAll(Iterable<T> iterable) Appends all elements from the iterable without copying.Equivalent to calling
addAll(Iterable, boolean)withcopy = false.- Type Parameters:
T- the element type- Parameters:
iterable- the elements to add- Returns:
- this builder
-
addAll
default <T extends com.google.gson.JsonElement> JsonBuilder.JsonArrayBuilder addAll(Stream<T> stream, boolean copy) Appends all elements from the stream.If
copyis true, object and array values are deep copied before being added.- Type Parameters:
T- the element type- Parameters:
stream- the elements to addcopy- whether to deep copy object and array values- Returns:
- this builder
-
addAll
default <T extends com.google.gson.JsonElement> JsonBuilder.JsonArrayBuilder addAll(Stream<T> stream) Appends all elements from the stream without copying.Equivalent to calling
addAll(Stream, boolean)withcopy = false.- Type Parameters:
T- the element type- Parameters:
stream- the elements to add- Returns:
- this builder
-
addStrings
Appends all strings from the iterable, wrapping each value viaJsonBuilder.primitive(String).- Parameters:
iterable- the values to add- Returns:
- this builder
-
addNumbers
Appends all numbers from the iterable, wrapping each value viaJsonBuilder.primitive(Number).- Type Parameters:
T- the number type- Parameters:
iterable- the values to add- Returns:
- this builder
-
addBooleans
Appends all booleans from the iterable, wrapping each value viaJsonBuilder.primitive(Boolean).- Parameters:
iterable- the values to add- Returns:
- this builder
-
addCharacters
Appends all characters from the iterable, wrapping each value viaJsonBuilder.primitive(Character).- Parameters:
iterable- the values to add- Returns:
- this builder
-
build
com.google.gson.JsonArray build()Returns the builtJsonArray.- Returns:
- the built array
-