Package org.eclipse.ditto.json
Class JsonCollectors
java.lang.Object
org.eclipse.ditto.json.JsonCollectors
This class provides implementations of
Collector
that implement various useful reduction operations, such as
accumulating JSON fields into JSON objects etc.-
Method Summary
Modifier and TypeMethodDescriptionstatic Collector<JsonField,
JsonArrayBuilder, JsonArray> Returns aCollector
that accumulates the key names of input JSON fields into a newJsonArray
.Returns aCollector
that accumulates the input JSON fields into a newJsonObject
.static Collector<JsonField,
JsonArrayBuilder, JsonArray> Returns aCollector
that accumulates the values of input JSON fields into a newJsonArray
.Returns aCollector
that accumulates the input JSON objects into a newJsonObject
.static Collector<JsonValue,
JsonArrayBuilder, JsonArray> Returns aCollector
that accumulates the input JSON values into a newJsonArray
.
-
Method Details
-
fieldsToObject
Returns aCollector
that accumulates the input JSON fields into a newJsonObject
.- Returns:
- a
Collector
which collects all the JSON fields into aJsonObject
, in encounter order.
-
objectsToObject
Returns aCollector
that accumulates the input JSON objects into a newJsonObject
.- Returns:
- a
Collector
which collects all the JSON object into aJsonObject
, in encounter order.
-
fieldKeysToArray
Returns aCollector
that accumulates the key names of input JSON fields into a newJsonArray
. The values are hereby dismissed.- Returns:
- a
Collector
which collects the key names of all the JSON fields into aJsonArray
, in encounter order.
-
fieldValuesToArray
Returns a
Collector
that accumulates the values of input JSON fields into a newJsonArray
. The keys are hereby dismissed.Caution: Due to the fact that each field of a JSON object can have a different type the resulting array will also consist of values of different types!
- Returns:
- a
Collector
which collects the values of all the JSON fields into aJsonArray
, in encounter order.
-
valuesToArray
Returns aCollector
that accumulates the input JSON values into a newJsonArray
.- Returns:
- a
Collector
which collects all the JSON values into aJsonArray
, in encounter order.
-