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 e1fb4c7  Context API refactoring.
e1fb4c7 is described below

commit e1fb4c728cd58acf6238c5851face22d74584489
Author: JamesBognar <[email protected]>
AuthorDate: Thu Sep 23 16:59:12 2021 -0400

    Context API refactoring.
---
 .../org/apache/juneau/rest/client/RestClient.java  | 103 ++-------------------
 .../juneau/rest/client/RestClientBuilder.java      |  29 +++---
 .../org/apache/juneau/rest/client/RestRequest.java |   4 +-
 .../juneau/rest/mock/MockRestClientBuilder.java    |   8 +-
 4 files changed, 29 insertions(+), 115 deletions(-)

diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 51db01d..6c252cb 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -54,7 +54,6 @@ import org.apache.juneau.collections.*;
 import org.apache.juneau.cp.*;
 import org.apache.juneau.http.remote.RemoteReturn;
 import org.apache.juneau.http.resource.*;
-import org.apache.juneau.http.annotation.*;
 import org.apache.juneau.http.entity.*;
 import org.apache.juneau.http.header.*;
 import org.apache.juneau.http.part.*;
@@ -1647,102 +1646,12 @@ public class RestClient extends BeanContextable 
implements HttpClient, Closeable
         */
        public static final String RESTCLIENT_rootUri = PREFIX + "rootUri.s";
 
-       /**
-        * Configuration property:  Skip empty form data.
-        *
-        * <h5 class='section'>Property:</h5>
-        * <ul class='spaced-list'>
-        *      <li><b>ID:</b>  {@link 
org.apache.juneau.rest.client.RestClient#RESTCLIENT_skipEmptyFormData 
RESTCLIENT_skipEmptyFormData}
-        *      <li><b>Name:</b>  <js>"RestClient.skipEmptyFormData.b"</js>
-        *      <li><b>Data type:</b>  {@link java.lang.Boolean}
-        *      <li><b>Default:</b>  <jk>false</jk>.
-        *      <li><b>Methods:</b>
-        *              <ul>
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#skipEmptyFormData(boolean)}
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#skipEmptyFormData()}
-        *              </ul>
-        *      <li><b>Related:</b>
-        *              <ul>
-        *                      <li class='ja'>{@link FormData#skipIfEmpty()}
-        *              </ul>
-        * </ul>
-        *
-        * <h5 class='section'>Description:</h5>
-        * <p>
-        * When enabled, form data consisting of empty strings will be skipped 
on requests.
-        * Note that <jk>null</jk> values are already skipped.
-        *
-        * <p>
-        * The {@link FormData#skipIfEmpty()} annotation overrides this setting.
-        */
-       public static final String RESTCLIENT_skipEmptyFormData = PREFIX + 
"skipEmptyFormData.b";
-
-       /**
-        * Configuration property:  Skip empty header data.
-        *
-        * <h5 class='section'>Property:</h5>
-        * <ul class='spaced-list'>
-        *      <li><b>ID:</b>  {@link 
org.apache.juneau.rest.client.RestClient#RESTCLIENT_skipEmptyHeaders 
RESTCLIENT_skipEmptyHeaders}
-        *      <li><b>Name:</b>  <js>"RestClient.skipEmptyHeaders.b"</js>
-        *      <li><b>Data type:</b>  {@link java.lang.Boolean}
-        *      <li><b>Default:</b>  <jk>false</jk>.
-        *      <li><b>Methods:</b>
-        *              <ul>
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#skipEmptyHeaders(boolean)}
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#skipEmptyHeaders()}
-        *              </ul>
-        *      <li><b>Related:</b>
-        *              <ul>
-        *                      <li class='ja'>{@link 
org.apache.juneau.http.annotation.Header#skipIfEmpty()}
-        *              </ul>
-        * </ul>
-        *
-        * <h5 class='section'>Description:</h5>
-        * <p>
-        * When enabled, header values consisting of empty strings will be 
skipped on requests.
-        * Note that <jk>null</jk> values are already skipped.
-        *
-        * <p>
-        * The {@link org.apache.juneau.http.annotation.Header#skipIfEmpty()} 
annotation overrides this setting.
-        */
-       public static final String RESTCLIENT_skipEmptyHeaders = PREFIX + 
"skipEmptyHeaders.b";
-
-       /**
-        * Configuration property:  Skip empty query data.
-        *
-        * <h5 class='section'>Property:</h5>
-        * <ul class='spaced-list'>
-        *      <li><b>ID:</b>  {@link 
org.apache.juneau.rest.client.RestClient#RESTCLIENT_skipEmptyQueryData 
RESTCLIENT_skipEmptyQueryData}
-        *      <li><b>Name:</b>  <js>"RestClient.skipEmptyQueryData.b"</js>
-        *      <li><b>Data type:</b>  {@link java.lang.Boolean}
-        *      <li><b>Default:</b>  <jk>false</jk>.
-        *      <li><b>Methods:</b>
-        *              <ul>
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#skipEmptyQueryData(boolean)}
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#skipEmptyQueryData()}
-        *              </ul>
-        *      <li><b>Related:</b>
-        *              <ul>
-        *                      <li class='ja'>{@link Query#skipIfEmpty()}
-        *              </ul>
-        * </ul>
-        *
-        * <h5 class='section'>Description:</h5>
-        * <p>
-        * When enabled, query parameters consisting of empty strings will be 
skipped on requests.
-        * Note that <jk>null</jk> values are already skipped.
-        *
-        * <p>
-        * The {@link Query#skipIfEmpty()} annotation overrides this setting.
-        */
-       public static final String RESTCLIENT_skipEmptyQueryData = PREFIX + 
"skipEmptyQueryData.b";
-
        final HeaderList.Builder headerData;
        final PartList.Builder queryData, formData, pathData;
        final CloseableHttpClient httpClient;
 
        private final HttpClientConnectionManager connectionManager;
-       private final boolean keepHttpClientOpen, leakDetection, 
skipEmptyHeaders, skipEmptyQueryData, skipEmptyFormData;
+       private final boolean keepHttpClientOpen, leakDetection, 
skipEmptyHeaderData, skipEmptyQueryData, skipEmptyFormData;
        private final BeanStore beanStore;
        private final UrlEncodingSerializer urlEncodingSerializer;  // Used for 
form posts only.
        final HttpPartSerializer partSerializer;
@@ -1808,11 +1717,11 @@ public class RestClient extends BeanContextable 
implements HttpClient, Closeable
                queryData = builder.queryData().build().copy();
                formData = builder.formData().build().copy();
                pathData = builder.pathData().build().copy();
+               skipEmptyHeaderData = builder.skipEmptyHeaderData;
+               skipEmptyQueryData = builder.skipEmptyQueryData;
+               skipEmptyFormData = builder.skipEmptyFormData;
 
                ContextProperties cp = 
getContextProperties().copy().apply(getBeanContext().getContextProperties()).build();
-               this.skipEmptyHeaders = 
cp.getBoolean(RESTCLIENT_skipEmptyHeaders).orElse(false);
-               this.skipEmptyQueryData = 
cp.getBoolean(RESTCLIENT_skipEmptyQueryData).orElse(false);
-               this.skipEmptyFormData = 
cp.getBoolean(RESTCLIENT_skipEmptyFormData).orElse(false);
 
                BeanStore bs = this.beanStore = BeanStore.create().build()
                        .addBean(ContextProperties.class, cp)
@@ -3163,8 +3072,8 @@ public class RestClient extends BeanContextable 
implements HttpClient, Closeable
         *
         * @return <jk>true</jk> if empty request header values should be 
ignored.
         */
-       protected boolean isSkipEmptyHeaders() {
-               return skipEmptyHeaders;
+       protected boolean isSkipEmptyHeaderData() {
+               return skipEmptyHeaderData;
        }
 
        /**
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
index 0629d3a..63184ac 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
@@ -95,6 +95,8 @@ public class RestClientBuilder extends BeanContextableBuilder 
{
        private PartList.Builder queryData, formData, pathData;
        private boolean pooled;
 
+       boolean skipEmptyHeaderData, skipEmptyFormData, skipEmptyQueryData;
+
        SerializerGroup.Builder serializerGroupBuilder;
        ParserGroup.Builder parserGroupBuilder;
 
@@ -3143,7 +3145,7 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
        }
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Skip empty 
form data.
+        * Skip empty form data.
         *
         * <p>
         * When enabled, form data consisting of empty strings will be skipped 
on requests.
@@ -3159,11 +3161,12 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
         */
        @FluentSetter
        public RestClientBuilder skipEmptyFormData(boolean value) {
-               return set(RESTCLIENT_skipEmptyFormData, value);
+               skipEmptyFormData = true;
+               return this;
        }
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Skip empty 
form data.
+        * Skip empty form data.
         *
         * <p>
         * When enabled, form data consisting of empty strings will be skipped 
on requests.
@@ -3180,7 +3183,7 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
        }
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Skip empty 
headers.
+        * Skip empty header data.
         *
         * <p>
         * When enabled, headers consisting of empty strings will be skipped on 
requests.
@@ -3195,12 +3198,13 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
         * @return This object (for method chaining).
         */
        @FluentSetter
-       public RestClientBuilder skipEmptyHeaders(boolean value) {
-               return set(RESTCLIENT_skipEmptyHeaders, value);
+       public RestClientBuilder skipEmptyHeaderData(boolean value) {
+               skipEmptyHeaderData = true;
+               return this;
        }
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Skip empty 
headers.
+        * Skip empty header data.
         *
         * <p>
         * When enabled, headers consisting of empty strings will be skipped on 
requests.
@@ -3212,12 +3216,12 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
         * @return This object (for method chaining).
         */
        @FluentSetter
-       public RestClientBuilder skipEmptyHeaders() {
-               return skipEmptyHeaders(true);
+       public RestClientBuilder skipEmptyHeaderData() {
+               return skipEmptyHeaderData(true);
        }
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Skip empty 
query data.
+        * Skip empty query data.
         *
         * <p>
         * When enabled, query parameters consisting of empty strings will be 
skipped on requests.
@@ -3233,11 +3237,12 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
         */
        @FluentSetter
        public RestClientBuilder skipEmptyQueryData(boolean value) {
-               return set(RESTCLIENT_skipEmptyQueryData, value);
+               skipEmptyQueryData = true;
+               return this;
        }
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Skip empty 
query data.
+        * Skip empty query data.
         *
         * <p>
         * When enabled, query parameters consisting of empty strings will be 
skipped on requests.
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
index f776c5e..b50d4ac 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
@@ -3089,7 +3089,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
                if (isEmpty(name))
                        return null;
                if (skipIfEmpty == null)
-                       skipIfEmpty = client.isSkipEmptyHeaders();
+                       skipIfEmpty = client.isSkipEmptyHeaderData();
                if (serializer == null)
                        serializer = client.getPartSerializer();
                return new SerializedHeader(name, value, 
getPartSerializerSession(serializer), schema, skipIfEmpty);
@@ -3223,7 +3223,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        private class SimpleHeader extends SimplePart implements Header {
 
                SimpleHeader(NameValuePair x) {
-                       super(x, client.isSkipEmptyHeaders());
+                       super(x, client.isSkipEmptyHeaderData());
                }
 
                @Override
diff --git 
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
 
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
index 143da14..da47909 100644
--- 
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
@@ -1405,14 +1405,14 @@ public class MockRestClientBuilder extends 
RestClientBuilder {
        }
 
        @Override /* GENERATED - RestClientBuilder */
-       public MockRestClientBuilder skipEmptyHeaders() {
-               super.skipEmptyHeaders();
+       public MockRestClientBuilder skipEmptyHeaderData() {
+               super.skipEmptyHeaderData();
                return this;
        }
 
        @Override /* GENERATED - RestClientBuilder */
-       public MockRestClientBuilder skipEmptyHeaders(boolean value) {
-               super.skipEmptyHeaders(value);
+       public MockRestClientBuilder skipEmptyHeaderData(boolean value) {
+               super.skipEmptyHeaderData(value);
                return this;
        }
 

Reply via email to