/** * 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); }
/** * 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); }
/** * 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); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param things the 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 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 JsonFieldSelector fieldSelector, final Predicate<JsonField> predicate, final DittoHeaders dittoHeaders) { final JsonArray thingsArray = checkNotNull(things, "Things").stream() .map(thing -> thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), fieldSelector, predicate)) .collect(JsonCollectors.valuesToArray()); return new SudoRetrieveThingsResponse(HttpStatusCode.OK, thingsArray, thingsArray.toString(), dittoHeaders); }
/** * Creates a new instance of {@code SudoRetrieveThingsResponse}. * * @param things the 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 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 JsonFieldSelector fieldSelector, final Predicate<JsonField> predicate, final DittoHeaders dittoHeaders) { final JsonArray thingsArray = checkNotNull(things, "Things").stream() .map(thing -> thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), fieldSelector, predicate)) .collect(JsonCollectors.valuesToArray()); return new SudoRetrieveThingsResponse(HttpStatusCode.OK, thingsArray, thingsArray.toString(), 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); }
/** * Creates a new {@code SudoRetrieveThingsResponse} from a JSON object. * * @param jsonObject the JSON object 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 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 * 'SudoRetrieveThingsResponse' format. */ public static SudoRetrieveThingsResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<SudoRetrieveThingsResponse>(TYPE, jsonObject) .deserialize(statusCode -> { final JsonArray thingsJsonArray = jsonObject.getValue(JSON_THINGS).orElse(null); final String plainJsonString = jsonObject.getValue(JSON_THINGS_PLAIN_JSON) .orElseGet(() -> thingsJsonArray != null ? thingsJsonArray.toString() : null); return new SudoRetrieveThingsResponse(HttpStatusCode.OK, thingsJsonArray, plainJsonString, dittoHeaders); }); }
/** * Creates a new {@code SudoRetrieveThingsResponse} from a JSON object. * * @param jsonObject the JSON object 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 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 * 'SudoRetrieveThingsResponse' format. */ public static SudoRetrieveThingsResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<SudoRetrieveThingsResponse>(TYPE, jsonObject) .deserialize(statusCode -> { final JsonArray thingsJsonArray = jsonObject.getValue(JSON_THINGS).orElse(null); final String plainJsonString = jsonObject.getValue(JSON_THINGS_PLAIN_JSON) .orElseGet(() -> thingsJsonArray != null ? thingsJsonArray.toString() : null); return new SudoRetrieveThingsResponse(HttpStatusCode.OK, thingsJsonArray, plainJsonString, dittoHeaders); }); }