private RetrieveAttributeLiveCommandImpl(final RetrieveAttribute command) { super(command); attributePointer = command.getAttributePointer(); }
private RetrieveAttributeLiveCommandImpl(final RetrieveAttribute command) { super(command); attributePointer = command.getAttributePointer(); }
@Override public Optional<JsonValue> determineETagEntity(final RetrieveAttribute command, @Nullable final Thing thing) { return extractAttributes(thing) .flatMap(attributes -> attributes.getValue(command.getAttributePointer())); } }
@Override public Optional<JsonValue> determineETagEntity(final RetrieveAttribute command, @Nullable final Thing thing) { return extractAttributes(thing) .flatMap(attributes -> attributes.getValue(command.getAttributePointer())); } }
private Result getAttributeValueResult(final JsonObject attributes, final String thingId, final RetrieveAttribute command, @Nullable final Thing thing) { final JsonPointer attributePointer = command.getAttributePointer(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return attributes.getValue(attributePointer) .map(value -> RetrieveAttributeResponse.of(thingId, attributePointer, value, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.attributeNotFound(thingId, attributePointer, dittoHeaders))); }
private Result getAttributeValueResult(final JsonObject attributes, final String thingId, final RetrieveAttribute command, @Nullable final Thing thing) { final JsonPointer attributePointer = command.getAttributePointer(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return attributes.getValue(attributePointer) .map(value -> RetrieveAttributeResponse.of(thingId, attributePointer, value, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.attributeNotFound(thingId, attributePointer, dittoHeaders))); }