private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
/** * Get a single typed header value. * * @param name header name. * @param converter from string conversion function. Is expected to throw {@link ProcessingException} * if conversion fails. * @param convertNull if {@code true} this method calls the provided converter even for {@code null}. Otherwise this * method returns the {@code null} without calling the converter. * @return value of the header, or (possibly converted) {@code null} if not present. */ private <T> T singleHeader(String name, Function<String, T> converter, boolean convertNull) { final List<String> values = this.headers.get(name); if (values == null || values.isEmpty()) { return convertNull ? converter.apply(null) : null; } if (values.size() > 1) { throw new HeaderValueException(LocalizationMessages.TOO_MANY_HEADER_VALUES(name, values.toString()), HeaderValueException.Context.INBOUND); } Object value = values.get(0); if (value == null) { return convertNull ? converter.apply(null) : null; } try { return converter.apply(HeaderUtils.asString(value, null)); } catch (ProcessingException ex) { throw exception(name, value, ex); } }
/** * Get a single typed header value. * * @param name header name. * @param converter from string conversion function. Is expected to throw {@link ProcessingException} * if conversion fails. * @param convertNull if {@code true} this method calls the provided converter even for {@code null}. Otherwise this * method returns the {@code null} without calling the converter. * @return value of the header, or (possibly converted) {@code null} if not present. */ private <T> T singleHeader(String name, Function<String, T> converter, boolean convertNull) { final List<String> values = this.headers.get(name); if (values == null || values.isEmpty()) { return convertNull ? converter.apply(null) : null; } if (values.size() > 1) { throw new HeaderValueException(LocalizationMessages.TOO_MANY_HEADER_VALUES(name, values.toString()), HeaderValueException.Context.INBOUND); } Object value = values.get(0); if (value == null) { return convertNull ? converter.apply(null) : null; } try { return converter.apply(HeaderUtils.asString(value, null)); } catch (ProcessingException ex) { throw exception(name, value, ex); } }
throw new HeaderValueException( LocalizationMessages.TOO_MANY_HEADER_VALUES(name, values.toString()), HeaderValueException.Context.OUTBOUND);
throw new HeaderValueException( LocalizationMessages.TOO_MANY_HEADER_VALUES(name, values.toString()), HeaderValueException.Context.OUTBOUND);
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.OUTBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
private static HeaderValueException exception(final String headerName, Object headerValue, Exception e) { return new HeaderValueException(LocalizationMessages.UNABLE_TO_PARSE_HEADER_VALUE(headerName, headerValue), e, HeaderValueException.Context.INBOUND); }
/** * Get a single typed header value. * * @param name header name. * @param converter from string conversion function. Is expected to throw {@link ProcessingException} * if conversion fails. * @param convertNull if {@code true} this method calls the provided converter even for {@code null}. Otherwise this * method returns the {@code null} without calling the converter. * @return value of the header, or (possibly converted) {@code null} if not present. */ private <T> T singleHeader(String name, Function<String, T> converter, boolean convertNull) { final List<String> values = this.headers.get(name); if (values == null || values.isEmpty()) { return convertNull ? converter.apply(null) : null; } if (values.size() > 1) { throw new HeaderValueException(LocalizationMessages.TOO_MANY_HEADER_VALUES(name, values.toString()), HeaderValueException.Context.INBOUND); } Object value = values.get(0); if (value == null) { return convertNull ? converter.apply(null) : null; } try { return converter.apply(HeaderUtils.asString(value, null)); } catch (ProcessingException ex) { throw exception(name, value, ex); } }
/** * Get a single typed header value. * * @param name header name. * @param converter from string conversion function. Is expected to throw {@link ProcessingException} * if conversion fails. * @param convertNull if {@code true} this method calls the provided converter even for {@code null}. Otherwise this * method returns the {@code null} without calling the converter. * @return value of the header, or (possibly converted) {@code null} if not present. */ private <T> T singleHeader(String name, Function<String, T> converter, boolean convertNull) { final List<String> values = this.headers.get(name); if (values == null || values.isEmpty()) { return convertNull ? converter.apply(null) : null; } if (values.size() > 1) { throw new HeaderValueException(LocalizationMessages.TOO_MANY_HEADER_VALUES(name, values.toString()), HeaderValueException.Context.INBOUND); } Object value = values.get(0); if (value == null) { return convertNull ? converter.apply(null) : null; } try { return converter.apply(HeaderUtils.asString(value, null)); } catch (ProcessingException ex) { throw exception(name, value, ex); } }