Skip to content

Commit 7c66eb1

Browse files
author
zhangkenan
committed
use './gradlew :spotlessApply' adjust code format.
1 parent 48f905e commit 7c66eb1

File tree

8 files changed

+33
-19
lines changed

8 files changed

+33
-19
lines changed

src/main/java/net/sf/jsqlparser/statement/insert/ConflictActionType.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
package net.sf.jsqlparser.statement.insert;
1111

1212
public enum ConflictActionType {
13-
NOTHING,
14-
DO_NOTHING,
15-
DO_UPDATE;
13+
NOTHING, DO_NOTHING, DO_UPDATE;
1614

1715
public static ConflictActionType from(String type) {
1816
return Enum.valueOf(ConflictActionType.class, type.toUpperCase());

src/main/java/net/sf/jsqlparser/statement/insert/Insert.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ public boolean isUseSelectBrackets() {
167167

168168
@Deprecated
169169
public boolean isUseDuplicate() {
170-
return duplicateAction != null && duplicateAction.getUpdateSets() != null && !duplicateAction.getUpdateSets().isEmpty();
170+
return duplicateAction != null && duplicateAction.getUpdateSets() != null
171+
&& !duplicateAction.getUpdateSets().isEmpty();
171172
}
172173

173174
public InsertModifierPriority getModifierPriority() {
@@ -273,7 +274,7 @@ public String toString() {
273274
StringBuilder sql = new StringBuilder();
274275
if (withItemsList != null && !withItemsList.isEmpty()) {
275276
sql.append("WITH ");
276-
for (Iterator<WithItem<?>> iter = withItemsList.iterator(); iter.hasNext(); ) {
277+
for (Iterator<WithItem<?>> iter = withItemsList.iterator(); iter.hasNext();) {
277278
WithItem<?> withItem = iter.next();
278279
sql.append(withItem);
279280
if (iter.hasNext()) {
@@ -397,7 +398,8 @@ public Insert addColumns(Column... columns) {
397398
}
398399

399400
public Insert addColumns(Collection<Column> columns) {
400-
ExpressionList<Column> collection = Optional.ofNullable(getColumns()).orElseGet(ExpressionList::new);
401+
ExpressionList<Column> collection =
402+
Optional.ofNullable(getColumns()).orElseGet(ExpressionList::new);
401403
collection.addAll(columns);
402404
return this.withColumns(collection);
403405
}

src/main/java/net/sf/jsqlparser/statement/insert/InsertDuplicateAction.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
/**
2323
* on duplicate key is one of:
2424
*
25-
* ON DUPLICATE KEY UPDATE NOTHING ON DUPLICATE KEY UPDATE { column_name = { expression | DEFAULT } | ( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT
26-
* } [, ...] ) | ( column_name [, ...] ) = ( sub-SELECT ) } [, ...] [ WHERE condition ]
25+
* ON DUPLICATE KEY UPDATE NOTHING ON DUPLICATE KEY UPDATE { column_name = { expression | DEFAULT }
26+
* | ( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT } [, ...] ) | ( column_name [, ...]
27+
* ) = ( sub-SELECT ) } [, ...] [ WHERE condition ]
2728
*
2829
* @author zhangconan
2930
*/
@@ -34,7 +35,8 @@ public class InsertDuplicateAction implements Serializable {
3435
private List<UpdateSet> updateSets;
3536

3637
public InsertDuplicateAction(ConflictActionType conflictActionType) {
37-
this.conflictActionType = Objects.requireNonNull(conflictActionType, "The Conflict Action Type is mandatory and must not be Null.");
38+
this.conflictActionType = Objects.requireNonNull(conflictActionType,
39+
"The Conflict Action Type is mandatory and must not be Null.");
3840
}
3941

4042
public List<UpdateSet> getUpdateSets() {
@@ -55,7 +57,8 @@ public ConflictActionType getConflictActionType() {
5557
}
5658

5759
public void setConflictActionType(ConflictActionType conflictActionType) {
58-
this.conflictActionType = Objects.requireNonNull(conflictActionType, "The Conflict Action Type is mandatory and must not be Null.");
60+
this.conflictActionType = Objects.requireNonNull(conflictActionType,
61+
"The Conflict Action Type is mandatory and must not be Null.");
5962
}
6063

6164
public InsertDuplicateAction withConflictActionType(ConflictActionType conflictActionType) {

src/main/java/net/sf/jsqlparser/statement/upsert/Upsert.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ public Upsert addColumns(Column... columns) {
226226
}
227227

228228
public Upsert addColumns(Collection<? extends Column> columns) {
229-
ExpressionList<Column> collection = Optional.ofNullable(getColumns()).orElseGet(ExpressionList::new);
229+
ExpressionList<Column> collection =
230+
Optional.ofNullable(getColumns()).orElseGet(ExpressionList::new);
230231
collection.addAll(columns);
231232
return this.withColumns(collection);
232233
}

src/main/java/net/sf/jsqlparser/util/deparser/InsertDeParser.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ public InsertDeParser() {
2929
super(new StringBuilder());
3030
}
3131

32-
public InsertDeParser(ExpressionVisitor<StringBuilder> expressionVisitor, SelectVisitor<StringBuilder> selectVisitor, StringBuilder buffer) {
32+
public InsertDeParser(ExpressionVisitor<StringBuilder> expressionVisitor,
33+
SelectVisitor<StringBuilder> selectVisitor, StringBuilder buffer) {
3334
super(buffer);
3435
this.expressionVisitor = expressionVisitor;
3536
this.selectVisitor = selectVisitor;
3637
}
3738

3839
@Override
39-
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.ExcessiveMethodLength", "PMD.NPathComplexity"})
40+
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.ExcessiveMethodLength",
41+
"PMD.NPathComplexity"})
4042
public void deParse(Insert insert) {
4143
if (insert.getWithItemsList() != null && !insert.getWithItemsList().isEmpty()) {
4244
builder.append("WITH ");
43-
for (Iterator<WithItem<?>> iter = insert.getWithItemsList().iterator(); iter.hasNext(); ) {
45+
for (Iterator<WithItem<?>> iter = insert.getWithItemsList().iterator(); iter
46+
.hasNext();) {
4447
WithItem<?> withItem = iter.next();
4548
withItem.accept(this.selectVisitor, null);
4649
if (iter.hasNext()) {
@@ -77,7 +80,7 @@ public void deParse(Insert insert) {
7780

7881
if (insert.getColumns() != null) {
7982
builder.append(" (");
80-
for (Iterator<Column> iter = insert.getColumns().iterator(); iter.hasNext(); ) {
83+
for (Iterator<Column> iter = insert.getColumns().iterator(); iter.hasNext();) {
8184
Column column = iter.next();
8285
builder.append(column.getColumnName());
8386
if (iter.hasNext()) {
@@ -114,7 +117,8 @@ public void deParse(Insert insert) {
114117

115118
if (insert.getDuplicateAction() != null) {
116119
builder.append(" ON DUPLICATE KEY UPDATE ");
117-
if (ConflictActionType.DO_UPDATE.equals(insert.getDuplicateAction().getConflictActionType())) {
120+
if (ConflictActionType.DO_UPDATE
121+
.equals(insert.getDuplicateAction().getConflictActionType())) {
118122
deparseUpdateSets(insert.getDuplicateUpdateSets(), builder, expressionVisitor);
119123
} else {
120124
insert.getDuplicateAction().appendTo(builder);

src/main/java/net/sf/jsqlparser/util/deparser/UpsertDeParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public class UpsertDeParser extends AbstractDeParser<Upsert> {
2020
private ExpressionDeParser expressionVisitor;
2121
private SelectDeParser selectVisitor;
2222

23-
public UpsertDeParser(ExpressionDeParser expressionVisitor, SelectDeParser selectVisitor, StringBuilder buffer) {
23+
public UpsertDeParser(ExpressionDeParser expressionVisitor, SelectDeParser selectVisitor,
24+
StringBuilder buffer) {
2425
super(buffer);
2526
this.expressionVisitor = expressionVisitor;
2627
this.expressionVisitor.setSelectVisitor(selectVisitor);
@@ -80,7 +81,8 @@ public void deParse(Upsert upsert) {
8081

8182
if (upsert.getDuplicateAction() != null) {
8283
builder.append(" ON DUPLICATE KEY UPDATE ");
83-
if (ConflictActionType.DO_UPDATE.equals(upsert.getDuplicateAction().getConflictActionType())) {
84+
if (ConflictActionType.DO_UPDATE
85+
.equals(upsert.getDuplicateAction().getConflictActionType())) {
8486
deparseUpdateSets(upsert.getDuplicateUpdateSets(), builder, expressionVisitor);
8587
} else {
8688
upsert.getDuplicateAction().appendTo(builder);

src/test/java/net/sf/jsqlparser/statement/insert/InsertTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ void insertDemo() {
916916
TestUtils.assertStatementCanBeDeparsedAs(
917917
insert, "INSERT INTO test VALUES ('A', 'B')");
918918
}
919+
919920
@Test
920921
public void testSimpleDuplicateInsert() throws JSQLParserException {
921922
assertSqlCanBeParsedAndDeparsed(

src/test/java/net/sf/jsqlparser/statement/upsert/UpsertTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,14 @@ public void testUpsertMultiRowValue() throws JSQLParserException {
107107
assertSqlCanBeParsedAndDeparsed("UPSERT INTO mytable (col1, col2) VALUES (a, b), (d, e)",
108108
true);
109109
}
110+
110111
@Test
111112
public void testUpsertMultiRowValueDoNothing() throws JSQLParserException {
112-
assertSqlCanBeParsedAndDeparsed("UPSERT INTO mytable (col1, col2) VALUES (a, b) ON DUPLICATE KEY UPDATE nothing",
113+
assertSqlCanBeParsedAndDeparsed(
114+
"UPSERT INTO mytable (col1, col2) VALUES (a, b) ON DUPLICATE KEY UPDATE nothing",
113115
true);
114116
}
117+
115118
@Test
116119
@Disabled
117120
/* not the job of the parser to validate this, it even may be valid eventually */

0 commit comments

Comments
 (0)