/** * Returns a new immutable {@link PolicyEntry} based on the given JSON object. * * @param label the Label for the PolicyEntry to create. * @param jsonObject the JSON object representation of a PolicyEntry. * @return the new Policy entry. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.model.base.exceptions.DittoJsonException if {@code jsonObject} cannot be parsed. */ public static PolicyEntry newPolicyEntry(final CharSequence label, final JsonObject jsonObject) { return ImmutablePolicyEntry.fromJson(label, jsonObject); }
/** * Returns a new immutable {@link PolicyEntry} based on the given JSON value. * * @param label the Label for the PolicyEntry to create. * @param jsonValue the JSON value representation of a PolicyEntry. * @return the new Policy entry. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code label} is empty. * @throws org.eclipse.ditto.model.base.exceptions.DittoJsonException if {@code jsonObject} cannot be parsed. * @throws PolicyIdInvalidException if the parsed policy ID did not comply to {@link Policy#ID_REGEX}. */ public static PolicyEntry newPolicyEntry(final CharSequence label, final JsonValue jsonValue) { final JsonObject jsonObject = wrapJsonRuntimeException(jsonValue::asObject); return ImmutablePolicyEntry.fromJson(label, jsonObject); }
/** * Returns a new immutable {@link PolicyEntry} based on the given JSON string. * * @param label the Label for the PolicyEntry to create. * @param jsonString the JSON object representation as String of a PolicyEntry. * @return the new Policy entry. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.model.base.exceptions.DittoJsonException if {@code jsonObject} cannot be parsed. */ public static PolicyEntry newPolicyEntry(final CharSequence label, final String jsonString) { final JsonObject jsonObject = wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); return ImmutablePolicyEntry.fromJson(label, jsonObject); }
.build()); return ImmutablePolicyEntry.fromJson(jsonField.getKey(), jsonValue.asObject()); };