@Override public FeaturePropertiesBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate) { jsonObjectBuilder.setAll(fields, predicate); return this; }
@Override public FeaturePropertiesBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate) { jsonObjectBuilder.setAll(fields, predicate); return this; }
/** * Sets the given {@link JsonField}s to the JSON object to be built. This method prevents duplicates, i. e. if two * fields have the same key, the previous field is replaced by the new field; the position of the new field in the * resulting JSON object is the same as the position of the previous field. * * @param fields the fields to set. * @return this builder to allow method chaining. * @throws NullPointerException if {@code fields} is {@code null}. */ default JsonObjectBuilder setAll(final Iterable<JsonField> fields) { return setAll(fields, field -> true); }
@Override public AttributesBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate) { jsonObjectBuilder.setAll(fields, predicate); return this; }
/** * Sets the given {@link JsonField}s to the JSON object to be built. This method prevents duplicates, i. e. if two * fields have the same key, the previous field is replaced by the new field; the position of the new field in the * resulting JSON object is the same as the position of the previous field. * * @param fields the fields to set. * @return this builder to allow method chaining. * @throws NullPointerException if {@code fields} is {@code null}. */ default JsonObjectBuilder setAll(final Iterable<JsonField> fields) { return setAll(fields, field -> true); }
@Override public AttributesBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate) { jsonObjectBuilder.setAll(fields, predicate); return this; }
/** * Returns a new mutable builder for the specified {@code JsonField}s. The returned builder is already initialised * with the data of the provided JSON object. This method is useful if an existing JSON object should be strongly * modified but the amount of creating objects should be kept low at the same time. * * @param jsonFields are the initial data of the returned builder. * @return a new JSON object builder with pre-filled data of {@code jsonFields}. * @throws NullPointerException if {@code jsonFields} is {@code null}. */ public static JsonObjectBuilder newObjectBuilder(final Iterable<JsonField> jsonFields) { requireNonNull(jsonFields, "The initial JSON fields must not be null!"); return newObjectBuilder().setAll(jsonFields); }
/** * Returns a new mutable builder for the specified {@code JsonField}s. The returned builder is already initialised * with the data of the provided JSON object. This method is useful if an existing JSON object should be strongly * modified but the amount of creating objects should be kept low at the same time. * * @param jsonFields are the initial data of the returned builder. * @return a new JSON object builder with pre-filled data of {@code jsonFields}. * @throws NullPointerException if {@code jsonFields} is {@code null}. */ public static JsonObjectBuilder newObjectBuilder(final Iterable<JsonField> jsonFields) { requireNonNull(jsonFields, "The initial JSON fields must not be null!"); final JsonObjectBuilder result = ImmutableJsonObjectBuilder.newInstance(); result.setAll(jsonFields); return result; }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); return JsonFactory.newObjectBuilder() .setAll(subjectsToJson(schemaVersion, thePredicate), predicate) .build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); return JsonFactory.newObjectBuilder() .setAll(resourcesToJson(schemaVersion, thePredicate), predicate) .build(); }
/** * @param jsonFields the json fields to create a new JsonObject from. * @return a null object if {@code jsonFields} is a null json object. Else this returns a new object containing the * given {code jsonFields}. */ public static JsonObject newObject(final Iterable<JsonField> jsonFields) { if (jsonFields instanceof JsonObject && ((JsonObject) jsonFields).isNull()) { return JsonFactory.nullObject(); } else { return JsonFactory.newObjectBuilder() .setAll(jsonFields) .build(); } }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); return JsonFactory.newObjectBuilder() // .set(JSON_SCHEMA_VERSION, schemaVersion.toInt(), predicate) // .setAll(stream() // .map(aclEntry -> aclEntry.toJson(schemaVersion, thePredicate)) // .collect(JsonCollectors.objectsToObject()), predicate) // .build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); return JsonFactory.newObjectBuilder() // .set(JSON_SCHEMA_VERSION, schemaVersion.toInt(), predicate) // .setAll(stream() // .map(aclEntry -> aclEntry.toJson(schemaVersion, thePredicate)) // .collect(JsonCollectors.objectsToObject()), predicate) // .build(); }
@Override public CompletionStage<JsonObject> get() { final JsonObjectBuilder overallStatusBuilder = JsonFactory.newObjectBuilder(); overallStatusBuilder.setAll(Status.provideStaticStatus()); // append roles statuses to static status return clusterStatusHealthHelper.retrieveOverallRolesStatus() .thenApply(Status.provideStaticStatus()::setAll); } }
@Override public JsonObject toJson(final DittoHeaders specificHeaders) { final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); if (!getTopicPath().equals(ProtocolFactory.emptyTopicPath())) { jsonObjectBuilder.set(JsonFields.TOPIC, getTopicPath().getPath()); } return jsonObjectBuilder .set(JsonFields.HEADERS, specificHeaders.toJson()) .setAll(getPayload().toJson()) .build(); }
@Override protected void appendPayload(final JsonObjectBuilder jsonObjectBuilder, final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { super.appendPayload(jsonObjectBuilder, schemaVersion, predicate); jsonObjectBuilder.remove(MessageCommand.JsonFields.JSON_THING_ID); final JsonObject superBuild = jsonObjectBuilder.build(); jsonObjectBuilder.removeAll(); jsonObjectBuilder.set(MessageCommand.JsonFields.JSON_THING_ID, getThingId()); jsonObjectBuilder.set(JSON_FEATURE_ID, getFeatureId()); jsonObjectBuilder.setAll(superBuild); }
@Override public JsonObject toJson(final DittoHeaders specificHeaders) { final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); if (!getTopicPath().equals(ProtocolFactory.emptyTopicPath())) { jsonObjectBuilder.set(JsonFields.TOPIC, getTopicPath().getPath()); } return jsonObjectBuilder .set(JsonFields.HEADERS, specificHeaders.toJson()) .setAll(getPayload().toJson()) .build(); }
@Override protected void appendPayload(final JsonObjectBuilder jsonObjectBuilder, final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { super.appendPayload(jsonObjectBuilder, schemaVersion, predicate); jsonObjectBuilder.remove(MessageCommand.JsonFields.JSON_THING_ID); final JsonObject superBuild = jsonObjectBuilder.build(); jsonObjectBuilder.removeAll(); jsonObjectBuilder.set(MessageCommand.JsonFields.JSON_THING_ID, getThingId()); jsonObjectBuilder.set(JSON_FEATURE_ID, getFeatureId()); jsonObjectBuilder.setAll(superBuild); }
@Override protected void appendPayload(final JsonObjectBuilder jsonObjectBuilder, final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { super.appendPayload(jsonObjectBuilder, schemaVersion, predicate); jsonObjectBuilder.remove(MessageCommand.JsonFields.JSON_THING_ID); final JsonObject superBuild = jsonObjectBuilder.build(); jsonObjectBuilder.removeAll(); jsonObjectBuilder.set(MessageCommand.JsonFields.JSON_THING_ID, getThingId()); jsonObjectBuilder.set(JSON_FEATURE_ID, getFeatureId()); jsonObjectBuilder.setAll(superBuild); }
@Override protected void appendPayload(final JsonObjectBuilder jsonObjectBuilder, final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { super.appendPayload(jsonObjectBuilder, schemaVersion, predicate); jsonObjectBuilder.remove(MessageCommand.JsonFields.JSON_THING_ID); final JsonObject superBuild = jsonObjectBuilder.build(); jsonObjectBuilder.removeAll(); jsonObjectBuilder.set(MessageCommand.JsonFields.JSON_THING_ID, getThingId()); jsonObjectBuilder.set(JSON_FEATURE_ID, getFeatureId()); jsonObjectBuilder.setAll(superBuild); }