- java.lang.Object
- 
- jakarta.json.stream.JsonCollectors
 
- 
 public final class JsonCollectors extends Object This class contains some implementations ofjava.util.stream.Collectorfor accumulatingJsonValues intoJsonArrayandJsonObject.- Since:
- 1.1
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static Collector<JsonValue,Map<String,JsonArrayBuilder>,JsonObject>groupingBy(Function<JsonValue,String> classifier)Constructs ajava.util.stream.Collectorthat implements a "group by" operation on the inputJsonValueelements.static <T extends JsonArrayBuilder>
 Collector<JsonValue,Map<String,T>,JsonObject>groupingBy(Function<JsonValue,String> classifier, Collector<JsonValue,T,JsonArray> downstream)Constructs ajava.util.stream.Collectorthat implements a "group by" operation on the inputJsonValueelements.static Collector<JsonValue,JsonArrayBuilder,JsonArray>toJsonArray()Constructs ajava.util.stream.Collectorthat accumulates the inputJsonValueelements into aJsonArray.static Collector<Map.Entry<String,JsonValue>,JsonObjectBuilder,JsonObject>toJsonObject()Constructs ajava.util.stream.Collectorthat accumulates the inputMap.Entry<String,JsonValue>elements into aJsonObject.static Collector<JsonValue,JsonObjectBuilder,JsonObject>toJsonObject(Function<JsonValue,String> keyMapper, Function<JsonValue,JsonValue> valueMapper)Constructs ajava.util.stream.Collectorthat accumulates the inputJsonValueelements into aJsonObject.
 
- 
- 
- 
Method Detail- 
toJsonArraypublic static Collector<JsonValue,JsonArrayBuilder,JsonArray> toJsonArray() Constructs ajava.util.stream.Collectorthat accumulates the inputJsonValueelements into aJsonArray.- Returns:
- the constructed Collector
 
 - 
toJsonObjectpublic static Collector<Map.Entry<String,JsonValue>,JsonObjectBuilder,JsonObject> toJsonObject() Constructs ajava.util.stream.Collectorthat accumulates the inputMap.Entry<String,JsonValue>elements into aJsonObject.- Returns:
- the constructed Collector
 
 - 
toJsonObjectpublic static Collector<JsonValue,JsonObjectBuilder,JsonObject> toJsonObject(Function<JsonValue,String> keyMapper, Function<JsonValue,JsonValue> valueMapper) Constructs ajava.util.stream.Collectorthat accumulates the inputJsonValueelements into aJsonObject. The name/value pairs of theJsonObjectare computed by applying the provided mapping functions.- Parameters:
- keyMapper- a mapping function to produce names.
- valueMapper- a mapping function to produce values
- Returns:
- the constructed Collector
 
 - 
groupingBypublic static <T extends JsonArrayBuilder> Collector<JsonValue,Map<String,T>,JsonObject> groupingBy(Function<JsonValue,String> classifier, Collector<JsonValue,T,JsonArray> downstream) Constructs ajava.util.stream.Collectorthat implements a "group by" operation on the inputJsonValueelements. A classifier function maps the inputJsonValues to keys, and theJsonValues are partitioned into groups according to the value of the key. A reduction operation is performed on theJsonValues in each group, using the downstreamCollector. For each group, the key and the results of the reduction operation become the name/value pairs of the resultantJsonObject.- Type Parameters:
- T- the intermediate accumulation- JsonArrayBuilderof the downstream collector
- Parameters:
- classifier- a function mapping the input- JsonValues to a String, producing keys
- downstream- a- Collectorthat implements a reduction operation on the- JsonValues in each group.
- Returns:
- the constructed Collector
 
 - 
groupingBypublic static Collector<JsonValue,Map<String,JsonArrayBuilder>,JsonObject> groupingBy(Function<JsonValue,String> classifier) Constructs ajava.util.stream.Collectorthat implements a "group by" operation on the inputJsonValueelements. A classifier function maps the inputJsonValues to keys, and theJsonValues are partitioned into groups according to the value of the key. TheJsonValues in each group are added to aJsonArray. The key and theJsonArrayin each group becomes the name/value pair of the resultantJsonObject.- Parameters:
- classifier- a function mapping the input- JsonValues to a String, producing keys
- Returns:
- the constructed Collector
 
 
- 
 
-