@Override public FeatureProperties build() { final JsonObject featurePropertiesJsonObject = jsonObjectBuilder.build(); return ImmutableFeatureProperties.of(featurePropertiesJsonObject); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { final List<JsonField> fields = mapping.entrySet().stream().map(e -> JsonFactory.newField(JsonFactory.newKey(e.getKey()), JsonFactory.newValue(e.getValue()))).collect(Collectors.toList()); return JsonFactory.newObjectBuilder(fields).build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { final List<JsonField> fields = mapping.entrySet().stream().map(e -> JsonFactory.newField(JsonFactory.newKey(e.getKey()), JsonFactory.newValue(e.getValue()))).collect(Collectors.toList()); return JsonFactory.newObjectBuilder(fields).build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); jsonObjectBuilder.set(JsonFields.INPUT, input, predicate); jsonObjectBuilder.set(JsonFields.FILTERS, filters.stream() .map(JsonFactory::newValue) .collect(JsonCollectors.valuesToArray()), predicate.and(Objects::nonNull)); return jsonObjectBuilder.build(); }
@Override public JsonObject toJson(final JsonPointer pointer) { final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); for (final Permission permission : Permission.values()) { final JsonKey permissionJsonKey = permission.toJsonKey(); if (Objects.equals(permissionJsonKey, pointer)) { jsonObjectBuilder.set(permissionJsonKey, JsonFactory.newValue(values.contains(permission))); } } return jsonObjectBuilder.build(); }
@Override public JsonObject buildJsonView(final ResourceKey resourceKey, final Iterable<JsonField> jsonFields, final AuthorizationContext authorizationContext, final Permissions permissions) { return hasUnrestrictedPermissions(resourceKey, authorizationContext, permissions) ? JsonFactory.newObjectBuilder(jsonFields).build() : JsonFactory.newObject(); } }
@Override public JsonObject toJson() { final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); jsonObjectBuilder.set(level.toString(), message); return jsonObjectBuilder.build(); }
@Override public JsonObject toJson() { return JsonFactory.newObjectBuilder() .set(JsonFields.CORRELATION_ID, correlationId) .set(JsonFields.PAYLOAD, payload) .build(); }
@Override protected void appendPayload(final JsonObjectBuilder jsonObjectBuilder, final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); jsonObjectBuilder.set(JSON_POLICY_ENTRIES, StreamSupport.stream(policyEntries.spliterator(), false) .map(entry -> JsonFactory.newObjectBuilder().set(entry.getLabel().getJsonFieldDefinition(), entry.toJson(schemaVersion, thePredicate), predicate).build()) .collect(JsonCollectors.objectsToObject()), predicate); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { final Predicate<JsonField> extendedPredicate = schemaVersion.and(predicate); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder() .set(JsonFields.TYPE, getType().toString(), extendedPredicate); getDetails().ifPresent(d -> jsonObjectBuilder.set(JsonFields.DETAILS, d, extendedPredicate)); return jsonObjectBuilder.build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder() // TYPE is included unconditionally .set(Event.JsonFields.TYPE, type) .set(Event.JsonFields.TIMESTAMP, getTimestamp().map(Instant::toString).orElse(null), predicate); appendPayloadAndBuild(jsonObjectBuilder, schemaVersion, thePredicate); return jsonObjectBuilder.build(); }
/** * {@inheritDoc} */ @Override public JsonValue toJson() { return JsonFactory.newObjectBuilder() .set(JsonFields.ELEMENT_ID, elementId) .set(JsonFields.STATUS, status.name()) .build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); // TYPE is included unconditionally jsonObjectBuilder.set(Event.JsonFields.TYPE, type); getTimestamp().ifPresent(timestampPresent -> jsonObjectBuilder.set(Event.JsonFields.TIMESTAMP, timestampPresent.toString(), predicate)); jsonObjectBuilder.set(JsonFields.CONNECTION_ID, connectionId); appendPayloadAndBuild(jsonObjectBuilder, schemaVersion, thePredicate); return jsonObjectBuilder.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 Predicate<JsonField> predicate) { final JsonSchemaVersion jsonSchemaVersion = JsonSchemaVersion.V_1; return JsonFactory.newObjectBuilder() .set(SCHEMA_VERSION_JSON_FIELD, jsonSchemaVersion.toInt(), predicate) .set(NAMESPACE_JSON_FIELD, namespace, predicate) .set(COUNT_JSON_FIELD, count, predicate) .build(); }
@Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); return JsonFactory.newObjectBuilder() .set(JsonFields.JSON_SCHEMA_VERSION, schemaVersion.toInt(), predicate) .set(JsonFields.AUTH_SUBJECTS, authorizedSubjectsToJson(), predicate) .build(); }
@Override public JsonObject toJson() { return JsonFactory.newObjectBuilder() .set(JsonFields.ENTITY_ID, entityId) .set(JsonFields.POLICY_ID, policyTag.getId()) .set(JsonFields.POLICY_REV, policyTag.getRevision()) .build(); }
@Override public JsonObject toJson() { final JsonObjectBuilder builder = JsonFactory.newObjectBuilder() .set(JsonFields.OPERATION, operation.toString()) .set(JsonFields.PATH, path.toString()); if (null != value) { builder.set(JsonFields.VALUE, value); } return builder.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); }
private static Thing createThingForPost(final String jsonString) { final JsonObject inputJson = wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); if (inputJson.contains(Thing.JsonFields.ID.getPointer())) { throw ThingIdNotExplicitlySettableException.newBuilder(true).build(); } final String thingId = ThingBuilder.generateRandomThingId(); final JsonObjectBuilder outputJsonBuilder = inputJson.toBuilder(); outputJsonBuilder.set(Thing.JsonFields.ID.getPointer(), thingId); return ThingsModelFactory.newThingBuilder(outputJsonBuilder.build()) .setId(thingId) .build(); }