@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final SudoRetrieveThing command) { final Thing theThing = getThingOrThrow(thing); final JsonSchemaVersion jsonSchemaVersion = determineSchemaVersion(command, theThing); final JsonObject thingJson = command.getSelectedFields() .map(selectedFields -> theThing.toJson(jsonSchemaVersion, selectedFields, FieldType.regularOrSpecial())) .orElseGet(() -> theThing.toJson(jsonSchemaVersion, FieldType.regularOrSpecial())); return ResultFactory.newQueryResult(command, thing, SudoRetrieveThingResponse.of(thingJson, command.getDittoHeaders()), this); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final SudoRetrieveThing command) { final Thing theThing = getThingOrThrow(thing); final JsonSchemaVersion jsonSchemaVersion = determineSchemaVersion(command, theThing); final JsonObject thingJson = command.getSelectedFields() .map(selectedFields -> theThing.toJson(jsonSchemaVersion, selectedFields, FieldType.regularOrSpecial())) .orElseGet(() -> theThing.toJson(jsonSchemaVersion, FieldType.regularOrSpecial())); return ResultFactory.newQueryResult(command, thing, SudoRetrieveThingResponse.of(thingJson, command.getDittoHeaders()), this); }