@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))); }