JsonCollectors { public static Collector<JsonField, JsonArrayBuilder, JsonArray> fieldValuesToArray() { return Collector.of(JsonFactory::newArrayBuilder, (arrayBuilder, field) -> arrayBuilder.add(field.getValue()), JsonArrayBuilder::addAll, JsonArrayBuilder::build); } private  JsonCollectors(); static Collector<JsonField, JsonObjectBuilder, JsonObject> fieldsToObject(); static Collector<JsonObject, JsonObjectBuilder, JsonObject> objectsToObject(); static Collector<JsonField, JsonArrayBuilder, JsonArray> fieldKeysToArray(); static Collector<JsonField, JsonArrayBuilder, JsonArray> fieldValuesToArray(); static Collector<JsonValue, JsonArrayBuilder, JsonArray> valuesToArray();  }
@Test public void collectingFieldValuesOfObjectReturnsExpectedArray() { final JsonArray expectedArray = JsonFactory.newArrayBuilder() .add(ID) .add(STATE) .add(MANUFACTURER) .build(); final JsonArray actualArray = KNOWN_JSON_OBJECT.stream() .collect(JsonCollectors.fieldValuesToArray()); DittoJsonAssertions.assertThat(actualArray).isEqualTo(expectedArray); }