@Override public RetrieveFeaturePropertiesResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, featureProperties, dittoHeaders); }
@Override public RetrieveFeaturePropertiesResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, featureProperties, dittoHeaders); }
@Nonnull @Override public RetrieveFeaturePropertiesResponse retrieved(final FeatureProperties featureProperties) { return RetrieveFeaturePropertiesResponse.of(command.getThingId(), command.getFeatureId(), featureProperties, command.getDittoHeaders()); }
@Nonnull @Override public RetrieveFeaturePropertiesResponse retrieved(final FeatureProperties featureProperties) { return RetrieveFeaturePropertiesResponse.of(command.getThingId(), command.getFeatureId(), featureProperties, command.getDittoHeaders()); }
private Result getFeatureProperties(final Feature feature, final String thingId, final RetrieveFeatureProperties command, @Nullable final Thing thing) { final String featureId = feature.getId(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return feature.getProperties() .map(featureProperties -> RetrieveFeaturePropertiesResponse.of(thingId, featureId, featureProperties, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(thingId, featureId, dittoHeaders))); }
private Result getFeatureProperties(final Feature feature, final String thingId, final RetrieveFeatureProperties command, @Nullable final Thing thing) { final String featureId = feature.getId(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return feature.getProperties() .map(featureProperties -> RetrieveFeaturePropertiesResponse.of(thingId, featureId, featureProperties, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(thingId, featureId, dittoHeaders))); }
@Override public RetrieveFeaturePropertiesResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, featureId, entity.asObject(), getDittoHeaders()); }
@Override public RetrieveFeaturePropertiesResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, featureId, entity.asObject(), getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveFeatureProperties} command. * * @param thingId the Thing ID of the retrieved feature properties. * @param featureId the identifier of the Feature whose Properties were retrieved. * @param jsonObject the retrieved FeatureProperties JSON. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveFeaturePropertiesResponse of(final String thingId, final String featureId, @Nullable final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final FeatureProperties featureProperties; if (jsonObject == null || jsonObject.isNull()) { featureProperties = ThingsModelFactory.nullFeatureProperties(); } else { featureProperties = ThingsModelFactory.newFeatureProperties(jsonObject); } return of(thingId, featureId, featureProperties, dittoHeaders); }
/** * Creates a response to a {@link RetrieveFeatureProperties} command. * * @param thingId the Thing ID of the retrieved feature properties. * @param featureId the identifier of the Feature whose Properties were retrieved. * @param jsonObject the retrieved FeatureProperties JSON. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveFeaturePropertiesResponse of(final String thingId, final String featureId, @Nullable final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final FeatureProperties featureProperties; if (jsonObject == null || jsonObject.isNull()) { featureProperties = ThingsModelFactory.nullFeatureProperties(); } else { featureProperties = ThingsModelFactory.newFeatureProperties(jsonObject); } return of(thingId, featureId, featureProperties, dittoHeaders); }
/** * Creates a response to a {@link RetrieveFeatureProperties} command from a JSON object. * * @param jsonObject the JSON object of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static RetrieveFeaturePropertiesResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveFeaturePropertiesResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); final JsonObject extractedFeatureProperties = jsonObject.getValueOrThrow(JSON_PROPERTIES); return of(thingId, extractedFeatureId, extractedFeatureProperties, dittoHeaders); }); }
/** * Creates a response to a {@link RetrieveFeatureProperties} command from a JSON object. * * @param jsonObject the JSON object of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static RetrieveFeaturePropertiesResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveFeaturePropertiesResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); final JsonObject extractedFeatureProperties = jsonObject.getValueOrThrow(JSON_PROPERTIES); return of(thingId, extractedFeatureId, extractedFeatureProperties, dittoHeaders); }); }
.of(thingIdFrom(adaptable), featureIdFrom(adaptable), featurePropertiesFrom(adaptable), dittoHeadersFrom(adaptable)));
.of(thingIdFrom(adaptable), featureIdFrom(adaptable), featurePropertiesFrom(adaptable), dittoHeadersFrom(adaptable)));