private Builder(final String uri) { this(); message(MessageFormat.format(MESSAGE_TEMPLATE, uri)); }
private Builder(final String uri) { this(); message(MessageFormat.format(MESSAGE_TEMPLATE, uri)); }
/** * Check whether the URI scheme of the connection belongs to an accepted scheme. * * @param connection the connection to check. * @param dittoHeaders headers of the command that triggered the connection validation. * @param acceptedSchemes valid URI schemes for the connection type. * @param protocolName protocol name of the connection type. * @throws DittoRuntimeException if the URI scheme is not accepted. */ protected static void validateUriScheme(final Connection connection, final DittoHeaders dittoHeaders, final Collection<String> acceptedSchemes, final String protocolName) { if (!acceptedSchemes.contains(connection.getProtocol())) { final String message = MessageFormat.format("The URI scheme ''{0}'' is not valid for {1}.", connection.getProtocol(), protocolName); final String description = MessageFormat.format("Accepted URI schemes are: {0}", String.join(", ", acceptedSchemes)); throw ConnectionUriInvalidException.newBuilder(connection.getUri()) .message(message) .description(description) .dittoHeaders(dittoHeaders) .build(); } }
/** * Check whether the URI scheme of the connection belongs to an accepted scheme. * * @param connection the connection to check. * @param dittoHeaders headers of the command that triggered the connection validation. * @param acceptedSchemes valid URI schemes for the connection type. * @param protocolName protocol name of the connection type. * @throws DittoRuntimeException if the URI scheme is not accepted. */ protected static void validateUriScheme(final Connection connection, final DittoHeaders dittoHeaders, final Collection<String> acceptedSchemes, final String protocolName) { if (!acceptedSchemes.contains(connection.getProtocol())) { final String message = MessageFormat.format("The URI scheme ''{0}'' is not valid for {1}.", connection.getProtocol(), protocolName); final String description = MessageFormat.format("Accepted URI schemes are: {0}", String.join(", ", acceptedSchemes)); throw ConnectionUriInvalidException.newBuilder(connection.getUri()) .message(message) .description(description) .dittoHeaders(dittoHeaders) .build(); } }