@Override protected FeatureIdInvalidException doBuild(final DittoHeaders dittoHeaders, @Nullable final String message, @Nullable final String description, @Nullable final Throwable cause, @Nullable final URI href) { return new FeatureIdInvalidException(dittoHeaders, message, description, cause, href); }
/** * Constructs a new {@code FeatureIdInvalidException} 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 FeatureIdInvalidException. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the {@code jsonObject} does not have the * {@link JsonFields#MESSAGE} field. */ public static FeatureIdInvalidException 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(); }
private static void validateMessageFeatureId(final String expectedFeatureId, final Message<?> message, final DittoHeaders dittoHeaders) { final Optional<String> messageFeatureIdOptional = message.getFeatureId(); if (!messageFeatureIdOptional.isPresent()) { final String msgPattern = "The Message did not contain a feature ID at all! Expected was feature ID <{0}>."; throw FeatureIdInvalidException.newBuilder() .message(MessageFormat.format(msgPattern, expectedFeatureId)) .dittoHeaders(dittoHeaders) .build(); } final String messageFeatureId = messageFeatureIdOptional.get(); if (!messageFeatureId.equals(expectedFeatureId)) { final String msgPattern = "The Message contained feature ID <{0}>. Expected was feature ID <{1}>."; throw FeatureIdInvalidException.newBuilder() .message(MessageFormat.format(msgPattern, messageFeatureId, expectedFeatureId)) .dittoHeaders(dittoHeaders) .build(); } }
private static void validateMessageFeatureId(final String expectedFeatureId, final Message<?> message, final DittoHeaders dittoHeaders) { final Optional<String> messageFeatureIdOptional = message.getFeatureId(); if (!messageFeatureIdOptional.isPresent()) { final String msgPattern = "The Message did not contain a feature ID at all! Expected was feature ID <{0}>."; throw FeatureIdInvalidException.newBuilder() .message(MessageFormat.format(msgPattern, expectedFeatureId)) .dittoHeaders(dittoHeaders) .build(); } final String messageFeatureId = messageFeatureIdOptional.get(); if (!messageFeatureId.equals(expectedFeatureId)) { final String msgPattern = "The Message contained feature ID <{0}>. Expected was feature ID <{1}>."; throw FeatureIdInvalidException.newBuilder() .message(MessageFormat.format(msgPattern, messageFeatureId, expectedFeatureId)) .dittoHeaders(dittoHeaders) .build(); } }