@@ -72,6 +72,9 @@ public final class PostgresqlConnectionConfiguration {
7272
7373 private final String host ;
7474
75+ @ Nullable
76+ private final LoopResources loopResources ;
77+
7578 private final Map <String , String > options ;
7679
7780 private final CharSequence password ;
@@ -82,20 +85,18 @@ public final class PostgresqlConnectionConfiguration {
8285
8386 private final String socket ;
8487
85- private final String username ;
86-
8788 private final SSLConfig sslConfig ;
8889
8990 private final boolean tcpKeepAlive ;
9091
9192 private final boolean tcpNoDelay ;
9293
93- private final LoopResources tcpLoopResources ;
94+ private final String username ;
9495
9596 private PostgresqlConnectionConfiguration (String applicationName , boolean autodetectExtensions , @ Nullable Duration connectTimeout , @ Nullable String database , List <Extension > extensions ,
96- ToIntFunction <String > fetchSize , boolean forceBinary , @ Nullable String host , @ Nullable Map < String , String > options , @ Nullable CharSequence password ,
97- int port , int preparedStatementCacheQueries , @ Nullable String schema , @ Nullable String socket , boolean tcpKeepAlive , boolean tcpNoDelay ,
98- String username , SSLConfig sslConfig , LoopResources tcpLoopResources ) {
97+ ToIntFunction <String > fetchSize , boolean forceBinary , @ Nullable String host , @ Nullable LoopResources loopResources ,
98+ @ Nullable Map < String , String > options , @ Nullable CharSequence password , int port , int preparedStatementCacheQueries , @ Nullable String schema ,
99+ @ Nullable String socket , SSLConfig sslConfig , boolean tcpKeepAlive , boolean tcpNoDelay , String username ) {
99100 this .applicationName = Assert .requireNonNull (applicationName , "applicationName must not be null" );
100101 this .autodetectExtensions = autodetectExtensions ;
101102 this .connectTimeout = connectTimeout ;
@@ -104,6 +105,7 @@ private PostgresqlConnectionConfiguration(String applicationName, boolean autode
104105 this .fetchSize = fetchSize ;
105106 this .forceBinary = forceBinary ;
106107 this .host = host ;
108+ this .loopResources = loopResources ;
107109 this .options = options == null ? new LinkedHashMap <>() : new LinkedHashMap <>(options );
108110
109111 if (schema != null && !schema .isEmpty ()) {
@@ -114,11 +116,10 @@ private PostgresqlConnectionConfiguration(String applicationName, boolean autode
114116 this .port = port ;
115117 this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
116118 this .socket = socket ;
117- this .username = Assert .requireNonNull (username , "username must not be null" );
118119 this .sslConfig = sslConfig ;
119120 this .tcpKeepAlive = tcpKeepAlive ;
120121 this .tcpNoDelay = tcpNoDelay ;
121- this .tcpLoopResources = tcpLoopResources ;
122+ this .username = Assert . requireNonNull ( username , "username must not be null" ) ;
122123 }
123124
124125 /**
@@ -141,9 +142,11 @@ public String toString() {
141142 ", fetchSize=" + this .fetchSize +
142143 ", forceBinary='" + this .forceBinary + '\'' +
143144 ", host='" + this .host + '\'' +
145+ ", loopResources='" + this .loopResources + '\'' +
144146 ", options='" + this .options + '\'' +
145147 ", password='" + obfuscate (this .password != null ? this .password .length () : 0 ) + '\'' +
146148 ", port=" + this .port +
149+ ", socket=" + this .socket +
147150 ", tcpKeepAlive=" + this .tcpKeepAlive +
148151 ", tcpNoDelay=" + this .tcpNoDelay +
149152 ", username='" + this .username + '\'' +
@@ -192,6 +195,11 @@ String getRequiredHost() {
192195 return host ;
193196 }
194197
198+ @ Nullable
199+ LoopResources getLoopResources () {
200+ return this .loopResources ;
201+ }
202+
195203 Map <String , String > getOptions () {
196204 return Collections .unmodifiableMap (this .options );
197205 }
@@ -253,10 +261,6 @@ SSLConfig getSslConfig() {
253261 return this .sslConfig ;
254262 }
255263
256- LoopResources getTcpLoopResources () {
257- return this .tcpLoopResources ;
258- }
259-
260264 private static String obfuscate (int length ) {
261265
262266 StringBuilder builder = new StringBuilder ();
@@ -285,7 +289,7 @@ public static final class Builder {
285289 @ Nullable
286290 private String database ;
287291
288- private List <Extension > extensions = new ArrayList <>();
292+ private final List <Extension > extensions = new ArrayList <>();
289293
290294 private ToIntFunction <String > fetchSize = sql -> NO_LIMIT ;
291295
@@ -332,7 +336,7 @@ public static final class Builder {
332336 private boolean tcpNoDelay = false ;
333337
334338 @ Nullable
335- private LoopResources tcpLoopResources = null ;
339+ private LoopResources loopResources = null ;
336340
337341 @ Nullable
338342 private String username ;
@@ -383,9 +387,8 @@ public PostgresqlConnectionConfiguration build() {
383387 }
384388
385389 return new PostgresqlConnectionConfiguration (this .applicationName , this .autodetectExtensions , this .connectTimeout , this .database , this .extensions , this .fetchSize , this .forceBinary ,
386- this .host , this .options , this .password , this .port , this .preparedStatementCacheQueries , this .schema , this .socket , this .tcpKeepAlive , this .tcpNoDelay , this .username ,
387- this .createSslConfig ()
388- , this .tcpLoopResources );
390+ this .host , this .loopResources , this .options , this .password , this .port , this .preparedStatementCacheQueries , this .schema , this .socket , this .createSslConfig (), this .tcpKeepAlive ,
391+ this .tcpNoDelay , this .username );
389392 }
390393
391394 /**
@@ -492,6 +495,18 @@ public Builder host(String host) {
492495 return this ;
493496 }
494497
498+ /**
499+ * Configure {@link LoopResources}.
500+ *
501+ * @param loopResources the {@link LoopResources}
502+ * @return this {@link Builder}
503+ * @since 0.8.5
504+ */
505+ public Builder loopResources (LoopResources loopResources ) {
506+ this .loopResources = Assert .requireNonNull (loopResources , "loopResources must not be null" );
507+ return this ;
508+ }
509+
495510 /**
496511 * Configure connection initialization parameters.
497512 * <p>
@@ -692,18 +707,6 @@ public Builder username(String username) {
692707 return this ;
693708 }
694709
695- /**
696- * Configure TCP {@link LoopResources}.
697- *
698- * @param loopResources the {@link LoopResources}
699- * @return this {@link Builder}
700- * @since 1.0.0
701- */
702- public Builder tcpLoopResources (LoopResources loopResources ) {
703- this .tcpLoopResources = Assert .requireNonNull (loopResources , "tcpLoopResources must not be null" );
704- return this ;
705- }
706-
707710 @ Override
708711 public String toString () {
709712 return "Builder{" +
@@ -715,6 +718,7 @@ public String toString() {
715718 ", fetchSize='" + this .fetchSize + '\'' +
716719 ", forceBinary='" + this .forceBinary + '\'' +
717720 ", host='" + this .host + '\'' +
721+ ", loopResources='" + this .loopResources + '\'' +
718722 ", parameters='" + this .options + '\'' +
719723 ", password='" + obfuscate (this .password != null ? this .password .length () : 0 ) + '\'' +
720724 ", port=" + this .port +
0 commit comments