Skip to content

Commit 89600d4

Browse files
refactor: Insert uses ExpressionList and UpdateSet
1 parent 2d200b0 commit 89600d4

18 files changed

Lines changed: 1927 additions & 1798 deletions

File tree

src/main/java/net/sf/jsqlparser/expression/ArrayConstructor.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@
99
*/
1010
package net.sf.jsqlparser.expression;
1111

12+
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
1213
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
13-
import net.sf.jsqlparser.statement.select.PlainSelect;
14-
15-
import java.util.List;
1614

1715
public class ArrayConstructor extends ASTNodeAccessImpl implements Expression {
18-
private List<Expression> expressions;
16+
private ExpressionList<?> expressions;
1917
private boolean arrayKeyword;
2018

21-
public List<Expression> getExpressions() {
19+
public ExpressionList<?> getExpressions() {
2220
return expressions;
2321
}
2422

25-
public void setExpressions(List<Expression> expressions) {
23+
public void setExpressions(ExpressionList<?> expressions) {
2624
this.expressions = expressions;
2725
}
2826

@@ -34,7 +32,7 @@ public void setArrayKeyword(boolean arrayKeyword) {
3432
this.arrayKeyword = arrayKeyword;
3533
}
3634

37-
public ArrayConstructor(List<Expression> expressions, boolean arrayKeyword) {
35+
public ArrayConstructor(ExpressionList<?> expressions, boolean arrayKeyword) {
3836
this.expressions = expressions;
3937
this.arrayKeyword = arrayKeyword;
4038
}
@@ -51,7 +49,7 @@ public String toString() {
5149
sb.append("ARRAY");
5250
}
5351
sb.append("[");
54-
sb.append(PlainSelect.getStringList(expressions, true, false));
52+
sb.append(expressions.toString());
5553
sb.append("]");
5654
return sb.toString();
5755
}

src/main/java/net/sf/jsqlparser/expression/TimezoneExpression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
*/
1010
package net.sf.jsqlparser.expression;
1111

12+
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
1213
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
1314

14-
import java.util.ArrayList;
1515
import java.util.List;
1616

1717
public class TimezoneExpression extends ASTNodeAccessImpl implements Expression {
1818

1919
private Expression leftExpression;
20-
private ArrayList<Expression> timezoneExpressions = new ArrayList<>();
20+
private ExpressionList<Expression> timezoneExpressions = new ExpressionList<>();
2121

2222
public Expression getLeftExpression() {
2323
return leftExpression;

src/main/java/net/sf/jsqlparser/expression/operators/relational/FullTextSearch.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
*/
1010
package net.sf.jsqlparser.expression.operators.relational;
1111

12-
import java.util.ArrayList;
13-
import java.util.Collection;
14-
import java.util.Collections;
15-
import java.util.Iterator;
16-
import java.util.List;
17-
import java.util.Optional;
1812
import net.sf.jsqlparser.expression.Expression;
1913
import net.sf.jsqlparser.expression.ExpressionVisitor;
2014
import net.sf.jsqlparser.expression.JdbcNamedParameter;
@@ -23,32 +17,37 @@
2317
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
2418
import net.sf.jsqlparser.schema.Column;
2519

20+
import java.util.Arrays;
21+
import java.util.Collection;
22+
import java.util.Iterator;
23+
import java.util.Optional;
24+
2625
public class FullTextSearch extends ASTNodeAccessImpl implements Expression {
2726

28-
private List<Column> _matchColumns;
27+
private ExpressionList<Column> _matchColumns;
2928
private Expression _againstValue;
3029
private String _searchModifier;
3130

3231
public FullTextSearch() {
3332

3433
}
3534

36-
public void setMatchColumns(List<Column> columns) {
35+
public void setMatchColumns(ExpressionList<Column> columns) {
3736
this._matchColumns = columns;
3837
}
3938

40-
public List<Column> getMatchColumns() {
39+
public ExpressionList<Column> getMatchColumns() {
4140
return this._matchColumns;
4241
}
4342

4443
public void setAgainstValue(StringValue val) {
4544
this._againstValue = val;
4645
}
47-
46+
4847
public void setAgainstValue(JdbcNamedParameter val) {
4948
this._againstValue = val;
5049
}
51-
50+
5251
public void setAgainstValue(JdbcParameter val) {
5352
this._againstValue = val;
5453
}
@@ -87,7 +86,7 @@ public String toString() {
8786
(this._searchModifier != null ? " " + this._searchModifier : "") + ")";
8887
}
8988

90-
public FullTextSearch withMatchColumns(List<Column> matchColumns) {
89+
public FullTextSearch withMatchColumns(ExpressionList<Column> matchColumns) {
9190
this.setMatchColumns(matchColumns);
9291
return this;
9392
}
@@ -103,13 +102,12 @@ public FullTextSearch withSearchModifier(String searchModifier) {
103102
}
104103

105104
public FullTextSearch addMatchColumns(Column... matchColumns) {
106-
List<Column> collection = Optional.ofNullable(getMatchColumns()).orElseGet(ArrayList::new);
107-
Collections.addAll(collection, matchColumns);
108-
return this.withMatchColumns(collection);
105+
return this.addMatchColumns(Arrays.asList(matchColumns));
109106
}
110107

111108
public FullTextSearch addMatchColumns(Collection<? extends Column> matchColumns) {
112-
List<Column> collection = Optional.ofNullable(getMatchColumns()).orElseGet(ArrayList::new);
109+
ExpressionList<Column> collection =
110+
Optional.ofNullable(getMatchColumns()).orElseGet(ExpressionList::new);
113111
collection.addAll(matchColumns);
114112
return this.withMatchColumns(collection);
115113
}

src/main/java/net/sf/jsqlparser/schema/Column.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
*/
1010
package net.sf.jsqlparser.schema;
1111

12-
import java.util.List;
1312
import net.sf.jsqlparser.expression.Expression;
1413
import net.sf.jsqlparser.expression.ExpressionVisitor;
1514
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
1615

16+
import java.util.List;
17+
1718
/**
1819
* A column. It can have the table name it belongs to.
1920
*/
@@ -22,8 +23,7 @@ public class Column extends ASTNodeAccessImpl implements Expression, MultiPartNa
2223
private Table table;
2324
private String columnName;
2425

25-
public Column() {
26-
}
26+
public Column() {}
2727

2828
public Column(Table table, String columnName) {
2929
setTable(table);
@@ -40,27 +40,31 @@ public Column(String columnName) {
4040
}
4141

4242
/**
43-
* Retrieve the information regarding the {@code Table} this {@code Column} does
44-
* belong to, if any can be inferred.
45-
* <p>
46-
* The inference is based only on local information, and not on the whole SQL command.
47-
* For example, consider the following query:
48-
* <blockquote><pre>
49-
* SELECT x FROM Foo
50-
* </pre></blockquote>
51-
* Given the {@code Column} called {@code x}, this method would return {@code null},
52-
* and not the info about the table {@code Foo}.
53-
* On the other hand, consider:
54-
* <blockquote><pre>
55-
* SELECT t.x FROM Foo t
56-
* </pre></blockquote>
57-
* Here, we will get a {@code Table} object for a table called {@code t}.
58-
* But because the inference is local, such object will not know that {@code t} is
59-
* just an alias for {@code Foo}.
60-
*
61-
* @return an instance of {@link net.sf.jsqlparser.schema.Table} representing the
62-
* table this column does belong to, if it can be inferred. Can be {@code null}.
63-
*/
43+
* Retrieve the information regarding the {@code Table} this {@code Column} does belong to, if
44+
* any can be inferred.
45+
* <p>
46+
* The inference is based only on local information, and not on the whole SQL command. For
47+
* example, consider the following query: <blockquote>
48+
*
49+
* <pre>
50+
* SELECT x FROM Foo
51+
* </pre>
52+
*
53+
* </blockquote> Given the {@code Column} called {@code x}, this method would return
54+
* {@code null}, and not the info about the table {@code Foo}. On the other hand, consider:
55+
* <blockquote>
56+
*
57+
* <pre>
58+
* SELECT t.x FROM Foo t
59+
* </pre>
60+
*
61+
* </blockquote> Here, we will get a {@code Table} object for a table called {@code t}. But
62+
* because the inference is local, such object will not know that {@code t} is just an alias for
63+
* {@code Foo}.
64+
*
65+
* @return an instance of {@link net.sf.jsqlparser.schema.Table} representing the table this
66+
* column does belong to, if it can be inferred. Can be {@code null}.
67+
*/
6468
public Table getTable() {
6569
return table;
6670
}

0 commit comments

Comments
 (0)