@Override public RetrieveAttributesResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, attributes, dittoHeaders); }
/** * Creates a response to a {@link RetrieveAttributes} command. * * @param thingId the Thing ID of the retrieved attributes. * @param attributes the retrieved Attributes. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveAttributesResponse of(final String thingId, final Attributes attributes, final DittoHeaders dittoHeaders) { return new RetrieveAttributesResponse(thingId, attributes, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveAttributesResponse that = (RetrieveAttributesResponse) o; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(attributes, that.attributes) && super.equals(o); }
@Override public RetrieveAttributesResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, entity.asObject(), getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveAttributes} 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 RetrieveAttributesResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public RetrieveAttributesResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, entity.asObject(), getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveAttributes} 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 RetrieveAttributesResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public RetrieveAttributesResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, attributes, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveAttributesResponse that = (RetrieveAttributesResponse) o; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(attributes, that.attributes) && super.equals(o); }
/** * Creates a response to a {@link RetrieveAttributes} command. * * @param thingId the Thing ID of the retrieved attributes. * @param attributes the retrieved Attributes. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveAttributesResponse of(final String thingId, final Attributes attributes, final DittoHeaders dittoHeaders) { return new RetrieveAttributesResponse(thingId, attributes, dittoHeaders); }
@Nonnull @Override public RetrieveAttributesResponse retrieved(final Attributes attributes) { return RetrieveAttributesResponse.of(command.getThingId(), attributes, command.getDittoHeaders()); }
@Nonnull @Override public RetrieveAttributesResponse retrieved(final Attributes attributes) { return RetrieveAttributesResponse.of(command.getThingId(), attributes, command.getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveAttributes} command. * * @param thingId the Thing ID of the retrieved attributes. * @param jsonObject the retrieved Attributes. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveAttributesResponse of(final String thingId, @Nullable final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final Attributes attributes = (null != jsonObject) ? ThingsModelFactory.newAttributes(jsonObject) : ThingsModelFactory.nullAttributes(); return of(thingId, attributes, dittoHeaders); }
/** * Creates a response to a {@link RetrieveAttributes} command. * * @param thingId the Thing ID of the retrieved attributes. * @param jsonObject the retrieved Attributes. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveAttributesResponse of(final String thingId, @Nullable final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final Attributes attributes = (null != jsonObject) ? ThingsModelFactory.newAttributes(jsonObject) : ThingsModelFactory.nullAttributes(); return of(thingId, attributes, dittoHeaders); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAttributes command) { final String thingId = context.getThingId(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return extractAttributes(thing) .map(attributes -> getAttributesJson(attributes, command)) .map(attributesJson -> RetrieveAttributesResponse.of(thingId, attributesJson, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.attributesNotFound(thingId, dittoHeaders))); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAttributes command) { final String thingId = context.getThingId(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return extractAttributes(thing) .map(attributes -> getAttributesJson(attributes, command)) .map(attributesJson -> RetrieveAttributesResponse.of(thingId, attributesJson, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.attributesNotFound(thingId, dittoHeaders))); }
/** * Creates a response to a {@link RetrieveAttributes} 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 RetrieveAttributesResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveAttributesResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final JsonObject attributesJsonObject = jsonObject.getValueOrThrow(JSON_ATTRIBUTES); final Attributes extractedAttributes = ThingsModelFactory.newAttributes(attributesJsonObject); return of(thingId, extractedAttributes, dittoHeaders); }); }
/** * Creates a response to a {@link RetrieveAttributes} 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 RetrieveAttributesResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveAttributesResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final JsonObject attributesJsonObject = jsonObject.getValueOrThrow(JSON_ATTRIBUTES); final Attributes extractedAttributes = ThingsModelFactory.newAttributes(attributesJsonObject); return of(thingId, extractedAttributes, dittoHeaders); }); }
adaptable -> RetrieveAttributesResponse.of(thingIdFrom(adaptable), attributesFrom(adaptable), dittoHeadersFrom(adaptable)));
adaptable -> RetrieveAttributesResponse.of(thingIdFrom(adaptable), attributesFrom(adaptable), dittoHeadersFrom(adaptable)));