@@ -34,6 +34,8 @@ public final class PostgresqlConnectionConfiguration {
3434
3535 private final String applicationName ;
3636
37+ private final Duration connectTimeout ;
38+
3739 private final String database ;
3840
3941 private final String host ;
@@ -46,18 +48,17 @@ public final class PostgresqlConnectionConfiguration {
4648
4749 private final String username ;
4850
49- private final Duration connectTimeout ;
51+ private PostgresqlConnectionConfiguration (String applicationName , @ Nullable Duration connectTimeout , @ Nullable String database , String host , String password , int port , @ Nullable String schema ,
52+ String username ) {
5053
51- private PostgresqlConnectionConfiguration (String applicationName , @ Nullable String database , String host , String password , int port , @ Nullable String schema , String username ,
52- Duration connectTimeout ) {
5354 this .applicationName = Assert .requireNonNull (applicationName , "applicationName must not be null" );
55+ this .connectTimeout = connectTimeout ;
5456 this .database = database ;
5557 this .host = Assert .requireNonNull (host , "host must not be null" );
5658 this .password = Assert .requireNonNull (password , "password must not be null" );
5759 this .port = port ;
5860 this .schema = schema ;
5961 this .username = Assert .requireNonNull (username , "username must not be null" );
60- this .connectTimeout = connectTimeout ;
6162 }
6263
6364 /**
@@ -71,22 +72,27 @@ public static Builder builder() {
7172
7273 @ Override
7374 public String toString () {
74- return "PostgresConnectionConfiguration {" +
75+ return "PostgresqlConnectionConfiguration {" +
7576 "applicationName='" + this .applicationName + '\'' +
77+ ", connectTimeout=" + this .connectTimeout +
7678 ", database='" + this .database + '\'' +
7779 ", host='" + this .host + '\'' +
7880 ", password='" + this .password + '\'' +
7981 ", port=" + this .port +
8082 ", schema='" + this .schema + '\'' +
8183 ", username='" + this .username + '\'' +
82- ", connectTimeout='" + this .connectTimeout + '\'' +
8384 '}' ;
8485 }
8586
8687 String getApplicationName () {
8788 return this .applicationName ;
8889 }
8990
91+ @ Nullable
92+ Duration getConnectTimeout () {
93+ return this .connectTimeout ;
94+ }
95+
9096 @ Nullable
9197 String getDatabase () {
9298 return this .database ;
@@ -113,11 +119,6 @@ String getUsername() {
113119 return this .username ;
114120 }
115121
116- @ Nullable
117- Duration getConnectTimeout () {
118- return this .connectTimeout ;
119- }
120-
121122 /**
122123 * A builder for {@link PostgresqlConnectionConfiguration} instances.
123124 * <p>
@@ -127,6 +128,8 @@ public static final class Builder {
127128
128129 private String applicationName = "r2dbc-postgresql" ;
129130
131+ private Duration connectTimeout ;
132+
130133 private String database ;
131134
132135 private String host ;
@@ -139,8 +142,6 @@ public static final class Builder {
139142
140143 private String username ;
141144
142- private Duration connectTimeout ;
143-
144145 private Builder () {
145146 }
146147
@@ -162,7 +163,12 @@ public Builder applicationName(String applicationName) {
162163 * @return a configured {@link PostgresqlConnectionConfiguration}
163164 */
164165 public PostgresqlConnectionConfiguration build () {
165- return new PostgresqlConnectionConfiguration (this .applicationName , this .database , this .host , this .password , this .port , this .schema , this .username , this .connectTimeout );
166+ return new PostgresqlConnectionConfiguration (this .applicationName , this .connectTimeout , this .database , this .host , this .password , this .port , this .schema , this .username );
167+ }
168+
169+ public Builder connectTimeout (@ Nullable Duration connectTimeout ) {
170+ this .connectTimeout = connectTimeout ;
171+ return this ;
166172 }
167173
168174 /**
@@ -222,22 +228,17 @@ public Builder schema(@Nullable String schema) {
222228 return this ;
223229 }
224230
225- public Builder connectTimeout (@ Nullable Duration connectTimeout ) {
226- this .connectTimeout = connectTimeout ;
227- return this ;
228- }
229-
230231 @ Override
231232 public String toString () {
232233 return "Builder{" +
233234 "applicationName='" + this .applicationName + '\'' +
235+ ", connectTimeout='" + this .connectTimeout + '\'' +
234236 ", database='" + this .database + '\'' +
235237 ", host='" + this .host + '\'' +
236238 ", password='" + this .password + '\'' +
237239 ", port=" + this .port +
238240 ", schema='" + this .schema + '\'' +
239241 ", username='" + this .username + '\'' +
240- ", connectTimeout='" + this .connectTimeout + '\'' +
241242 '}' ;
242243 }
243244
0 commit comments