@@ -77,6 +77,8 @@ public final class PostgresqlConnectionConfiguration {
77
77
78
78
private final int port ;
79
79
80
+ private final int preparedStatementCacheQueries ;
81
+
80
82
private final String socket ;
81
83
82
84
private final String username ;
@@ -87,12 +89,10 @@ public final class PostgresqlConnectionConfiguration {
87
89
88
90
private final boolean tcpNoDelay ;
89
91
90
- private final int preparedStatementCacheQueries ;
91
-
92
92
private PostgresqlConnectionConfiguration (String applicationName , boolean autodetectExtensions , @ Nullable Duration connectTimeout , @ Nullable String database , List <Extension > extensions ,
93
93
ToIntFunction <String > fetchSize , boolean forceBinary , @ Nullable String host , @ Nullable Map <String , String > options , @ Nullable CharSequence password ,
94
- int port , @ Nullable String schema , @ Nullable String socket , boolean tcpKeepAlive , boolean tcpNoDelay , String username , SSLConfig sslConfig ,
95
- int preparedStatementCacheQueries ) {
94
+ int port , int preparedStatementCacheQueries , @ Nullable String schema , @ Nullable String socket , boolean tcpKeepAlive , boolean tcpNoDelay ,
95
+ String username , SSLConfig sslConfig ) {
96
96
this .applicationName = Assert .requireNonNull (applicationName , "applicationName must not be null" );
97
97
this .autodetectExtensions = autodetectExtensions ;
98
98
this .connectTimeout = connectTimeout ;
@@ -109,12 +109,12 @@ private PostgresqlConnectionConfiguration(String applicationName, boolean autode
109
109
110
110
this .password = password ;
111
111
this .port = port ;
112
+ this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
112
113
this .socket = socket ;
113
114
this .username = Assert .requireNonNull (username , "username must not be null" );
114
115
this .sslConfig = sslConfig ;
115
116
this .tcpKeepAlive = tcpKeepAlive ;
116
117
this .tcpNoDelay = tcpNoDelay ;
117
- this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
118
118
}
119
119
120
120
/**
@@ -201,6 +201,10 @@ int getPort() {
201
201
return this .port ;
202
202
}
203
203
204
+ int getPreparedStatementCacheQueries () {
205
+ return this .preparedStatementCacheQueries ;
206
+ }
207
+
204
208
@ Nullable
205
209
String getSocket () {
206
210
return this .socket ;
@@ -240,15 +244,10 @@ boolean isTcpNoDelay() {
240
244
boolean isUseSocket () {
241
245
return getSocket () != null ;
242
246
}
243
-
244
247
SSLConfig getSslConfig () {
245
248
return this .sslConfig ;
246
249
}
247
250
248
- int getPreparedStatementCacheQueries () {
249
- return this .preparedStatementCacheQueries ;
250
- }
251
-
252
251
private static String obfuscate (int length ) {
253
252
254
253
StringBuilder builder = new StringBuilder ();
@@ -293,6 +292,8 @@ public static final class Builder {
293
292
294
293
private int port = DEFAULT_PORT ;
295
294
295
+ private int preparedStatementCacheQueries = -1 ;
296
+
296
297
@ Nullable
297
298
private String schema ;
298
299
@@ -324,8 +325,6 @@ public static final class Builder {
324
325
@ Nullable
325
326
private String username ;
326
327
327
- private int preparedStatementCacheQueries = -1 ;
328
-
329
328
private Builder () {
330
329
}
331
330
@@ -372,8 +371,9 @@ public PostgresqlConnectionConfiguration build() {
372
371
}
373
372
374
373
return new PostgresqlConnectionConfiguration (this .applicationName , this .autodetectExtensions , this .connectTimeout , this .database , this .extensions , this .fetchSize , this .forceBinary ,
375
- this .host , this .options , this .password , this .port , this .schema , this .socket , this .tcpKeepAlive , this .tcpNoDelay , this .username , this .createSslConfig (),
376
- this .preparedStatementCacheQueries );
374
+ this .host , this .options , this .password , this .port , this .preparedStatementCacheQueries , this .schema , this .socket , this .tcpKeepAlive , this .tcpNoDelay , this .username ,
375
+ this .createSslConfig ()
376
+ );
377
377
}
378
378
379
379
/**
@@ -525,6 +525,19 @@ public Builder port(int port) {
525
525
return this ;
526
526
}
527
527
528
+ /**
529
+ * Configure the preparedStatementCacheQueries. The default is {@code -1}, meaning there's no limit. The value of {@code 0} disables the cache. Any other value specifies the cache size.
530
+ *
531
+ * @param preparedStatementCacheQueries the preparedStatementCacheQueries
532
+ * @return this {@link Builder}
533
+ * @throws IllegalArgumentException if {@code username} is {@code null}
534
+ * @since 0.8.1
535
+ */
536
+ public Builder preparedStatementCacheQueries (int preparedStatementCacheQueries ) {
537
+ this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
538
+ return this ;
539
+ }
540
+
528
541
/**
529
542
* Configure the schema.
530
543
*
@@ -667,19 +680,6 @@ public Builder username(String username) {
667
680
return this ;
668
681
}
669
682
670
- /**
671
- * Configure the preparedStatementCacheQueries. The default is {@code -1}, meaning there's no limit. The value of {@code 0} disables the cache. Any other value specifies the cache size.
672
- *
673
- * @param preparedStatementCacheQueries the preparedStatementCacheQueries
674
- * @return this {@link Builder}
675
- * @throws IllegalArgumentException if {@code username} is {@code null}
676
- * @since 0.8.1
677
- */
678
- public Builder preparedStatementCacheQueries (int preparedStatementCacheQueries ) {
679
- this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
680
- return this ;
681
- }
682
-
683
683
@ Override
684
684
public String toString () {
685
685
return "Builder{" +
@@ -694,8 +694,8 @@ public String toString() {
694
694
", parameters='" + this .options + '\'' +
695
695
", password='" + obfuscate (this .password != null ? this .password .length () : 0 ) + '\'' +
696
696
", port=" + this .port +
697
+ ", preparedStatementCacheQueries='" + this .preparedStatementCacheQueries + '\'' +
697
698
", schema='" + this .schema + '\'' +
698
- ", username='" + this .username + '\'' +
699
699
", socket='" + this .socket + '\'' +
700
700
", sslContextBuilderCustomizer='" + this .sslContextBuilderCustomizer + '\'' +
701
701
", sslMode='" + this .sslMode + '\'' +
@@ -705,7 +705,7 @@ public String toString() {
705
705
", sslHostnameVerifier='" + this .sslHostnameVerifier + '\'' +
706
706
", tcpKeepAlive='" + this .tcpKeepAlive + '\'' +
707
707
", tcpNoDelay='" + this .tcpNoDelay + '\'' +
708
- ", preparedStatementCacheQueries ='" + this .preparedStatementCacheQueries + '\'' +
708
+ ", username ='" + this .username + '\'' +
709
709
'}' ;
710
710
}
711
711
0 commit comments