@Override public RetrieveThingsResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingsPlainJson, namespace, dittoHeaders); }
@Override public RetrieveThingsResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(entity.asArray(), namespace, getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveThings} command. * * @param thingsPlainJson the retrieved Things. * @param namespace the namespace of this search request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final String thingsPlainJson, @Nullable final String namespace, final DittoHeaders dittoHeaders) { return new RetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson, namespace, dittoHeaders); }
final QueryThingsResponse theQueryThingsResponse = QueryThingsResponse.of(SearchResult.newBuilder() .addAll(rtr.getEntity(rtr.getImplementedSchemaVersion()).asArray()) .nextPageOffset(queryThingsResponse.getSearchResult().getNextPageOffset()) .build(), rtr.getDittoHeaders() ); originatingSender.tell(theQueryThingsResponse, getSelf());
/** * Creates a response to a {@link RetrieveThings} command. * * @param things the retrieved Things. * @param fieldSelector the JsonFieldSelector to apply to the passed things when transforming to JSON. * @param predicate the predicate to apply to the things when transforming to JSON. * @param namespace the namespace of this retrieve things request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final List<Thing> things, @Nullable final JsonFieldSelector fieldSelector, @Nullable final Predicate<JsonField> predicate, @Nullable final String namespace, final DittoHeaders dittoHeaders) { final JsonArray thingsArray = checkNotNull(things, PROPERTY_NAME_THINGS).stream() .map(thing -> getJsonFields(fieldSelector, predicate, dittoHeaders, thing)) .collect(JsonCollectors.valuesToArray()); return new RetrieveThingsResponse(HttpStatusCode.OK, thingsArray, thingsArray.toString(), namespace, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveThingsResponse that = (RetrieveThingsResponse) o; return that.canEqual(this) && Objects.equals(things, that.things) && Objects.equals(thingsPlainJson, that.thingsPlainJson) && Objects.equals(namespace, that.namespace) && super.equals(o); }
/** * Creates a response to a {@link RetrieveThings} command from a JSON string. * * @param jsonString the JSON string of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. */ public static RetrieveThingsResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { final JsonObject jsonObject = DittoJsonException.wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); return fromJson(jsonObject, dittoHeaders); }
/** * Creates a response to a {@link RetrieveThings} command. * * @param things the retrieved Things. * @param fieldSelector the JsonFieldSelector to apply to the passed things when transforming to JSON. * @param predicate the predicate to apply to the things when transforming to JSON. * @param namespace the namespace of this retrieve things request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final List<Thing> things, @Nullable final JsonFieldSelector fieldSelector, @Nullable final Predicate<JsonField> predicate, @Nullable final String namespace, final DittoHeaders dittoHeaders) { final JsonArray thingsArray = checkNotNull(things, PROPERTY_NAME_THINGS).stream() .map(thing -> getJsonFields(fieldSelector, predicate, dittoHeaders, thing)) .collect(JsonCollectors.valuesToArray()); return new RetrieveThingsResponse(HttpStatusCode.OK, thingsArray, thingsArray.toString(), namespace, dittoHeaders); }
@Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RetrieveThingsResponse that = (RetrieveThingsResponse) o; return that.canEqual(this) && Objects.equals(things, that.things) && Objects.equals(thingsPlainJson, that.thingsPlainJson) && Objects.equals(namespace, that.namespace) && super.equals(o); }
/** * Creates a response to a {@link RetrieveThings} command from a JSON string. * * @param jsonString the JSON string of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. */ public static RetrieveThingsResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { final JsonObject jsonObject = DittoJsonException.wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); return fromJson(jsonObject, dittoHeaders); }
@Override public RetrieveThingsResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingsPlainJson, namespace, dittoHeaders); }
@Override public RetrieveThingsResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(entity.asArray(), namespace, getDittoHeaders()); }
/** * Creates a response to a {@link RetrieveThings} command. * * @param thingsPlainJson the retrieved Things. * @param namespace the namespace of this search request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final String thingsPlainJson, @Nullable final String namespace, final DittoHeaders dittoHeaders) { return new RetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson, namespace, dittoHeaders); }
private Function<List<PlainJson>, CommandResponse<?>> supplyRetrieveThingsResponse( final DittoHeaders dittoHeaders, @Nullable final String namespace) { return plainJsonThings -> RetrieveThingsResponse.of(plainJsonThings.stream() .map(PlainJson::getJson) .collect(Collectors.toList()), namespace, dittoHeaders); }
/** * Creates a response to a {@link RetrieveThings} command. * * @param things the retrieved Things. * @param namespace the namespace of this search request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final JsonArray things, @Nullable final String namespace, final DittoHeaders dittoHeaders) { return new RetrieveThingsResponse(HttpStatusCode.OK, things, things.toString(), namespace, dittoHeaders); }
@Nonnull @Override public RetrieveThingsResponse retrieved(final List<Thing> things, final Predicate<JsonField> predicate) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); String namespace = command.getNamespace().orElse(null); final Function<JsonFieldSelector, RetrieveThingsResponse> fieldSelectorToResponse = fieldSelector -> RetrieveThingsResponse.of(things, fieldSelector, predicate, namespace, dittoHeaders); return command.getSelectedFields() .map(fieldSelectorToResponse) .orElse(RetrieveThingsResponse.of(things, predicate, namespace, dittoHeaders)); }
/** * Creates a response to a {@link RetrieveThings} command. * * @param things the retrieved Things. * @param namespace the namespace of this search request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final JsonArray things, @Nullable final String namespace, final DittoHeaders dittoHeaders) { return new RetrieveThingsResponse(HttpStatusCode.OK, things, things.toString(), namespace, dittoHeaders); }
@Nonnull @Override public RetrieveThingsResponse retrieved(final List<Thing> things, final Predicate<JsonField> predicate) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); String namespace = command.getNamespace().orElse(null); final Function<JsonFieldSelector, RetrieveThingsResponse> fieldSelectorToResponse = fieldSelector -> RetrieveThingsResponse.of(things, fieldSelector, predicate, namespace, dittoHeaders); return command.getSelectedFields() .map(fieldSelectorToResponse) .orElse(RetrieveThingsResponse.of(things, predicate, namespace, dittoHeaders)); }
/** * Creates a response to a {@link RetrieveThings} command. * * @param thingsPlainJson the retrieved Things. * @param namespace the namespace of this search request * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static RetrieveThingsResponse of(final List<String> thingsPlainJson, @Nullable final String namespace, final DittoHeaders dittoHeaders) { return new RetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson.stream() .collect(Collectors.joining(",", "[", "]")), namespace, dittoHeaders); }
adaptable -> RetrieveThingsResponse.of(thingsArrayFrom(adaptable), namespaceFrom(adaptable), dittoHeadersFrom(adaptable)));