Class JsonCollectors

java.lang.Object
org.eclipse.ditto.json.JsonCollectors

@Immutable public final class JsonCollectors extends Object
This class provides implementations of Collector that implement various useful reduction operations, such as accumulating JSON fields into JSON objects etc.
  • Method Details

    • fieldsToObject

      public static Collector<JsonField,JsonObjectBuilder,JsonObject> fieldsToObject()
      Returns a Collector that accumulates the input JSON fields into a new JsonObject.
      Returns:
      a Collector which collects all the JSON fields into a JsonObject, in encounter order.
    • objectsToObject

      public static Collector<JsonObject,JsonObjectBuilder,JsonObject> objectsToObject()
      Returns a Collector that accumulates the input JSON objects into a new JsonObject.
      Returns:
      a Collector which collects all the JSON object into a JsonObject, in encounter order.
    • fieldKeysToArray

      public static Collector<JsonField,JsonArrayBuilder,JsonArray> fieldKeysToArray()
      Returns a Collector that accumulates the key names of input JSON fields into a new JsonArray. The values are hereby dismissed.
      Returns:
      a Collector which collects the key names of all the JSON fields into a JsonArray, in encounter order.
    • fieldValuesToArray

      public static Collector<JsonField,JsonArrayBuilder,JsonArray> fieldValuesToArray()

      Returns a Collector that accumulates the values of input JSON fields into a new JsonArray. 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 a JsonArray, in encounter order.
    • valuesToArray

      public static Collector<JsonValue,JsonArrayBuilder,JsonArray> valuesToArray()
      Returns a Collector that accumulates the input JSON values into a new JsonArray.
      Returns:
      a Collector which collects all the JSON values into a JsonArray, in encounter order.