/** * Returns a Command for retrieving a Feature with the given ID of a Thing. * * @param thingId the ID of a Thing whose Feature to be retrieved by this command. * @param featureId the ID of the a single Feature to be retrieved by this command. * @param dittoHeaders the headers of the command. * @return a Command for retrieving the Feature with the {@code featureId} as its ID. * @throws NullPointerException if any argument but {@code dittoHeaders} is {@code null}. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeature of(final String thingId, final String featureId, final DittoHeaders dittoHeaders) { return of(thingId, featureId, null, dittoHeaders); }
@Override public RetrieveFeature setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, selectedFields, dittoHeaders); }
/** * Returns a Command for retrieving a Feature with the given ID of a Thing. * * @param thingId the ID of a Thing whose Feature to be retrieved by this command. * @param featureId the ID of the a single Feature to be retrieved by this command. * @param dittoHeaders the headers of the command. * @return a Command for retrieving the Feature with the {@code featureId} as its ID. * @throws NullPointerException if any argument but {@code dittoHeaders} is {@code null}. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeature of(final String thingId, final String featureId, final DittoHeaders dittoHeaders) { return of(thingId, featureId, null, dittoHeaders); }
@Override public RetrieveFeature setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, selectedFields, dittoHeaders); }
@Override public RetrieveFeatureLiveCommand setDittoHeaders(final DittoHeaders dittoHeaders) { return of(RetrieveFeature.of(getThingId(), getFeatureId(), getSelectedFields().orElse(null), dittoHeaders)); }
@Override public RetrieveFeatureLiveCommand setDittoHeaders(final DittoHeaders dittoHeaders) { return of(RetrieveFeature.of(getThingId(), getFeatureId(), getSelectedFields().orElse(null), dittoHeaders)); }
/** * Creates a new {@code RetrieveFeature} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @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 * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeature fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<RetrieveFeature>(TYPE, jsonObject).deserialize(() -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommand.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); final JsonFieldSelector extractedFieldSelector = jsonObject.getValue(JSON_SELECTED_FIELDS) .map(str -> JsonFactory.newFieldSelector(str, JsonFactory.newParseOptionsBuilder() .withoutUrlDecoding() .build())) .orElse(null); return of(thingId, extractedFeatureId, extractedFieldSelector, dittoHeaders); }); }
/** * Creates a new {@code RetrieveFeature} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @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 * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeature fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<RetrieveFeature>(TYPE, jsonObject).deserialize(() -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommand.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); final JsonFieldSelector extractedFieldSelector = jsonObject.getValue(JSON_SELECTED_FIELDS) .map(str -> JsonFactory.newFieldSelector(str, JsonFactory.newParseOptionsBuilder() .withoutUrlDecoding() .build())) .orElse(null); return of(thingId, extractedFeatureId, extractedFieldSelector, dittoHeaders); }); }
selectedFieldsFrom(adaptable), dittoHeadersFrom(adaptable))); mappingStrategies.put(RetrieveFeature.TYPE, adaptable -> RetrieveFeature.of(thingIdFrom(adaptable), featureIdFrom(adaptable), selectedFieldsFrom(adaptable), dittoHeadersFrom(adaptable)));
selectedFieldsFrom(adaptable), dittoHeadersFrom(adaptable))); mappingStrategies.put(RetrieveFeature.TYPE, adaptable -> RetrieveFeature.of(thingIdFrom(adaptable), featureIdFrom(adaptable), selectedFieldsFrom(adaptable), dittoHeadersFrom(adaptable)));
fieldsString -> handlePerRequest(ctx, RetrieveFeature.of(thingId, featureId, calculateSelectedFields( fieldsString).orElse(