@Override protected DittoRuntimeExceptionBuilder createExceptionBuilder(@Nullable final CharSequence id) { return PolicyIdInvalidException.newBuilder(id); }
@Override protected PolicyIdInvalidException doBuild(final DittoHeaders dittoHeaders, @Nullable final String message, @Nullable final String description, @Nullable final Throwable cause, @Nullable final URI href) { return new PolicyIdInvalidException(dittoHeaders, message, description, cause, href); }
/** * Constructs a new {@code PolicyIdInvalidException} object with the exception message extracted from the * given JSON object. * * @param jsonObject the JSON to read the {@link JsonFields#MESSAGE} field from. * @param dittoHeaders the headers of the command which resulted in this exception. * @return the new PolicyIdInvalidException. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link JsonFields#MESSAGE} field. */ public static PolicyIdInvalidException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new Builder() .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DEFAULT_DESCRIPTION)) .href(readHRef(jsonObject).orElse(null)) .build(); }
/** * Returns a Command for creating a new Policy which is passed as argument. * * @param policy the Policy to create. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws PolicyIdInvalidException if the {@link Policy}'s ID is not valid. */ public static CreatePolicy of(final Policy policy, final DittoHeaders dittoHeaders) { Objects.requireNonNull(policy, "The Policy must not be null!"); if (!policy.getId().isPresent()) { throw PolicyIdInvalidException.newBuilder("") .message("Policy ID must be present in 'CreatePolicy' payload") .dittoHeaders(dittoHeaders) .build(); } return new CreatePolicy(policy, dittoHeaders); }
/** * Returns a Command for creating a new Policy which is passed as argument. * * @param policy the Policy to create. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws PolicyIdInvalidException if the {@link Policy}'s ID is not valid. */ public static CreatePolicy of(final Policy policy, final DittoHeaders dittoHeaders) { Objects.requireNonNull(policy, "The Policy must not be null!"); if (!policy.getId().isPresent()) { throw PolicyIdInvalidException.newBuilder("") .message("Policy ID must be present in 'CreatePolicy' payload") .dittoHeaders(dittoHeaders) .build(); } return new CreatePolicy(policy, dittoHeaders); }