@Override public RetrieveFeatureDefinitionResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, definition, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveFeatureDefinitionResponse that = (RetrieveFeatureDefinitionResponse) o; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(featureId, that.featureId) && Objects.equals(definition, that.definition) && super.equals(o); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} 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. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the parsed {@code jsonString} did not contain any of * the required fields * <ul> * <li>{@link ThingQueryCommandResponse.JsonFields#JSON_THING_ID},</li> * <li>{@link #JSON_FEATURE_ID} or</li> * <li>{@link #JSON_DEFINITION}.</li> * </ul> * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureDefinitionResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public RetrieveFeatureDefinitionResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, featureId, entity.asArray(), getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} command. * * @param thingId the Thing ID of the retrieved Feature Definition. * @param featureId the identifier of the Feature whose Definition was retrieved. * @param definition the retrieved FeatureDefinition. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if {@code thingId} did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveFeatureDefinitionResponse of(final String thingId, final String featureId, final FeatureDefinition definition, final DittoHeaders dittoHeaders) { checkNotNull(definition, "Definition"); return new RetrieveFeatureDefinitionResponse(thingId, featureId, definition.toJson(), dittoHeaders); }
@Override public RetrieveFeatureDefinitionResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, featureId, entity.asArray(), getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} command. * * @param thingId the Thing ID of the retrieved Feature Definition. * @param featureId the identifier of the Feature whose Definition was retrieved. * @param definition the retrieved FeatureDefinition. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if {@code thingId} did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveFeatureDefinitionResponse of(final String thingId, final String featureId, final FeatureDefinition definition, final DittoHeaders dittoHeaders) { checkNotNull(definition, "Definition"); return new RetrieveFeatureDefinitionResponse(thingId, featureId, definition.toJson(), dittoHeaders); }
@Override public RetrieveFeatureDefinitionResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, definition, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveFeatureDefinitionResponse that = (RetrieveFeatureDefinitionResponse) o; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(featureId, that.featureId) && Objects.equals(definition, that.definition) && super.equals(o); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} 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. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the parsed {@code jsonString} did not contain any of * the required fields * <ul> * <li>{@link ThingQueryCommandResponse.JsonFields#JSON_THING_ID},</li> * <li>{@link #JSON_FEATURE_ID} or</li> * <li>{@link #JSON_DEFINITION}.</li> * </ul> * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureDefinitionResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} command. * * @param thingId the Thing ID of the retrieved Feature Definition. * @param featureId the identifier of the Feature whose Definition was retrieved. * @param definitionJsonArray the retrieved FeatureDefinition JSON array. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if {@code thingId} did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveFeatureDefinitionResponse of(final String thingId, final String featureId, final JsonArray definitionJsonArray, final DittoHeaders dittoHeaders) { return of(thingId, featureId, FeatureDefinition.fromJson(definitionJsonArray), dittoHeaders); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} command. * * @param thingId the Thing ID of the retrieved Feature Definition. * @param featureId the identifier of the Feature whose Definition was retrieved. * @param definitionJsonArray the retrieved FeatureDefinition JSON array. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if {@code thingId} did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveFeatureDefinitionResponse of(final String thingId, final String featureId, final JsonArray definitionJsonArray, final DittoHeaders dittoHeaders) { return of(thingId, featureId, FeatureDefinition.fromJson(definitionJsonArray), dittoHeaders); }
private Result getFeatureDefinition(final Feature feature, final String thingId, final RetrieveFeatureDefinition command, @Nullable final Thing thing) { final String featureId = feature.getId(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return feature.getDefinition() .map(featureDefinition -> RetrieveFeatureDefinitionResponse.of(thingId, featureId, featureDefinition, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDefinitionNotFound(thingId, featureId, dittoHeaders))); }
private Result getFeatureDefinition(final Feature feature, final String thingId, final RetrieveFeatureDefinition command, @Nullable final Thing thing) { final String featureId = feature.getId(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return feature.getDefinition() .map(featureDefinition -> RetrieveFeatureDefinitionResponse.of(thingId, featureId, featureDefinition, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDefinitionNotFound(thingId, featureId, dittoHeaders))); }
@Override public RetrieveFeatureDefinitionResponse retrieved(final FeatureDefinition featureProperties) { return RetrieveFeatureDefinitionResponse.of(command.getThingId(), command.getFeatureId(), featureProperties, command.getDittoHeaders()); }
@Override public RetrieveFeatureDefinitionResponse retrieved(final FeatureDefinition featureProperties) { return RetrieveFeatureDefinitionResponse.of(command.getThingId(), command.getFeatureId(), featureProperties, command.getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} 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. * @throws org.eclipse.ditto.json.JsonMissingFieldException if {@code jsonObject} did not contain any of * the required fields * <ul> * <li>{@link ThingQueryCommandResponse.JsonFields#JSON_THING_ID},</li> * <li>{@link #JSON_FEATURE_ID} or</li> * <li>{@link #JSON_DEFINITION}.</li> * </ul> * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureDefinitionResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveFeatureDefinitionResponse>(TYPE, jsonObject) .deserialize(statusCode -> { final String extractedThingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); final JsonArray extractedFeatureDefinition = jsonObject.getValueOrThrow(JSON_DEFINITION); return of(extractedThingId, extractedFeatureId, extractedFeatureDefinition, dittoHeaders); }); }
/** * Creates a response to a {@link RetrieveFeatureDefinition} 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. * @throws org.eclipse.ditto.json.JsonMissingFieldException if {@code jsonObject} did not contain any of * the required fields * <ul> * <li>{@link ThingQueryCommandResponse.JsonFields#JSON_THING_ID},</li> * <li>{@link #JSON_FEATURE_ID} or</li> * <li>{@link #JSON_DEFINITION}.</li> * </ul> * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to * {@link org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureDefinitionResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveFeatureDefinitionResponse>(TYPE, jsonObject) .deserialize(statusCode -> { final String extractedThingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); final JsonArray extractedFeatureDefinition = jsonObject.getValueOrThrow(JSON_DEFINITION); return of(extractedThingId, extractedFeatureId, extractedFeatureDefinition, dittoHeaders); }); }
.of(thingIdFrom(adaptable), featureIdFrom(adaptable), featureDefinitionFrom(adaptable), dittoHeadersFrom(adaptable)));
.of(thingIdFrom(adaptable), featureIdFrom(adaptable), featureDefinitionFrom(adaptable), dittoHeadersFrom(adaptable)));