public final class JsonCollectors extends Object
java.util.stream.Collector
for accumulating
JsonValue
s into JsonArray
and JsonObject
.Modifier and Type | Method and Description |
---|---|
static Collector<JsonValue,Map<String,JsonArrayBuilder>,JsonObject> |
groupingBy(Function<JsonValue,String> classifier)
Constructs a
java.util.stream.Collector that implements a "group by" operation on the
input JsonValue elements. |
static <T extends JsonArrayBuilder> |
groupingBy(Function<JsonValue,String> classifier,
Collector<JsonValue,T,JsonArray> downstream)
Constructs a
java.util.stream.Collector that implements a "group by" operation on the
input JsonValue elements. |
static Collector<JsonValue,JsonArrayBuilder,JsonArray> |
toJsonArray()
Constructs a
java.util.stream.Collector that accumulates the input JsonValue
elements into a JsonArray . |
static Collector<Map.Entry<String,JsonValue>,JsonObjectBuilder,JsonObject> |
toJsonObject()
Constructs a
java.util.stream.Collector that accumulates the input Map.Entry<String,JsonValue>
elements into a JsonObject . |
static Collector<JsonValue,JsonObjectBuilder,JsonObject> |
toJsonObject(Function<JsonValue,String> keyMapper,
Function<JsonValue,JsonValue> valueMapper)
Constructs a
java.util.stream.Collector that accumulates the input JsonValue
elements into a JsonObject . |
public static Collector<JsonValue,JsonArrayBuilder,JsonArray> toJsonArray()
java.util.stream.Collector
that accumulates the input JsonValue
elements into a JsonArray
.public static Collector<Map.Entry<String,JsonValue>,JsonObjectBuilder,JsonObject> toJsonObject()
java.util.stream.Collector
that accumulates the input Map.Entry<String,JsonValue>
elements into a JsonObject
.public static Collector<JsonValue,JsonObjectBuilder,JsonObject> toJsonObject(Function<JsonValue,String> keyMapper, Function<JsonValue,JsonValue> valueMapper)
java.util.stream.Collector
that accumulates the input JsonValue
elements into a JsonObject
. The name/value pairs of the JsonObject
are computed
by applying the provided mapping functions.keyMapper
- a mapping function to produce names.valueMapper
- a mapping function to produce valuespublic static <T extends JsonArrayBuilder> Collector<JsonValue,Map<String,T>,JsonObject> groupingBy(Function<JsonValue,String> classifier, Collector<JsonValue,T,JsonArray> downstream)
java.util.stream.Collector
that implements a "group by" operation on the
input JsonValue
elements. A classifier function maps the input JsonValue
s to keys, and
the JsonValue
s are partitioned into groups according to the value of the key.
A reduction operation is performed on the JsonValue
s in each group, using the
downstream Collector
. For each group, the key and the results of the reduction operation
become the name/value pairs of the resultant JsonObject
.T
- the intermediate accumulation JsonArrayBuilder
of the downstream collectorclassifier
- a function mapping the input JsonValue
s to a String, producing keysdownstream
- a Collector
that implements a reduction operation on the
JsonValue
s in each group.Collector
public static Collector<JsonValue,Map<String,JsonArrayBuilder>,JsonObject> groupingBy(Function<JsonValue,String> classifier)
java.util.stream.Collector
that implements a "group by" operation on the
input JsonValue
elements. A classifier function maps the input JsonValue
s to keys, and
the JsonValue
s are partitioned into groups according to the value of the key.
The JsonValue
s in each group are added to a JsonArray
. The key and the
JsonArray
in each group becomes the name/value pair of the resultant JsonObject
.classifier
- a function mapping the input JsonValue
s to a String, producing keysCollector
Copyright © 2018,2020 Eclipse Foundation.
Use is subject to license terms.