Default method using explicitly comma
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java index cf56f69..bf98ee3 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java
@@ -194,7 +194,7 @@ public String getHeaderString(String name); /** - * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * Checks whether a header with a specific name and value (or item of the token-separated value list) exists. * * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value @@ -210,7 +210,7 @@ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split. * @param valuePredicate value must fulfil this predicate. * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value - * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values. * @see #getHeaders() * @see #getHeaderString(String) * @since 4.0 @@ -218,6 +218,31 @@ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate<String> valuePredicate); /** + * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * + * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one + * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value + * class or using its {@code toString} method if a header delegate is not available. + * + * <p> + * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if + * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value + * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform} + * (missing comma), or the value {@code no - store} (whitespace within value). + * + * @param name the message header. + * @param valuePredicate value must fulfil this predicate. + * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value + * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * @see #getHeaders() + * @see #getHeaderString(String) + * @since 4.0 + */ + default public boolean containsHeaderString(String name, Predicate<String> valuePredicate) { + return containsHeaderString(name, ",", valuePredicate); + } + + /** * Get message date. * * @return the message date, otherwise {@code null} if not present.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java index 7956d31..2ba9962 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java
@@ -90,7 +90,7 @@ public String getHeaderString(String name); /** - * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * Checks whether a header with a specific name and value (or item of the token-separated value list) exists. * * <p> * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if @@ -102,7 +102,7 @@ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split. * @param valuePredicate value must fulfil this predicate. * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value - * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values. * @see #getHeaders() * @see #getHeaderString(String) * @since 4.0 @@ -110,6 +110,27 @@ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate<String> valuePredicate); /** + * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * + * <p> + * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if + * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value + * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform} + * (missing comma), or the value {@code no - store} (whitespace within value). + * + * @param name the message header. + * @param valuePredicate value must fulfil this predicate. + * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value + * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * @see #getHeaders() + * @see #getHeaderString(String) + * @since 4.0 + */ + default public boolean containsHeaderString(String name, Predicate<String> valuePredicate) { + return containsHeaderString(name, ",", valuePredicate); + } + + /** * Get the allowed HTTP methods from the Allow HTTP header. * * @return the allowed HTTP methods, all methods will returned as upper case strings.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java index 6046edf..6577f3c 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java
@@ -230,7 +230,7 @@ public String getHeaderString(String name); /** - * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * Checks whether a header with a specific name and value (or item of the token-separated value list) exists. * * <p> * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if @@ -242,7 +242,7 @@ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split. * @param valuePredicate value must fulfil this predicate. * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value - * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values. * @see #getHeaders() * @see #getHeaderString(String) * @since 4.0 @@ -250,6 +250,27 @@ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate<String> valuePredicate); /** + * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * + * <p> + * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if + * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value + * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform} + * (missing comma), or the value {@code no - store} (whitespace within value). + * + * @param name the message header. + * @param valuePredicate value must fulfil this predicate. + * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value + * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * @see #getHeaders() + * @see #getHeaderString(String) + * @since 4.0 + */ + default public boolean containsHeaderString(String name, Predicate<String> valuePredicate) { + return containsHeaderString(name, ",", valuePredicate); + } + + /** * Get message date. * * @return the message date, otherwise {@code null} if not present.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java index cfd5d70..878001a 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java
@@ -116,7 +116,7 @@ public String getHeaderString(String name); /** - * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * Checks whether a header with a specific name and value (or item of the token-separated value list) exists. * * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value @@ -132,7 +132,7 @@ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split. * @param valuePredicate value must fulfil this predicate. * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value - * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values. * @see #getHeaders() * @see #getHeaderString(String) * @since 4.0 @@ -140,6 +140,31 @@ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate<String> valuePredicate); /** + * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * + * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one + * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value + * class or using its {@code toString} method if a header delegate is not available. + * + * <p> + * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if + * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value + * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform} + * (missing comma), or the value {@code no - store} (whitespace within value). + * + * @param name the message header. + * @param valuePredicate value must fulfil this predicate. + * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value + * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * @see #getHeaders() + * @see #getHeaderString(String) + * @since 4.0 + */ + default public boolean containsHeaderString(String name, Predicate<String> valuePredicate) { + return containsHeaderString(name, ",", valuePredicate); + } + + /** * Get the allowed HTTP methods from the Allow HTTP header. * * @return the allowed HTTP methods, all methods will returned as upper case strings.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java index 802808a..62e3431 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java
@@ -62,7 +62,7 @@ public String getHeaderString(String name); /** - * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * Checks whether a header with a specific name and value (or item of the token-separated value list) exists. * * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value @@ -78,7 +78,7 @@ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split. * @param valuePredicate value must fulfil this predicate. * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value - * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values. * @see #getRequestHeaders() * @see #getHeaderString(String) * @since 4.0 @@ -86,6 +86,31 @@ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate<String> valuePredicate); /** + * Checks whether a header with a specific name and value (or item of the comma-separated value list) exists. + * + * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one + * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value + * class or using its {@code toString} method if a header delegate is not available. + * + * <p> + * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if + * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value + * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform} + * (missing comma), or the value {@code no - store} (whitespace within value). + * + * @param name the message header. + * @param valuePredicate value must fulfil this predicate. + * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value + * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values. + * @see #getRequestHeaders() + * @see #getHeaderString(String) + * @since 4.0 + */ + default public boolean containsHeaderString(String name, Predicate<String> valuePredicate) { + return containsHeaderString(name, ",", valuePredicate); + } + + /** * Get the values of HTTP request headers. The returned Map is case-insensitive wrt. keys and is read-only. The method * never returns {@code null}. *