@Override public SudoRetrieveThingResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thing, dittoHeaders); }
@Override public SudoRetrieveThingResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thing, dittoHeaders); }
@Override public SudoRetrieveThingResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(entity.asObject(), getDittoHeaders()); }
@Override public SudoRetrieveThingResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(entity.asObject(), getDittoHeaders()); }
/** * Creates a new {@code SudoRetrieveThingResponse} from a JSON object. * * @param jsonObject the JSON object of which a new SudoRetrieveThingResponse instance is to be created. * @param dittoHeaders the optional command headers of the request. * @return the {@code SudoRetrieveThingResponse} which was created from the given JSON object. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * 'SudoRetrieveThingResponse' format. */ public static SudoRetrieveThingResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<SudoRetrieveThingResponse>(TYPE, jsonObject) .deserialize(statusCode -> { final JsonObject extractedThing = jsonObject.getValueOrThrow(JSON_THING); return of(extractedThing, dittoHeaders); }); }
/** * Creates a new {@code SudoRetrieveThingResponse} from a JSON object. * * @param jsonObject the JSON object of which a new SudoRetrieveThingResponse instance is to be created. * @param dittoHeaders the optional command headers of the request. * @return the {@code SudoRetrieveThingResponse} which was created from the given JSON object. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * 'SudoRetrieveThingResponse' format. */ public static SudoRetrieveThingResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<SudoRetrieveThingResponse>(TYPE, jsonObject) .deserialize(statusCode -> { final JsonObject extractedThing = jsonObject.getValueOrThrow(JSON_THING); return of(extractedThing, dittoHeaders); }); }
@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); }