Skip to content

Commit 28f6820

Browse files
authored
Merge pull request #623 from aguibert/db2-source-formatting
Apply source formatting for DB2 module
2 parents 93e6e0f + ce85ec3 commit 28f6820

39 files changed

+1965
-2028
lines changed

vertx-db2-client/src/main/java/examples/DB2ClientExamples.java

Lines changed: 281 additions & 261 deletions
Large diffs are not rendered by default.

vertx-db2-client/src/main/java/examples/SqlClientExamples.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
*/
1616
package examples;
1717

18+
import java.util.ArrayList;
19+
import java.util.List;
20+
1821
import io.vertx.core.Vertx;
1922
import io.vertx.docgen.Source;
2023
import io.vertx.sqlclient.Cursor;
2124
import io.vertx.sqlclient.Pool;
22-
import io.vertx.sqlclient.PoolOptions;
2325
import io.vertx.sqlclient.PreparedStatement;
2426
import io.vertx.sqlclient.Row;
2527
import io.vertx.sqlclient.RowSet;
@@ -30,9 +32,6 @@
3032
import io.vertx.sqlclient.Transaction;
3133
import io.vertx.sqlclient.Tuple;
3234

33-
import java.util.ArrayList;
34-
import java.util.List;
35-
3635
@Source
3736
public class SqlClientExamples {
3837

vertx-db2-client/src/main/java/io/vertx/db2client/DB2ConnectOptions.java

Lines changed: 174 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -33,175 +33,183 @@
3333
*/
3434
@DataObject(generateConverter = true)
3535
public class DB2ConnectOptions extends SqlConnectOptions {
36-
37-
/**
38-
* Provide a {@link DB2ConnectOptions} configured from a connection URI.
39-
*
40-
* @param connectionUri the connection URI to configure from
41-
* @return a {@link DB2ConnectOptions} parsed from the connection URI
42-
* @throws IllegalArgumentException when the {@code connectionUri} is in an invalid format
43-
*/
44-
public static DB2ConnectOptions fromUri(String connectionUri) throws IllegalArgumentException {
45-
JsonObject parsedConfiguration = DB2ConnectionUriParser.parse(connectionUri);
46-
return new DB2ConnectOptions(parsedConfiguration);
47-
}
48-
49-
public static final String DEFAULT_HOST = "localhost";
50-
public static final int DEFAULT_PORT = 50000;
51-
public static final String DEFAULT_CHARSET = "utf8";
52-
public static final boolean DEFAULT_USE_AFFECTED_ROWS = false;
53-
public static final int DEFAULT_PIPELINING_LIMIT = 1; //256; // TODO default to 256 once implemented properly
54-
public static final Map<String, String> DEFAULT_CONNECTION_ATTRIBUTES;
55-
56-
static {
57-
Map<String, String> defaultAttributes = new HashMap<>();
58-
defaultAttributes.put("_client_name", "vertx-db2-client");
59-
DEFAULT_CONNECTION_ATTRIBUTES = Collections.unmodifiableMap(defaultAttributes);
60-
}
61-
62-
private int pipeliningLimit = DEFAULT_PIPELINING_LIMIT;
63-
64-
public DB2ConnectOptions() {
65-
super();
66-
}
67-
68-
public DB2ConnectOptions(String uri) {
69-
super();
70-
throw new UnsupportedOperationException("TODO @AGG need to implement uri parsing");
71-
}
72-
73-
public DB2ConnectOptions(JsonObject json) {
74-
super(json);
75-
DB2ConnectOptionsConverter.fromJson(json, this);
76-
}
77-
78-
public DB2ConnectOptions(SqlConnectOptions other) {
79-
super(other);
80-
if (other instanceof DB2ConnectOptions) {
81-
DB2ConnectOptions opts = (DB2ConnectOptions) other;
82-
this.pipeliningLimit = opts.pipeliningLimit;
83-
}
84-
}
85-
86-
public DB2ConnectOptions(DB2ConnectOptions other) {
87-
super(other);
88-
this.pipeliningLimit = other.pipeliningLimit;
89-
}
90-
91-
@Override
92-
public DB2ConnectOptions setHost(String host) {
93-
return (DB2ConnectOptions) super.setHost(host);
94-
}
95-
96-
@Override
97-
public DB2ConnectOptions setPort(int port) {
98-
return (DB2ConnectOptions) super.setPort(port);
99-
}
100-
101-
@Override
102-
public DB2ConnectOptions setUser(String user) {
103-
if (user == null || user.length() < 1) {
104-
throw new DB2Exception("The user cannot be blank or null", SqlCode.MISSING_CREDENTIALS, SQLState.CONNECT_USERID_ISNULL);
105-
} else {
106-
return (DB2ConnectOptions) super.setUser(user);
107-
}
108-
}
109-
110-
@Override
111-
public DB2ConnectOptions setPassword(String password) {
112-
if (password == null || password.length() < 1) {
113-
throw new DB2Exception("The password cannot be blank or null", SqlCode.MISSING_CREDENTIALS, SQLState.CONNECT_PASSWORD_ISNULL);
114-
} else {
115-
return (DB2ConnectOptions) super.setPassword(password);
116-
}
117-
}
11836

119-
@Override
120-
public DB2ConnectOptions setDatabase(String database) {
121-
if (database == null || database.length() < 1) {
122-
throw new DB2Exception("The database name cannot be blank or null", SqlCode.DATABASE_NOT_FOUND, SQLState.DATABASE_NOT_FOUND);
123-
} else {
124-
return (DB2ConnectOptions) super.setDatabase(database);
125-
}
126-
}
127-
128-
@Override
129-
public DB2ConnectOptions setCachePreparedStatements(boolean cachePreparedStatements) {
130-
return (DB2ConnectOptions) super.setCachePreparedStatements(cachePreparedStatements);
131-
}
132-
133-
@Override
134-
public DB2ConnectOptions setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize) {
135-
return (DB2ConnectOptions) super.setPreparedStatementCacheMaxSize(preparedStatementCacheMaxSize);
136-
}
137-
138-
@Override
139-
public DB2ConnectOptions setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit) {
140-
return (DB2ConnectOptions) super.setPreparedStatementCacheSqlLimit(preparedStatementCacheSqlLimit);
141-
}
142-
143-
public int getPipeliningLimit() {
144-
return pipeliningLimit;
145-
}
146-
147-
/**
148-
* @deprecated UNSTABLE FEATURE: Current default value is 1, anything higher than 1 will
149-
* result in errors currently.
150-
* @param pipeliningLimit the number of commands that can simultaneously use the same
151-
* physical socket connection.
152-
* @return A reference to this, so the API can be used fluently
153-
*/
154-
@GenIgnore
155-
@Deprecated // TODO: Get pipelining working properly, or remove this as API
156-
public DB2ConnectOptions setPipeliningLimit(int pipeliningLimit) {
157-
if (pipeliningLimit < 1) {
158-
throw new IllegalArgumentException();
159-
}
160-
this.pipeliningLimit = pipeliningLimit;
161-
return this;
162-
}
163-
164-
@Override
165-
public DB2ConnectOptions setProperties(Map<String, String> properties) {
166-
return (DB2ConnectOptions) super.setProperties(properties);
167-
}
168-
169-
@GenIgnore
170-
@Override
171-
public DB2ConnectOptions addProperty(String key, String value) {
172-
return (DB2ConnectOptions) super.addProperty(key, value);
173-
}
174-
175-
/**
176-
* Initialize with the default options.
177-
*/
178-
protected void init() {
179-
this.setHost(DEFAULT_HOST);
180-
this.setPort(DEFAULT_PORT);
181-
this.setProperties(new HashMap<>(DEFAULT_CONNECTION_ATTRIBUTES));
182-
}
183-
184-
@Override
185-
public JsonObject toJson() {
186-
JsonObject json = super.toJson();
187-
return json;
188-
}
189-
190-
@Override
191-
public boolean equals(Object o) {
192-
if (this == o) return true;
193-
if (!(o instanceof DB2ConnectOptions)) return false;
194-
if (!super.equals(o)) return false;
37+
/**
38+
* Provide a {@link DB2ConnectOptions} configured from a connection URI.
39+
*
40+
* @param connectionUri the connection URI to configure from
41+
* @return a {@link DB2ConnectOptions} parsed from the connection URI
42+
* @throws IllegalArgumentException when the {@code connectionUri} is in an
43+
* invalid format
44+
*/
45+
public static DB2ConnectOptions fromUri(String connectionUri) throws IllegalArgumentException {
46+
JsonObject parsedConfiguration = DB2ConnectionUriParser.parse(connectionUri);
47+
return new DB2ConnectOptions(parsedConfiguration);
48+
}
49+
50+
public static final String DEFAULT_HOST = "localhost";
51+
public static final int DEFAULT_PORT = 50000;
52+
public static final String DEFAULT_CHARSET = "utf8";
53+
public static final boolean DEFAULT_USE_AFFECTED_ROWS = false;
54+
public static final int DEFAULT_PIPELINING_LIMIT = 1; // 256; // TODO default to 256 once implemented properly
55+
public static final Map<String, String> DEFAULT_CONNECTION_ATTRIBUTES;
56+
57+
static {
58+
Map<String, String> defaultAttributes = new HashMap<>();
59+
defaultAttributes.put("_client_name", "vertx-db2-client");
60+
DEFAULT_CONNECTION_ATTRIBUTES = Collections.unmodifiableMap(defaultAttributes);
61+
}
62+
63+
private int pipeliningLimit = DEFAULT_PIPELINING_LIMIT;
64+
65+
public DB2ConnectOptions() {
66+
super();
67+
}
68+
69+
public DB2ConnectOptions(String uri) {
70+
super();
71+
throw new UnsupportedOperationException("TODO @AGG need to implement uri parsing");
72+
}
73+
74+
public DB2ConnectOptions(JsonObject json) {
75+
super(json);
76+
DB2ConnectOptionsConverter.fromJson(json, this);
77+
}
78+
79+
public DB2ConnectOptions(SqlConnectOptions other) {
80+
super(other);
81+
if (other instanceof DB2ConnectOptions) {
82+
DB2ConnectOptions opts = (DB2ConnectOptions) other;
83+
this.pipeliningLimit = opts.pipeliningLimit;
84+
}
85+
}
86+
87+
public DB2ConnectOptions(DB2ConnectOptions other) {
88+
super(other);
89+
this.pipeliningLimit = other.pipeliningLimit;
90+
}
91+
92+
@Override
93+
public DB2ConnectOptions setHost(String host) {
94+
return (DB2ConnectOptions) super.setHost(host);
95+
}
96+
97+
@Override
98+
public DB2ConnectOptions setPort(int port) {
99+
return (DB2ConnectOptions) super.setPort(port);
100+
}
101+
102+
@Override
103+
public DB2ConnectOptions setUser(String user) {
104+
if (user == null || user.length() < 1) {
105+
throw new DB2Exception("The user cannot be blank or null", SqlCode.MISSING_CREDENTIALS,
106+
SQLState.CONNECT_USERID_ISNULL);
107+
} else {
108+
return (DB2ConnectOptions) super.setUser(user);
109+
}
110+
}
111+
112+
@Override
113+
public DB2ConnectOptions setPassword(String password) {
114+
if (password == null || password.length() < 1) {
115+
throw new DB2Exception("The password cannot be blank or null", SqlCode.MISSING_CREDENTIALS,
116+
SQLState.CONNECT_PASSWORD_ISNULL);
117+
} else {
118+
return (DB2ConnectOptions) super.setPassword(password);
119+
}
120+
}
121+
122+
@Override
123+
public DB2ConnectOptions setDatabase(String database) {
124+
if (database == null || database.length() < 1) {
125+
throw new DB2Exception("The database name cannot be blank or null", SqlCode.DATABASE_NOT_FOUND,
126+
SQLState.DATABASE_NOT_FOUND);
127+
} else {
128+
return (DB2ConnectOptions) super.setDatabase(database);
129+
}
130+
}
131+
132+
@Override
133+
public DB2ConnectOptions setCachePreparedStatements(boolean cachePreparedStatements) {
134+
return (DB2ConnectOptions) super.setCachePreparedStatements(cachePreparedStatements);
135+
}
136+
137+
@Override
138+
public DB2ConnectOptions setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize) {
139+
return (DB2ConnectOptions) super.setPreparedStatementCacheMaxSize(preparedStatementCacheMaxSize);
140+
}
141+
142+
@Override
143+
public DB2ConnectOptions setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit) {
144+
return (DB2ConnectOptions) super.setPreparedStatementCacheSqlLimit(preparedStatementCacheSqlLimit);
145+
}
146+
147+
public int getPipeliningLimit() {
148+
return pipeliningLimit;
149+
}
150+
151+
/**
152+
* @deprecated UNSTABLE FEATURE: Current default value is 1, anything higher
153+
* than 1 will result in errors currently.
154+
* @param pipeliningLimit the number of commands that can simultaneously use the
155+
* same physical socket connection.
156+
* @return A reference to this, so the API can be used fluently
157+
*/
158+
@GenIgnore
159+
@Deprecated // TODO: Get pipelining working properly, or remove this as API
160+
public DB2ConnectOptions setPipeliningLimit(int pipeliningLimit) {
161+
if (pipeliningLimit < 1) {
162+
throw new IllegalArgumentException();
163+
}
164+
this.pipeliningLimit = pipeliningLimit;
165+
return this;
166+
}
167+
168+
@Override
169+
public DB2ConnectOptions setProperties(Map<String, String> properties) {
170+
return (DB2ConnectOptions) super.setProperties(properties);
171+
}
172+
173+
@GenIgnore
174+
@Override
175+
public DB2ConnectOptions addProperty(String key, String value) {
176+
return (DB2ConnectOptions) super.addProperty(key, value);
177+
}
178+
179+
/**
180+
* Initialize with the default options.
181+
*/
182+
protected void init() {
183+
this.setHost(DEFAULT_HOST);
184+
this.setPort(DEFAULT_PORT);
185+
this.setProperties(new HashMap<>(DEFAULT_CONNECTION_ATTRIBUTES));
186+
}
187+
188+
@Override
189+
public JsonObject toJson() {
190+
JsonObject json = super.toJson();
191+
return json;
192+
}
193+
194+
@Override
195+
public boolean equals(Object o) {
196+
if (this == o)
197+
return true;
198+
if (!(o instanceof DB2ConnectOptions))
199+
return false;
200+
if (!super.equals(o))
201+
return false;
195202

196-
DB2ConnectOptions that = (DB2ConnectOptions) o;
203+
DB2ConnectOptions that = (DB2ConnectOptions) o;
197204

198-
if (pipeliningLimit != that.pipeliningLimit) return false;
205+
if (pipeliningLimit != that.pipeliningLimit)
206+
return false;
199207

200-
return true;
201-
}
208+
return true;
209+
}
202210

203-
@Override
204-
public int hashCode() {
205-
return Objects.hash(pipeliningLimit);
206-
}
211+
@Override
212+
public int hashCode() {
213+
return Objects.hash(pipeliningLimit);
214+
}
207215
}

0 commit comments

Comments
 (0)