Skip to content

Commit 2593d90

Browse files
committed
Add code formatter
1 parent a7c8bb6 commit 2593d90

38 files changed

Lines changed: 421 additions & 421 deletions

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@
128128
<goals>deploy</goals>
129129
</configuration>
130130
</plugin>
131+
<plugin>
132+
<groupId>com.hubspot.maven.plugins</groupId>
133+
<artifactId>prettier-maven-plugin</artifactId>
134+
<version>0.8</version>
135+
<configuration>
136+
<useTabs>true</useTabs>
137+
</configuration>
138+
</plugin>
131139
</plugins>
132140
</build>
133141

src/main/java/com/github/jonathanhds/sqlbuilder/Context.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.jonathanhds.sqlbuilder;
22

33
import com.github.jonathanhds.sqlbuilder.select.RowMapper;
4-
54
import java.sql.Connection;
65
import java.sql.PreparedStatement;
76
import java.sql.ResultSet;
@@ -13,7 +12,6 @@
1312
import java.util.logging.Logger;
1413

1514
public class Context {
16-
1715
private static final String NEW_LINE = System.getProperty("line.separator");
1816

1917
private final Connection connection;
@@ -24,7 +22,7 @@ public class Context {
2422

2523
private final Database database;
2624

27-
private transient final Logger log;
25+
private final transient Logger log;
2826

2927
{
3028
this.log = Logger.getLogger(getClass().getName());
@@ -120,5 +118,4 @@ private PreparedStatement prepareStatement(String sql) throws SQLException {
120118

121119
return statement;
122120
}
123-
124-
}
121+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.jonathanhds.sqlbuilder;
22

33
public enum Database {
4-
ORACLE, HSQLDB
5-
}
4+
ORACLE,
5+
HSQLDB
6+
}

src/main/java/com/github/jonathanhds/sqlbuilder/IllegalQueryException.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.github.jonathanhds.sqlbuilder;
22

33
public class IllegalQueryException extends RuntimeException {
4-
54
private static final long serialVersionUID = -4847411495350655382L;
65

7-
public IllegalQueryException() {
8-
}
6+
public IllegalQueryException() {}
97

108
public IllegalQueryException(String message, Throwable cause) {
119
super(message, cause);
@@ -18,5 +16,4 @@ public IllegalQueryException(String message) {
1816
public IllegalQueryException(Throwable cause) {
1917
super(cause);
2018
}
21-
2219
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.github.jonathanhds.sqlbuilder;
22

33
import com.github.jonathanhds.sqlbuilder.select.RowMapper;
4-
54
import java.sql.SQLException;
65
import java.util.List;
76

87
public interface TerminalExpression {
9-
108
<E> List<E> list(RowMapper<E> rowMapper) throws SQLException;
119

1210
<E> E single(RowMapper<E> rowMapper) throws SQLException;
13-
}
11+
}

src/main/java/com/github/jonathanhds/sqlbuilder/builder/QueryBuilder.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
import com.github.jonathanhds.sqlbuilder.insert.Insert;
77
import com.github.jonathanhds.sqlbuilder.select.Select;
88
import com.github.jonathanhds.sqlbuilder.update.Update;
9-
10-
import javax.sql.DataSource;
119
import java.sql.Connection;
1210
import java.sql.SQLException;
11+
import javax.sql.DataSource;
1312

1413
public class QueryBuilder {
15-
1614
private final Context context;
1715

18-
public QueryBuilder(Database database, DataSource dataSource) throws SQLException {
16+
public QueryBuilder(Database database, DataSource dataSource)
17+
throws SQLException {
1918
this(database, dataSource.getConnection());
2019
}
2120

@@ -55,4 +54,4 @@ public Insert insert(String table) {
5554
public String toString() {
5655
return context.toString();
5756
}
58-
}
57+
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.github.jonathanhds.sqlbuilder.builder;
22

33
import com.github.jonathanhds.sqlbuilder.Database;
4-
5-
import javax.sql.DataSource;
64
import java.sql.Connection;
75
import java.sql.SQLException;
6+
import javax.sql.DataSource;
87

98
public class QueryBuilderHSQLDB extends QueryBuilder {
109

@@ -15,5 +14,4 @@ public QueryBuilderHSQLDB(Connection connection) {
1514
public QueryBuilderHSQLDB(DataSource dataSource) throws SQLException {
1615
super(Database.HSQLDB, dataSource);
1716
}
18-
19-
}
17+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.github.jonathanhds.sqlbuilder.builder;
22

33
import com.github.jonathanhds.sqlbuilder.Database;
4-
5-
import javax.sql.DataSource;
64
import java.sql.Connection;
75
import java.sql.SQLException;
6+
import javax.sql.DataSource;
87

98
public class QueryBuilderOracle extends QueryBuilder {
109

@@ -15,5 +14,4 @@ public QueryBuilderOracle(Connection connection) {
1514
public QueryBuilderOracle(DataSource dataSource) throws SQLException {
1615
super(Database.ORACLE, dataSource);
1716
}
18-
1917
}

src/main/java/com/github/jonathanhds/sqlbuilder/delete/Delete.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
import com.github.jonathanhds.sqlbuilder.Context;
44
import com.github.jonathanhds.sqlbuilder.IllegalQueryException;
5-
import org.apache.commons.lang.StringUtils;
6-
75
import java.util.Collection;
86
import java.util.Iterator;
97
import java.util.LinkedList;
10-
8+
import org.apache.commons.lang.StringUtils;
119

1210
public class Delete {
13-
1411
private String table;
1512
private final Context context;
1613
private final Collection<String> conditions;
@@ -38,7 +35,9 @@ public Delete and(String condition) {
3835
}
3936

4037
private void terminate() {
41-
if (StringUtils.isBlank(table)) throw new IllegalQueryException("No table specified!");
38+
if (StringUtils.isBlank(table)) throw new IllegalQueryException(
39+
"No table specified!"
40+
);
4241

4342
if (!terminated) {
4443
context.append(table);
@@ -67,4 +66,4 @@ public String toString() {
6766
terminate();
6867
return context.toString();
6968
}
70-
}
69+
}

src/main/java/com/github/jonathanhds/sqlbuilder/insert/Insert.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import com.github.jonathanhds.sqlbuilder.Context;
44
import com.github.jonathanhds.sqlbuilder.IllegalQueryException;
5-
import org.apache.commons.lang.StringUtils;
6-
75
import java.util.Collections;
86
import java.util.LinkedList;
97
import java.util.List;
8+
import org.apache.commons.lang.StringUtils;
109

1110
public class Insert {
12-
1311
private String table;
1412
private final List<String> columns;
1513
private final List<Object[]> values;
@@ -50,22 +48,29 @@ public String toString() {
5048
}
5149

5250
private void terminate() {
53-
if (columns.isEmpty()) throw new IllegalQueryException("No columns informed!");
54-
if (values.isEmpty()) throw new IllegalQueryException("No values informed!");
51+
if (columns.isEmpty()) throw new IllegalQueryException(
52+
"No columns informed!"
53+
);
54+
if (values.isEmpty()) throw new IllegalQueryException(
55+
"No values informed!"
56+
);
5557

5658
for (Object[] valueSet : values) {
5759
if (valueSet.length != columns.size()) {
58-
throw new IllegalQueryException("Value size different from column size!");
60+
throw new IllegalQueryException(
61+
"Value size different from column size!"
62+
);
5963
}
6064
}
6165

6266
if (!terminated) {
63-
context.appendLine(table)
64-
.append(" ( ")
65-
.append(StringUtils.join(columns, ", "))
66-
.appendLine(" )")
67-
.append("VALUES ")
68-
.append(StringUtils.join(getValues(), ", "));
67+
context
68+
.appendLine(table)
69+
.append(" ( ")
70+
.append(StringUtils.join(columns, ", "))
71+
.appendLine(" )")
72+
.append("VALUES ")
73+
.append(StringUtils.join(getValues(), ", "));
6974
}
7075
}
7176

@@ -93,4 +98,4 @@ private String toValue(Object[] objs) {
9398

9499
return "(" + StringUtils.join(result, ", ") + ")";
95100
}
96-
}
101+
}

0 commit comments

Comments
 (0)