@Override public RetrieveFeaturePropertiesResponse setDittoHeaders(final DittoHeaders dittoHeaders) { 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 featureProperties the retrieved FeatureProperties. * @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, final FeatureProperties featureProperties, final DittoHeaders dittoHeaders) { return new RetrieveFeaturePropertiesResponse(thingId, featureId, featureProperties, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveFeaturePropertiesResponse that = (RetrieveFeaturePropertiesResponse) o; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(featureId, that.featureId) && Objects.equals(featureProperties, that.featureProperties) && super.equals(o); }
@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 from a JSON string. * * @param jsonString the JSON string of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. */ public static RetrieveFeaturePropertiesResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@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 from a JSON string. * * @param jsonString the JSON string of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. */ public static RetrieveFeaturePropertiesResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public RetrieveFeaturePropertiesResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, featureProperties, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveFeaturePropertiesResponse that = (RetrieveFeaturePropertiesResponse) o; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(featureId, that.featureId) && Objects.equals(featureProperties, that.featureProperties) && super.equals(o); }
/** * 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 featureProperties the retrieved FeatureProperties. * @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, final FeatureProperties featureProperties, final DittoHeaders dittoHeaders) { return new RetrieveFeaturePropertiesResponse(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))); }
/** * 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)));