/** * Builds an instance of {@code RetrieveThings} based on the provided values. * * @return a new instance of {@code RetrieveThings}. */ public RetrieveThings build() { return new RetrieveThings(this); }
/** * Builds an instance of {@code RetrieveThings} based on the provided values. * * @return a new instance of {@code RetrieveThings}. */ public RetrieveThings build() { return new RetrieveThings(this); }
/** * Creates a new {@code RetrieveThings} 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 {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static RetrieveThings fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final String namespace = jsonObject.getValue(JSON_NAMESPACE).orElse(null); final List<String> extractedThingIds = jsonObject.getValueOrThrow(JSON_THING_IDS) .stream() .filter(JsonValue::isString) .map(JsonValue::asString) .collect(Collectors.toList()); final JsonFieldSelector extractedFieldSelector = jsonObject.getValue(JSON_SELECTED_FIELDS) .map(str -> JsonFactory.newFieldSelector(str, JsonFactory.newParseOptionsBuilder() .withoutUrlDecoding() .build())) .orElse(null); return new RetrieveThings(extractedThingIds, extractedFieldSelector, namespace, dittoHeaders); }
/** * Creates a new {@code RetrieveThings} 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 {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static RetrieveThings fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final String namespace = jsonObject.getValue(JSON_NAMESPACE).orElse(null); final List<String> extractedThingIds = jsonObject.getValueOrThrow(JSON_THING_IDS) .stream() .filter(JsonValue::isString) .map(JsonValue::asString) .collect(Collectors.toList()); final JsonFieldSelector extractedFieldSelector = jsonObject.getValue(JSON_SELECTED_FIELDS) .map(str -> JsonFactory.newFieldSelector(str, JsonFactory.newParseOptionsBuilder() .withoutUrlDecoding() .build())) .orElse(null); return new RetrieveThings(extractedThingIds, extractedFieldSelector, namespace, dittoHeaders); }