/** * Sets a link to a resource which provides further information about the exception to be built. * * @param hrefSupplier supplier of the link to be set. * @return this builder to allow method chaining. * @throws NullPointerException if {@code messageSupplier} is {@code null}. */ public DittoRuntimeExceptionBuilder<T> href(final Supplier<URI> hrefSupplier) { checkSupplier(hrefSupplier); return href(hrefSupplier.get()); }
/** * Sets a link to a resource which provides further information about the exception to be built. * * @param hrefSupplier supplier of the link to be set. * @return this builder to allow method chaining. * @throws NullPointerException if {@code messageSupplier} is {@code null}. */ public DittoRuntimeExceptionBuilder<T> href(final Supplier<URI> hrefSupplier) { checkSupplier(hrefSupplier); return href(hrefSupplier.get()); }
private void validateEntityTagMatcher(final String key, @Nullable final CharSequence charSequence) { final String headerValue = String.valueOf(charSequence); if (!EntityTagMatcher.isValid(headerValue)) { final DittoRuntimeExceptionBuilder<DittoHeaderInvalidException> exceptionBuilder = DittoHeaderInvalidException.newInvalidTypeBuilder(key, headerValue, "entity-tag"); try { exceptionBuilder.href(new URI(RFC_7232_SECTION_2_3)); } catch (final URISyntaxException e) { // Do nothing. If this happens, there is no href appended to the exception builder. } throw exceptionBuilder.build(); } }
private void validateEntityTagMatcher(final String key, @Nullable final CharSequence charSequence) { final String headerValue = String.valueOf(charSequence); if (!EntityTagMatcher.isValid(headerValue)) { final DittoRuntimeExceptionBuilder<DittoHeaderInvalidException> exceptionBuilder = DittoHeaderInvalidException.newInvalidTypeBuilder(key, headerValue, "entity-tag"); try { exceptionBuilder.href(new URI(RFC_7232_SECTION_2_3)); } catch (final URISyntaxException e) { // Do nothing. If this happens, there is no href appended to the exception builder. } throw exceptionBuilder.build(); } }
private void validateEntityTag(final String key, @Nullable final CharSequence charSequence) { final String headerValue = String.valueOf(charSequence); if (!EntityTag.isValid(headerValue)) { final DittoRuntimeExceptionBuilder<DittoHeaderInvalidException> exceptionBuilder = DittoHeaderInvalidException.newInvalidTypeBuilder(key, headerValue, "entity-tag"); try { exceptionBuilder.href(new URI(RFC_7232_SECTION_2_3)); } catch (final URISyntaxException e) { // Do nothing. If this happens, there is no href appended to the exception builder. } throw exceptionBuilder.build(); } } }
private void validateEntityTag(final String key, @Nullable final CharSequence charSequence) { final String headerValue = String.valueOf(charSequence); if (!EntityTag.isValid(headerValue)) { final DittoRuntimeExceptionBuilder<DittoHeaderInvalidException> exceptionBuilder = DittoHeaderInvalidException.newInvalidTypeBuilder(key, headerValue, "entity-tag"); try { exceptionBuilder.href(new URI(RFC_7232_SECTION_2_3)); } catch (final URISyntaxException e) { // Do nothing. If this happens, there is no href appended to the exception builder. } throw exceptionBuilder.build(); } } }
/** * Constructs a new {@code ThingIdInvalidException} 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 ThingIdInvalidException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link JsonFields#MESSAGE} field. */ public static ThingIdInvalidException 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(); }
/** * Constructs a new {@code SubjectNotModifiableException} 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 SubjectNotModifiableException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link JsonFields#MESSAGE} field. */ public static SubjectNotModifiableException 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(); }
/** * Constructs a new {@code UnknownSignalException} 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 signal which resulted in this exception. * @return the new UnknownSignalException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link * JsonFields#MESSAGE} field. */ public static UnknownSignalException 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(); }
/** * Constructs a new {@code MessageMappingFailedException} 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 MessageMappingFailedException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link * JsonFields#MESSAGE} field. */ public static MessageMappingFailedException 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(); }
/** * Constructs a new {@code AclInvalidException} 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 AclInvalidException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link JsonFields#MESSAGE} field. */ public static AclInvalidException 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(); }
/** * Constructs a new {@link PolicyInvalidException} object 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 {@link PolicyInvalidException}. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link * JsonFields#MESSAGE} field. */ public static PolicyInvalidException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new Builder() .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DESCRIPTION_TEMPLATE)) .href(readHRef(jsonObject).orElse(null)) .build(); }
/** * Constructs a new {@code AclEntryInvalidException} 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 AclEntryInvalidException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link JsonFields#MESSAGE} field. */ public static AclEntryInvalidException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return newBuilder() .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DEFAULT_DESCRIPTION)) .href(readHRef(jsonObject).orElse(null)) .build(); }
/** * Constructs a new {@code ThingPolicyIdInvalidException} 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 ThingPolicyIdInvalidException. * @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 ThingPolicyIdInvalidException 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(); }
/** * Constructs a new {@code ConnectionUriInvalidException} 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 ConnectionUriInvalidException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the {@link * JsonFields#MESSAGE} field. */ public static ConnectionUriInvalidException 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 mutable builder for this exception. * * @return the builder. */ public DittoRuntimeExceptionBuilder<NamespaceBlockedException> toBuilder() { return new Builder() .dittoHeaders(getDittoHeaders()) .message(getMessage()) .description(getDescription().orElse(DEFAULT_DESCRIPTION)) .cause(getCause()) .href(getHref().orElse(null)); }
/** * Deserialize from a JSON object. * * @param jsonObject the JSON object to deserialize. * @param dittoHeaders the headers. * @return an instance of this class. * @throws NullPointerException if any argument is {@code null}. */ public static ThingTooLargeException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new ThingTooLargeException.Builder() .loadJson(jsonObject) .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DEFAULT_DESCRIPTION)) .href(readHRef(jsonObject).orElse(null)) .build(); }
/** * Deserialize from a JSON object. * * @param jsonObject the JSON object to deserialize. * @param dittoHeaders the headers. * @return an instance of this class. * @throws NullPointerException if any argument is {@code null}. */ public static PolicyTooLargeException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new Builder() .loadJson(jsonObject) .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DEFAULT_DESCRIPTION)) .href(readHRef(jsonObject).orElse(null)) .build(); }
/** * Construct a builder {@code b} such that {@code b.build()} has identical class and fields as {@code this}. * <p> * A subclass should extend this method if it adds another field. * * @return A builder to construct an identical copy of {@code this}. */ public DittoRuntimeExceptionBuilder<? extends DittoRuntimeException> getBuilder() { return getEmptyBuilder() .dittoHeaders(dittoHeaders) .message(getMessage()) .cause(getCause()) .description(description) .href(href); }
/** * Construct a builder {@code b} such that {@code b.build()} has identical class and fields as {@code this}. * <p> * A subclass should extend this method if it adds another field. * * @return A builder to construct an identical copy of {@code this}. */ public DittoRuntimeExceptionBuilder<? extends DittoRuntimeException> getBuilder() { return getEmptyBuilder() .dittoHeaders(dittoHeaders) .message(getMessage()) .cause(getCause()) .description(description) .href(href); }