@Override public SudoRetrieveThingsResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingsPlainJson, dittoHeaders); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param thingsPlainJson the retrieved Things. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final String thingsPlainJson, final DittoHeaders dittoHeaders) { return new SudoRetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson, dittoHeaders); }
/** * Returns the {@code Thing}s. * * @return the Things. */ public List<Thing> getThings() { return getThingStream(lazyLoadThingsJsonArray()).collect(Collectors.toList()); }
@Override public SudoRetrieveThingsResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(entity.asArray(), getDittoHeaders()); }
@Override public JsonValue getEntity(final JsonSchemaVersion schemaVersion) { return lazyLoadThingsJsonArray(); }
@SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "pmd:SimplifyConditional"}) @Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SudoRetrieveThingsResponse that = (SudoRetrieveThingsResponse) o; return that.canEqual(this) && Objects.equals(things, that.things) && Objects.equals(thingsPlainJson, that.thingsPlainJson) && super.equals(that); }
/** * Creates a new {@code SudoRetrieveThingsResponse} from a JSON string. * * @param jsonString the JSON string of which a new SudoRetrieveThingsResponse instance is to be created. * @param dittoHeaders the optional command headers of the request. * @return the {@code SudoRetrieveThingsResponse} which was created from the given JSON string. * @throws NullPointerException if {@code dittoHeaders} is {@code null}. * @throws DittoJsonException if the passed in {@code jsonString} was {@code null}, empty or not in the expected * 'SudoRetrieveThingsResponse' format. */ public static SudoRetrieveThingsResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { final JsonObject jsonObject = DittoJsonException.wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); return fromJson(jsonObject, dittoHeaders); }
@Override public SudoRetrieveThingsResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(entity.asArray(), getDittoHeaders()); }
@Override public JsonValue getEntity(final JsonSchemaVersion schemaVersion) { return lazyLoadThingsJsonArray(); }
@SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "pmd:SimplifyConditional"}) @Override public boolean equals(@Nullable final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SudoRetrieveThingsResponse that = (SudoRetrieveThingsResponse) o; return that.canEqual(this) && Objects.equals(things, that.things) && Objects.equals(thingsPlainJson, that.thingsPlainJson) && super.equals(that); }
/** * Creates a new {@code SudoRetrieveThingsResponse} from a JSON string. * * @param jsonString the JSON string of which a new SudoRetrieveThingsResponse instance is to be created. * @param dittoHeaders the optional command headers of the request. * @return the {@code SudoRetrieveThingsResponse} which was created from the given JSON string. * @throws NullPointerException if {@code dittoHeaders} is {@code null}. * @throws DittoJsonException if the passed in {@code jsonString} was {@code null}, empty or not in the expected * 'SudoRetrieveThingsResponse' format. */ public static SudoRetrieveThingsResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders) { final JsonObject jsonObject = DittoJsonException.wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); return fromJson(jsonObject, dittoHeaders); }
@Override public SudoRetrieveThingsResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingsPlainJson, dittoHeaders); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param thingsPlainJson the retrieved Things. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final String thingsPlainJson, final DittoHeaders dittoHeaders) { return new SudoRetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson, dittoHeaders); }
/** * Returns the {@code Thing}s. * * @return the Things. */ public List<Thing> getThings() { return getThingStream(lazyLoadThingsJsonArray()).collect(Collectors.toList()); }
private Function<List<PlainJson>, CommandResponse<?>> supplySudoRetrieveThingsResponse( final DittoHeaders dittoHeaders) { return plainJsonThings -> SudoRetrieveThingsResponse.of(plainJsonThings.stream() .map(PlainJson::getJson) .collect(Collectors.toList()), dittoHeaders); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param things the retrieved Things. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final JsonArray things, final DittoHeaders dittoHeaders) { return new SudoRetrieveThingsResponse(HttpStatusCode.OK, things, things.toString(), dittoHeaders); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param things the retrieved Things. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final JsonArray things, final DittoHeaders dittoHeaders) { return new SudoRetrieveThingsResponse(HttpStatusCode.OK, things, things.toString(), dittoHeaders); }
/** * Creates a response to a {@link SudoRetrieveThingsResponse} command. * * @param thingsPlainJson the retrieved Things. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final List<String> thingsPlainJson, final DittoHeaders dittoHeaders) { return new SudoRetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson.stream() .collect(Collectors.joining(",", "[", "]")), dittoHeaders); }
/** * Creates a response to a {@link SudoRetrieveThingsResponse} command. * * @param thingsPlainJson the retrieved Things. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final List<String> thingsPlainJson, final DittoHeaders dittoHeaders) { return new SudoRetrieveThingsResponse(HttpStatusCode.OK, null, thingsPlainJson.stream() .collect(Collectors.joining(",", "[", "]")), dittoHeaders); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param things the Things. * @param predicate the predicate to apply to the things when transforming to JSON. * @param dittoHeaders the command headers of the request. * @return a new SudoRetrieveThingsResponse object. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThingsResponse of(final List<Thing> things, final Predicate<JsonField> predicate, final DittoHeaders dittoHeaders) { final JsonArray thingsArray = checkNotNull(things, "Things").stream() .map(thing -> thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), predicate)) .collect(JsonCollectors.valuesToArray()); return new SudoRetrieveThingsResponse(HttpStatusCode.OK, thingsArray, thingsArray.toString(), dittoHeaders); }