This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 3386d85 Context API refactoring.
3386d85 is described below
commit 3386d85ba0302d1a883a79f0e38564b73cf5ea0e
Author: JamesBognar <[email protected]>
AuthorDate: Sat Aug 28 12:44:55 2021 -0400
Context API refactoring.
---
.../org/apache/juneau/rest/RestMatcherList.java | 51 +++++++++++--
...atcherList.java => RestMatcherListBuilder.java} | 58 +++++++++++++--
.../apache/juneau/rest/RestOperationContext.java | 86 +++-------------------
.../juneau/rest/RestOperationContextBuilder.java | 60 +++++++++++++--
.../rest/annotation/RestDeleteAnnotation.java | 3 +-
.../juneau/rest/annotation/RestGetAnnotation.java | 3 +-
.../juneau/rest/annotation/RestOpAnnotation.java | 3 +-
.../juneau/rest/annotation/RestPostAnnotation.java | 3 +-
.../juneau/rest/annotation/RestPutAnnotation.java | 3 +-
9 files changed, 167 insertions(+), 103 deletions(-)
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
index 525f96d..c2e4898 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
@@ -12,22 +12,61 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest;
-import org.apache.juneau.collections.*;
+import static java.util.stream.Collectors.*;
+import static java.util.Collections.*;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.cp.*;
/**
* A list of {@link RestMatcher} objects.
*/
-public class RestMatcherList extends AList<RestMatcher> {
+public class RestMatcherList {
- private static final long serialVersionUID = 1L;
+ private final List<RestMatcher> matchers;
/**
* Static creator.
*
* @return An empty list.
*/
- @SuppressWarnings("unchecked")
- public static RestMatcherList create() {
- return new RestMatcherList();
+ public static RestMatcherListBuilder create() {
+ return new RestMatcherListBuilder();
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param builder The builder containing the contents for this list.
+ */
+ protected RestMatcherList(RestMatcherListBuilder builder) {
+ matchers = unmodifiableList(
+ builder
+ .matchers
+ .stream()
+ .map(x -> instantiate(x, builder.beanStore))
+ .collect(toList())
+ );
+ }
+
+ private static RestMatcher instantiate(Object o, BeanStore bs) {
+ if (o instanceof RestMatcher)
+ return (RestMatcher)o;
+ try {
+ return (RestMatcher)bs.createBean((Class<?>)o);
+ } catch (ExecutableException e) {
+ throw new ConfigException(e, "Could not instantiate
class {0}", o);
+ }
+ }
+
+ /**
+ * Returns the matchers in this list.
+ *
+ * @return The matchers in this list. The list is unmodifiable.
+ */
+ public List<RestMatcher> getMatchers() {
+ return matchers;
}
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherListBuilder.java
similarity index 53%
copy from
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
copy to
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherListBuilder.java
index 525f96d..bad3a10 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherList.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMatcherListBuilder.java
@@ -13,21 +13,65 @@
package org.apache.juneau.rest;
import org.apache.juneau.collections.*;
+import org.apache.juneau.cp.*;
+import org.apache.juneau.internal.*;
/**
- * A list of {@link RestMatcher} objects.
+ * Builder for {@link RestMatcherList} objects.
*/
-public class RestMatcherList extends AList<RestMatcher> {
+@FluentSetters
+public class RestMatcherListBuilder {
- private static final long serialVersionUID = 1L;
+ AList<Object> matchers;
+ BeanStore beanStore;
/**
- * Static creator.
+ * Create an empty builder.
+ */
+ protected RestMatcherListBuilder() {
+ this.matchers = AList.create();
+ }
+
+ /**
+ * Creates a new {@link RestMatcherList} object using a snapshot of the
settings defined in this builder.
+ *
+ * @return A new {@link RestMatcherList} object.
+ */
+ public RestMatcherList build() {
+ return new RestMatcherList(this);
+ }
+
+ /**
+ * Appends the specified rest matcher classes to the list.
*
- * @return An empty list.
+ * @param values The values to add.
+ * @return This object (for method chaining).
*/
@SuppressWarnings("unchecked")
- public static RestMatcherList create() {
- return new RestMatcherList();
+ public RestMatcherListBuilder append(Class<? extends
RestMatcher>...values) {
+ matchers.append((Object[])values);
+ return this;
+ }
+
+ /**
+ * Appends the specified rest matcher classes to the list.
+ *
+ * @param values The values to add.
+ * @return This object (for method chaining).
+ */
+ public RestMatcherListBuilder append(RestMatcher...values) {
+ matchers.append((Object[])values);
+ return this;
+ }
+
+ /**
+ * Specifies the bean store to use for instantiating rest matcher
classes.
+ *
+ * @param value The bean store to use for instantiating rest matcher
classes.
+ * @return This object (for method chaining).
+ */
+ public RestMatcherListBuilder beanStore(BeanStore value) {
+ beanStore = value;
+ return this;
}
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
index 6a91538..62742d4 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
@@ -75,63 +75,6 @@ public class RestOperationContext extends BeanContext
implements Comparable<Rest
}
}
-
//-------------------------------------------------------------------------------------------------------------------
- // Configurable properties
-
//-------------------------------------------------------------------------------------------------------------------
-
- static final String PREFIX = "RestOperationContext";
-
- /**
- * Configuration property: Method-level matchers.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.rest.RestOperationContext#RESTOP_matchers RESTOP_matchers}
- * <li><b>Name:</b> <js>"RestOperationContext.matchers.lo"</js>
- * <li><b>Data type:</b> <c>List<{@link
org.apache.juneau.rest.RestMatcher}|Class<{@link
org.apache.juneau.rest.RestMatcher}>></c>
- * <li><b>Default:</b> empty list
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Annotations:</b>
- * <ul>
- * <li class='ja'>{@link
org.apache.juneau.rest.annotation.RestOp#matchers()}
- * </ul>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.rest.RestOperationContextBuilder#matchers(RestMatcher...)}
- * </ul>
- * </ul>
- *
- * <h5 class='section'>Description:</h5>
- * <p>
- * Associates one or more {@link RestMatcher RestMatchers} with the
specified method.
- *
- * <p>
- * If multiple matchers are specified, <b>ONE</b> matcher must pass.
- * <br>Note that this is different than guards where <b>ALL</b> guards
needs to pass.
- *
- * <ul class='notes'>
- * <li>
- * When defined as a class, the implementation must have
one of the following constructors:
- * <ul>
- * <li><code><jk>public</jk> T(RestContext)</code>
- * <li><code><jk>public</jk> T()</code>
- * <li><code><jk>public static</jk> T
<jsm>create</jsm>(RestContext)</code>
- * <li><code><jk>public static</jk> T
<jsm>create</jsm>()</code>
- * </ul>
- * <li>
- * Inner classes of the REST resource class are allowed.
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='link'>{@doc RestmMatchers}
- * </ul>
- */
- public static final String RESTOP_matchers = PREFIX + ".matchers.lo";
-
-
//-------------------------------------------------------------------------------------------------------------------
- // Instance
-
//-------------------------------------------------------------------------------------------------------------------
-
private final String httpMethod;
private final UrlPathMatcher[] pathMatchers;
private final RestOperationArg[] opArgs;
@@ -225,9 +168,9 @@ public class RestOperationContext extends BeanContext
implements Comparable<Rest
guards = createGuards(r, cp, bs).asArray();
bs.addBean(RestGuard[].class, guards);
- RestMatcherList matchers = createMatchers(r, cp,
builder, bs);
- requiredMatchers = matchers.stream().filter(x ->
x.required()).toArray(RestMatcher[]::new);
- optionalMatchers = matchers.stream().filter(x -> !
x.required()).toArray(RestMatcher[]::new);
+ RestMatcherList matchers = createMatchers(r, builder,
bs);
+ requiredMatchers =
matchers.getMatchers().stream().filter(x ->
x.required()).toArray(RestMatcher[]::new);
+ optionalMatchers =
matchers.getMatchers().stream().filter(x -> !
x.required()).toArray(RestMatcher[]::new);
pathMatchers = createPathMatchers(r, cp, builder,
bs).asArray();
bs.addBean(UrlPathMatcher[].class, pathMatchers);
@@ -400,7 +343,7 @@ public class RestOperationContext extends BeanContext
implements Comparable<Rest
* <p>
* Instantiates based on the following logic:
* <ul>
- * <li>Looks for {@link #RESTOP_matchers} value set via any of the
following:
+ * <li>Looks for matchers set via any of the following:
* <ul>
* <li>{@link RestOp#matchers()}.
* </ul>
@@ -417,35 +360,28 @@ public class RestOperationContext extends BeanContext
implements Comparable<Rest
* </ul>
*
* @param resource The REST resource object.
- * @param properties xxx
- * @param builder The builder for this bean.
+ * @param builder The builder for this object.
* @param beanStore The bean store to use for retrieving and creating
beans.
* @return The method matchers for this REST resource method.
* @throws Exception If method matchers could not be instantiated.
- * @see #RESTOP_matchers
*/
- protected RestMatcherList createMatchers(Object resource,
ContextProperties properties, RestOperationContextBuilder builder, BeanStore
beanStore) throws Exception {
-
- RestMatcherList x = RestMatcherList.create();
+ protected RestMatcherList createMatchers(Object resource,
RestOperationContextBuilder builder, BeanStore beanStore) throws Exception {
- x.append(properties.getInstanceArray(RESTOP_matchers,
RestMatcher.class, beanStore).orElse(new RestMatcher[0]));
-
- if (x.isEmpty())
- x = beanStore.getBean(RestMatcherList.class).orElse(x);
+ RestMatcherListBuilder x =
builder.restMatchers.beanStore(beanStore);
String clientVersion = builder.clientVersion;
if (clientVersion != null)
- x.add(new
ClientVersionMatcher(context.getClientVersionHeader(), mi));
+ x.append(new
ClientVersionMatcher(context.getClientVersionHeader(), mi));
x = BeanStore
.of(beanStore, resource)
- .addBean(RestMatcherList.class, x)
- .beanCreateMethodFinder(RestMatcherList.class, resource)
+ .addBean(RestMatcherListBuilder.class, x)
+ .beanCreateMethodFinder(RestMatcherListBuilder.class,
resource)
.find("createMatchers", Method.class)
.withDefault(x)
.run();
- return x;
+ return x.build();
}
/**
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContextBuilder.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContextBuilder.java
index 3fd7093..f2864bc 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContextBuilder.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContextBuilder.java
@@ -13,8 +13,6 @@
package org.apache.juneau.rest;
import static org.apache.juneau.rest.HttpRuntimeException.*;
-import static org.apache.juneau.rest.RestOperationContext.*;
-
import java.lang.annotation.*;
import java.util.*;
import org.apache.http.*;
@@ -44,6 +42,7 @@ public class RestOperationContextBuilder extends
BeanContextBuilder {
PartListBuilder defaultFormData, defaultQueryData;
NamedAttributeList defaultRequestAttributes;
HeaderListBuilder defaultRequestHeaders, defaultResponseHeaders;
+ RestMatcherListBuilder restMatchers;
private BeanStore beanStore;
@@ -82,6 +81,7 @@ public class RestOperationContextBuilder extends
BeanContextBuilder {
this.defaultRequestAttributes = NamedAttributeList.create();
this.defaultRequestHeaders = HeaderList.create();
this.defaultResponseHeaders = HeaderList.create();
+ this.restMatchers = RestMatcherList.create();
MethodInfo mi = MethodInfo.of(context.getResourceClass(),
method);
@@ -438,13 +438,21 @@ public class RestOperationContextBuilder extends
BeanContextBuilder {
}
/**
- * Configuration property: Method-level matchers.
+ * Method-level matchers.
*
* <p>
* Associates one or more {@link RestMatcher RestMatchers} with the
specified method.
*
+ * <p>
+ * If multiple matchers are specified, <b>ONE</b> matcher must pass.
+ * <br>Note that this is different than guards where <b>ALL</b> guards
needs to pass.
+ *
* <ul class='seealso'>
- * <li class='jf'>{@link RestOperationContext#RESTOP_matchers}
+ * <li class='ja'>{@link RestOp#matchers()}
+ * <li class='ja'>{@link RestGet#matchers()}
+ * <li class='ja'>{@link RestPut#matchers()}
+ * <li class='ja'>{@link RestPost#matchers()}
+ * <li class='ja'>{@link RestDelete#matchers()}
* </ul>
*
* @param values The new values for this setting.
@@ -452,7 +460,49 @@ public class RestOperationContextBuilder extends
BeanContextBuilder {
*/
@FluentSetter
public RestOperationContextBuilder matchers(RestMatcher...values) {
- return set(RESTOP_matchers, values);
+ restMatchers.append(values);
+ return this;
+ }
+
+ /**
+ * Method-level matchers.
+ *
+ * <p>
+ * Associates one or more {@link RestMatcher RestMatchers} with the
specified method.
+ *
+ * <p>
+ * If multiple matchers are specified, <b>ONE</b> matcher must pass.
+ * <br>Note that this is different than guards where <b>ALL</b> guards
needs to pass.
+ *
+ * <ul class='notes'>
+ * <li>
+ * When defined as a class, the implementation must have
one of the following constructors:
+ * <ul>
+ * <li><code><jk>public</jk> T(RestContext)</code>
+ * <li><code><jk>public</jk> T()</code>
+ * <li><code><jk>public static</jk> T
<jsm>create</jsm>(RestContext)</code>
+ * <li><code><jk>public static</jk> T
<jsm>create</jsm>()</code>
+ * </ul>
+ * <li>
+ * Inner classes of the REST resource class are allowed.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link RestOp#matchers()}
+ * <li class='ja'>{@link RestGet#matchers()}
+ * <li class='ja'>{@link RestPut#matchers()}
+ * <li class='ja'>{@link RestPost#matchers()}
+ * <li class='ja'>{@link RestDelete#matchers()}
+ * </ul>
+ *
+ * @param values The new values for this setting.
+ * @return This object (for method chaining).
+ */
+ @SuppressWarnings("unchecked")
+ @FluentSetter
+ public RestOperationContextBuilder matchers(Class<? extends
RestMatcher>...values) {
+ restMatchers.append(values);
+ return this;
}
/**
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
index bbff5ab..87c756c 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.annotation;
import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import static org.apache.juneau.rest.RestContext.*;
-import static org.apache.juneau.rest.RestOperationContext.*;
import static org.apache.juneau.rest.util.RestUtils.*;
import static org.apache.juneau.http.HttpParts.*;
@@ -464,7 +463,7 @@ public class RestDeleteAnnotation {
stringStream(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
b.appendToIfNotEmpty(REST_defaultRequestHeaders,
accept(string(a.defaultAccept())));
b.prependTo(REST_guards, reverse(a.guards()));
- b.prependTo(RESTOP_matchers, a.matchers());
+ b.matchers(a.matchers());
value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
b.setIfNotEmpty(REST_defaultCharset,
string(a.defaultCharset()));
stringStream(a.path()).forEach(x -> b.path(x));
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
index 83b0eb1..041e7f4 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.annotation;
import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import static org.apache.juneau.rest.RestContext.*;
-import static org.apache.juneau.rest.RestOperationContext.*;
import static org.apache.juneau.rest.util.RestUtils.*;
import static org.apache.juneau.http.HttpParts.*;
@@ -520,7 +519,7 @@ public class RestGetAnnotation {
b.appendToIfNotEmpty(REST_defaultRequestHeaders,
accept(string(a.defaultAccept())));
b.prependTo(REST_converters, a.converters());
b.prependTo(REST_guards, reverse(a.guards()));
- b.prependTo(RESTOP_matchers, a.matchers());
+ b.matchers(a.matchers());
value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
b.setIfNotEmpty(REST_defaultCharset,
string(a.defaultCharset()));
stringStream(a.path()).forEach(x -> b.path(x));
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
index 6f36f8f..04356a5 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.annotation;
import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import static org.apache.juneau.rest.RestContext.*;
-import static org.apache.juneau.rest.RestOperationContext.*;
import static org.apache.juneau.rest.util.RestUtils.*;
import static org.apache.juneau.http.HttpParts.*;
@@ -624,7 +623,7 @@ public class RestOpAnnotation {
b.appendToIfNotEmpty(REST_defaultRequestHeaders,
contentType(string(a.defaultContentType())));
b.prependTo(REST_converters, a.converters());
b.prependTo(REST_guards, reverse(a.guards()));
- b.prependTo(RESTOP_matchers, a.matchers());
+ b.matchers(a.matchers());
value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
b.setIfNotEmpty(REST_defaultCharset,
string(a.defaultCharset()));
b.setIfNotEmpty(REST_maxInput, string(a.maxInput()));
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
index d4208bd..543f57d 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.annotation;
import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import static org.apache.juneau.rest.RestContext.*;
-import static org.apache.juneau.rest.RestOperationContext.*;
import static org.apache.juneau.rest.util.RestUtils.*;
import static org.apache.juneau.http.HttpParts.*;
@@ -609,7 +608,7 @@ public class RestPostAnnotation {
b.appendToIfNotEmpty(REST_defaultRequestHeaders,
contentType(string(a.defaultContentType())));
b.prependTo(REST_converters, a.converters());
b.prependTo(REST_guards, reverse(a.guards()));
- b.prependTo(RESTOP_matchers, a.matchers());
+ b.matchers(a.matchers());
value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
b.setIfNotEmpty(REST_defaultCharset,
string(a.defaultCharset()));
b.setIfNotEmpty(REST_maxInput, string(a.maxInput()));
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
index f35f640..74c6907 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.annotation;
import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import static org.apache.juneau.rest.RestContext.*;
-import static org.apache.juneau.rest.RestOperationContext.*;
import static org.apache.juneau.rest.util.RestUtils.*;
import static org.apache.juneau.http.HttpParts.*;
@@ -609,7 +608,7 @@ public class RestPutAnnotation {
b.appendToIfNotEmpty(REST_defaultRequestHeaders,
contentType(string(a.defaultContentType())));
b.prependTo(REST_converters, a.converters());
b.prependTo(REST_guards, reverse(a.guards()));
- b.prependTo(RESTOP_matchers, a.matchers());
+ b.matchers(a.matchers());
value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
b.setIfNotEmpty(REST_defaultCharset,
string(a.defaultCharset()));
b.setIfNotEmpty(REST_maxInput, string(a.maxInput()));