@NonnullByDefault public final class JsonBuilder extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
JsonBuilder.JsonArrayBuilder
A
JsonArray builder utility |
static interface |
JsonBuilder.JsonObjectBuilder
A
JsonObject builder utility |
| Modifier and Type | Method and Description |
|---|---|
static JsonBuilder.JsonArrayBuilder |
array()
Creates a new array builder, with no initial values
|
static JsonBuilder.JsonArrayBuilder |
array(com.google.gson.JsonArray array)
Creates a new array builder, without copying the passed array.
|
static JsonBuilder.JsonArrayBuilder |
array(com.google.gson.JsonArray array,
boolean copy)
Creates a new array builder
|
static Collector<GsonSerializable,JsonBuilder.JsonArrayBuilder,com.google.gson.JsonArray> |
collectSerializablesToArray()
Returns a collector which forms a JsonArray from GsonSerializables
|
static Collector<com.google.gson.JsonElement,JsonBuilder.JsonArrayBuilder,com.google.gson.JsonArray> |
collectToArray()
Returns a collector which forms a JsonArray from JsonElements
|
static <T> Collector<T,JsonBuilder.JsonArrayBuilder,com.google.gson.JsonArray> |
collectToArray(Function<? super T,com.google.gson.JsonElement> valueMapper)
Returns a collector which forms a JsonArray using the value mapper
|
static <T> Collector<T,JsonBuilder.JsonObjectBuilder,com.google.gson.JsonObject> |
collectToObject(Function<? super T,String> keyMapper,
Function<? super T,com.google.gson.JsonElement> valueMapper)
Returns a collector which forms a JsonObject using the key and value mappers
|
static com.google.gson.JsonNull |
nullValue()
Returns an instance of
JsonNull. |
static JsonBuilder.JsonObjectBuilder |
object()
Creates a new object builder, with no initial values
|
static JsonBuilder.JsonObjectBuilder |
object(com.google.gson.JsonObject object)
Creates a new object builder, without copying the passed object.
|
static JsonBuilder.JsonObjectBuilder |
object(com.google.gson.JsonObject object,
boolean copy)
Creates a new object builder
|
static com.google.gson.JsonElement |
primitive(Boolean value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonElement |
primitive(Character value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonElement |
primitive(Number value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonElement |
primitive(String value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonPrimitive |
primitiveNonNull(Boolean value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonPrimitive |
primitiveNonNull(Character value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonPrimitive |
primitiveNonNull(Number value)
Creates a JsonPrimitive from the given value.
|
static com.google.gson.JsonPrimitive |
primitiveNonNull(String value)
Creates a JsonPrimitive from the given value.
|
public static JsonBuilder.JsonObjectBuilder object(com.google.gson.JsonObject object, boolean copy)
If copy is not true, the passed object will be mutated by the builder methods.
object - the object to base the new builder uponcopy - if the object should be deep copied, or just referenced.public static JsonBuilder.JsonObjectBuilder object(com.google.gson.JsonObject object)
Equivalent to calling object(JsonObject, boolean) with copy = false.
object - the object to base the new builder uponpublic static JsonBuilder.JsonObjectBuilder object()
public static JsonBuilder.JsonArrayBuilder array(com.google.gson.JsonArray array, boolean copy)
If copy is not true, the passed array will be mutated by the builder methods.
array - the array to base the new builder uponcopy - if the array should be deep copied, or just referenced.public static JsonBuilder.JsonArrayBuilder array(com.google.gson.JsonArray array)
Equivalent to calling array(JsonArray, boolean) with copy = false.
array - the array to base the new builder uponpublic static JsonBuilder.JsonArrayBuilder array()
public static com.google.gson.JsonElement primitive(@Nullable String value)
If the value is null, nullValue() is returned.
value - the valuepublic static com.google.gson.JsonElement primitive(@Nullable Number value)
If the value is null, nullValue() is returned.
value - the valuepublic static com.google.gson.JsonElement primitive(@Nullable Boolean value)
If the value is null, nullValue() is returned.
value - the valuepublic static com.google.gson.JsonElement primitive(@Nullable Character value)
If the value is null, nullValue() is returned.
value - the valuepublic static com.google.gson.JsonNull nullValue()
JsonNull.public static com.google.gson.JsonPrimitive primitiveNonNull(String value)
If the value is null, a NullPointerException will be thrown.
value - the valueNullPointerException - if value is nullpublic static com.google.gson.JsonPrimitive primitiveNonNull(Number value)
If the value is null, a NullPointerException will be thrown.
value - the valueNullPointerException - if value is nullpublic static com.google.gson.JsonPrimitive primitiveNonNull(Boolean value)
If the value is null, a NullPointerException will be thrown.
value - the valueNullPointerException - if value is nullpublic static com.google.gson.JsonPrimitive primitiveNonNull(Character value)
If the value is null, a NullPointerException will be thrown.
value - the valueNullPointerException - if value is nullpublic static <T> Collector<T,JsonBuilder.JsonObjectBuilder,com.google.gson.JsonObject> collectToObject(Function<? super T,String> keyMapper, Function<? super T,com.google.gson.JsonElement> valueMapper)
T - the typekeyMapper - the function to map from T to StringvalueMapper - the function to map from T to JsonElementpublic static <T> Collector<T,JsonBuilder.JsonArrayBuilder,com.google.gson.JsonArray> collectToArray(Function<? super T,com.google.gson.JsonElement> valueMapper)
T - the typevalueMapper - the function to map from T to JsonElementpublic static Collector<com.google.gson.JsonElement,JsonBuilder.JsonArrayBuilder,com.google.gson.JsonArray> collectToArray()
public static Collector<GsonSerializable,JsonBuilder.JsonArrayBuilder,com.google.gson.JsonArray> collectSerializablesToArray()
Copyright © 2020. All rights reserved.