Skip to content

Commit a339fda

Browse files
committed
Rename DSL classes to show their true nature
1 parent 60ac43c commit a339fda

30 files changed

+183
-183
lines changed

src/main/java/org/mybatis/dynamic/sql/AbstractSubselectCondition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.mybatis.dynamic.sql;
1717

18-
import org.mybatis.dynamic.sql.select.Buildable;
1918
import org.mybatis.dynamic.sql.select.SelectModel;
19+
import org.mybatis.dynamic.sql.util.Buildable;
2020

2121
public abstract class AbstractSubselectCondition<T> implements VisitableCondition<T> {
2222
private SelectModel selectModel;

src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java

+37-38
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
import java.util.Arrays;
1919
import java.util.List;
2020

21-
import org.mybatis.dynamic.sql.delete.DeleteModelBuilder;
22-
import org.mybatis.dynamic.sql.insert.InsertBatchModelBuilder;
23-
import org.mybatis.dynamic.sql.insert.InsertModelBuilder;
24-
import org.mybatis.dynamic.sql.insert.InsertSelectModelBuilder;
25-
import org.mybatis.dynamic.sql.insert.InsertSelectModelBuilder.InsertColumnGatherer;
26-
import org.mybatis.dynamic.sql.select.Buildable;
27-
import org.mybatis.dynamic.sql.select.QueryExpressionBuilder;
21+
import org.mybatis.dynamic.sql.delete.DeleteDSL;
22+
import org.mybatis.dynamic.sql.insert.InsertBatchDSL;
23+
import org.mybatis.dynamic.sql.insert.InsertDSL;
24+
import org.mybatis.dynamic.sql.insert.InsertSelectDSL;
25+
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
26+
import org.mybatis.dynamic.sql.select.SelectDSL;
2827
import org.mybatis.dynamic.sql.select.SelectModel;
29-
import org.mybatis.dynamic.sql.select.SelectModelBuilder;
3028
import org.mybatis.dynamic.sql.select.aggregate.Avg;
3129
import org.mybatis.dynamic.sql.select.aggregate.Count;
3230
import org.mybatis.dynamic.sql.select.aggregate.CountAll;
@@ -36,7 +34,8 @@
3634
import org.mybatis.dynamic.sql.select.join.EqualTo;
3735
import org.mybatis.dynamic.sql.select.join.JoinCondition;
3836
import org.mybatis.dynamic.sql.select.join.JoinCriterion;
39-
import org.mybatis.dynamic.sql.update.UpdateModelBuilder;
37+
import org.mybatis.dynamic.sql.update.UpdateDSL;
38+
import org.mybatis.dynamic.sql.util.Buildable;
4039
import org.mybatis.dynamic.sql.where.condition.IsBetween;
4140
import org.mybatis.dynamic.sql.where.condition.IsEqualTo;
4241
import org.mybatis.dynamic.sql.where.condition.IsEqualToWithSubselect;
@@ -67,37 +66,37 @@
6766
public interface SqlBuilder {
6867

6968
// statements
70-
static DeleteModelBuilder deleteFrom(SqlTable table) {
71-
return DeleteModelBuilder.deleteFrom(table);
69+
static DeleteDSL deleteFrom(SqlTable table) {
70+
return DeleteDSL.deleteFrom(table);
7271
}
7372

74-
static <T> InsertModelBuilder.IntoGatherer<T> insert(T record) {
75-
return InsertModelBuilder.insert(record);
73+
static <T> InsertDSL.IntoGatherer<T> insert(T record) {
74+
return InsertDSL.insert(record);
7675
}
7776

7877
@SafeVarargs
79-
static <T> InsertBatchModelBuilder.IntoGatherer<T> insert(T...records) {
80-
return InsertBatchModelBuilder.insert(records);
78+
static <T> InsertBatchDSL.IntoGatherer<T> insert(T...records) {
79+
return InsertBatchDSL.insert(records);
8180
}
8281

83-
static <T> InsertBatchModelBuilder.IntoGatherer<T> insert(List<T> records) {
84-
return InsertBatchModelBuilder.insert(records);
82+
static <T> InsertBatchDSL.IntoGatherer<T> insert(List<T> records) {
83+
return InsertBatchDSL.insert(records);
8584
}
8685

87-
static InsertColumnGatherer insertInto(SqlTable table) {
88-
return InsertSelectModelBuilder.insertInto(table);
86+
static InsertSelectDSL.InsertColumnGatherer insertInto(SqlTable table) {
87+
return InsertSelectDSL.insertInto(table);
8988
}
9089

91-
static QueryExpressionBuilder select(SelectListItem...selectList) {
92-
return SelectModelBuilder.select(selectList);
90+
static QueryExpressionDSL select(SelectListItem...selectList) {
91+
return SelectDSL.select(selectList);
9392
}
9493

95-
static QueryExpressionBuilder selectDistinct(SelectListItem...selectList) {
96-
return SelectModelBuilder.selectDistinct(selectList);
94+
static QueryExpressionDSL selectDistinct(SelectListItem...selectList) {
95+
return SelectDSL.selectDistinct(selectList);
9796
}
9897

99-
static UpdateModelBuilder update(SqlTable table) {
100-
return UpdateModelBuilder.update(table);
98+
static UpdateDSL update(SqlTable table) {
99+
return UpdateDSL.update(table);
101100
}
102101

103102
// where condition connectors
@@ -136,6 +135,19 @@ static <T> SqlCriterion<T> and(SqlColumn<T> column, VisitableCondition<T> condit
136135
.build();
137136
}
138137

138+
// join support
139+
static <T> JoinCriterion<T> and(SqlColumn<T> joinColumn, JoinCondition<T> joinCondition) {
140+
return new JoinCriterion.Builder<T>()
141+
.withJoinColumn(joinColumn)
142+
.withJoinCondition(joinCondition)
143+
.withConnector("and") //$NON-NLS-1$
144+
.build();
145+
}
146+
147+
static <T> EqualTo<T> equalTo(SqlColumn<T> column) {
148+
return new EqualTo<>(column);
149+
}
150+
139151
// aggregate support
140152
static CountAll count() {
141153
return new CountAll();
@@ -277,17 +289,4 @@ static IsInCaseInsensitive isInCaseInsensitive(String...values) {
277289
static IsNotInCaseInsensitive isNotInCaseInsensitive(String...values) {
278290
return IsNotInCaseInsensitive.of(Arrays.asList(values));
279291
}
280-
281-
// join support
282-
static <T> JoinCriterion<T> and(SqlColumn<T> joinColumn, JoinCondition<T> joinCondition) {
283-
return new JoinCriterion.Builder<T>()
284-
.withJoinColumn(joinColumn)
285-
.withJoinCondition(joinCondition)
286-
.withConnector("and") //$NON-NLS-1$
287-
.build();
288-
}
289-
290-
static <T> EqualTo<T> equalTo(SqlColumn<T> column) {
291-
return new EqualTo<>(column);
292-
}
293292
}

src/main/java/org/mybatis/dynamic/sql/delete/DeleteModelBuilder.java src/main/java/org/mybatis/dynamic/sql/delete/DeleteDSL.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import org.mybatis.dynamic.sql.SqlCriterion;
2020
import org.mybatis.dynamic.sql.SqlTable;
2121
import org.mybatis.dynamic.sql.VisitableCondition;
22-
import org.mybatis.dynamic.sql.where.AbstractWhereModelBuilder;
22+
import org.mybatis.dynamic.sql.where.AbstractWhereDSL;
2323

24-
public class DeleteModelBuilder {
24+
public class DeleteDSL {
2525

2626
private SqlTable table;
2727

28-
private DeleteModelBuilder(SqlTable table) {
28+
private DeleteDSL(SqlTable table) {
2929
this.table = table;
3030
}
3131

@@ -50,11 +50,11 @@ public DeleteModel build() {
5050
.build();
5151
}
5252

53-
public static DeleteModelBuilder deleteFrom(SqlTable table) {
54-
return new DeleteModelBuilder(table);
53+
public static DeleteDSL deleteFrom(SqlTable table) {
54+
return new DeleteDSL(table);
5555
}
5656

57-
public class DeleteSupportWhereBuilder extends AbstractWhereModelBuilder<DeleteSupportWhereBuilder> {
57+
public class DeleteSupportWhereBuilder extends AbstractWhereDSL<DeleteSupportWhereBuilder> {
5858

5959
private <T> DeleteSupportWhereBuilder(SqlColumn<T> column, VisitableCondition<T> condition) {
6060
super(column, condition);

src/main/java/org/mybatis/dynamic/sql/insert/InsertBatchModelBuilder.java src/main/java/org/mybatis/dynamic/sql/insert/InsertBatchDSL.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import org.mybatis.dynamic.sql.util.PropertyMapping;
2828
import org.mybatis.dynamic.sql.util.StringConstantMapping;
2929

30-
public class InsertBatchModelBuilder<T> {
30+
public class InsertBatchDSL<T> {
3131

3232
private List<T> records;
3333
private SqlTable table;
3434
private List<InsertMapping> columnMappings = new ArrayList<>();
3535

36-
private InsertBatchModelBuilder(List<T> records, SqlTable table) {
36+
private InsertBatchDSL(List<T> records, SqlTable table) {
3737
this.records = records;
3838
this.table = table;
3939
}
@@ -66,8 +66,8 @@ private IntoGatherer(List<T> records) {
6666
this.records = records;
6767
}
6868

69-
public InsertBatchModelBuilder<T> into(SqlTable table) {
70-
return new InsertBatchModelBuilder<>(records, table);
69+
public InsertBatchDSL<T> into(SqlTable table) {
70+
return new InsertBatchDSL<>(records, table);
7171
}
7272
}
7373

@@ -78,24 +78,24 @@ public BatchColumnMappingFinisher(SqlColumn<F> column) {
7878
this.column = column;
7979
}
8080

81-
public InsertBatchModelBuilder<T> toProperty(String property) {
81+
public InsertBatchDSL<T> toProperty(String property) {
8282
columnMappings.add(PropertyMapping.of(column, property));
83-
return InsertBatchModelBuilder.this;
83+
return InsertBatchDSL.this;
8484
}
8585

86-
public InsertBatchModelBuilder<T> toNull() {
86+
public InsertBatchDSL<T> toNull() {
8787
columnMappings.add(NullMapping.of(column));
88-
return InsertBatchModelBuilder.this;
88+
return InsertBatchDSL.this;
8989
}
9090

91-
public InsertBatchModelBuilder<T> toConstant(String constant) {
91+
public InsertBatchDSL<T> toConstant(String constant) {
9292
columnMappings.add(ConstantMapping.of(column, constant));
93-
return InsertBatchModelBuilder.this;
93+
return InsertBatchDSL.this;
9494
}
9595

96-
public InsertBatchModelBuilder<T> toStringConstant(String constant) {
96+
public InsertBatchDSL<T> toStringConstant(String constant) {
9797
columnMappings.add(StringConstantMapping.of(column, constant));
98-
return InsertBatchModelBuilder.this;
98+
return InsertBatchDSL.this;
9999
}
100100
}
101101
}

src/main/java/org/mybatis/dynamic/sql/insert/InsertModelBuilder.java src/main/java/org/mybatis/dynamic/sql/insert/InsertDSL.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import org.mybatis.dynamic.sql.util.PropertyMapping;
2828
import org.mybatis.dynamic.sql.util.StringConstantMapping;
2929

30-
public class InsertModelBuilder<T> {
30+
public class InsertDSL<T> {
3131

3232
private T record;
3333
private SqlTable table;
3434
private List<InsertMapping> columnMappings = new ArrayList<>();
3535

36-
private InsertModelBuilder(T record, SqlTable table) {
36+
private InsertDSL(T record, SqlTable table) {
3737
this.record = record;
3838
this.table = table;
3939
}
@@ -61,8 +61,8 @@ private IntoGatherer(T record) {
6161
this.record = record;
6262
}
6363

64-
public InsertModelBuilder<T> into(SqlTable table) {
65-
return new InsertModelBuilder<>(record, table);
64+
public InsertDSL<T> into(SqlTable table) {
65+
return new InsertDSL<>(record, table);
6666
}
6767
}
6868

@@ -73,31 +73,31 @@ public ColumnMappingFinisher(SqlColumn<F> column) {
7373
this.column = column;
7474
}
7575

76-
public InsertModelBuilder<T> toProperty(String property) {
76+
public InsertDSL<T> toProperty(String property) {
7777
columnMappings.add(PropertyMapping.of(column, property));
78-
return InsertModelBuilder.this;
78+
return InsertDSL.this;
7979
}
8080

81-
public InsertModelBuilder<T> toPropertyWhenPresent(String property) {
81+
public InsertDSL<T> toPropertyWhenPresent(String property) {
8282
if (BeanPropertyGetter.instance().getPropertyValue(record, property) != null) {
8383
toProperty(property);
8484
}
85-
return InsertModelBuilder.this;
85+
return InsertDSL.this;
8686
}
8787

88-
public InsertModelBuilder<T> toNull() {
88+
public InsertDSL<T> toNull() {
8989
columnMappings.add(NullMapping.of(column));
90-
return InsertModelBuilder.this;
90+
return InsertDSL.this;
9191
}
9292

93-
public InsertModelBuilder<T> toConstant(String constant) {
93+
public InsertDSL<T> toConstant(String constant) {
9494
columnMappings.add(ConstantMapping.of(column, constant));
95-
return InsertModelBuilder.this;
95+
return InsertDSL.this;
9696
}
9797

98-
public InsertModelBuilder<T> toStringConstant(String constant) {
98+
public InsertDSL<T> toStringConstant(String constant) {
9999
columnMappings.add(StringConstantMapping.of(column, constant));
100-
return InsertModelBuilder.this;
100+
return InsertDSL.this;
101101
}
102102
}
103103
}

src/main/java/org/mybatis/dynamic/sql/insert/InsertSelectModelBuilder.java src/main/java/org/mybatis/dynamic/sql/insert/InsertSelectDSL.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121

2222
import org.mybatis.dynamic.sql.SqlColumn;
2323
import org.mybatis.dynamic.sql.SqlTable;
24-
import org.mybatis.dynamic.sql.select.Buildable;
2524
import org.mybatis.dynamic.sql.select.SelectModel;
25+
import org.mybatis.dynamic.sql.util.Buildable;
2626

27-
public class InsertSelectModelBuilder {
27+
public class InsertSelectDSL {
2828

2929
private SqlTable table;
3030
private Optional<List<SqlColumn<?>>> columns;
3131
private SelectModel selectModel;
3232

33-
private InsertSelectModelBuilder(SqlTable table, List<SqlColumn<?>> columns, SelectModel selectModel) {
33+
private InsertSelectDSL(SqlTable table, List<SqlColumn<?>> columns, SelectModel selectModel) {
3434
this.table = table;
3535
this.columns = Optional.of(columns);
3636
this.selectModel = selectModel;
3737
}
3838

39-
private InsertSelectModelBuilder(SqlTable table, SelectModel selectModel) {
39+
private InsertSelectDSL(SqlTable table, SelectModel selectModel) {
4040
this.table = table;
4141
this.columns = Optional.empty();
4242
this.selectModel = selectModel;
@@ -65,8 +65,8 @@ public SelectGatherer withColumnList(SqlColumn<?>...columns) {
6565
return new SelectGatherer(table, Arrays.asList(columns));
6666
}
6767

68-
public InsertSelectModelBuilder withSelectStatement(Buildable<SelectModel> selectModelBuilder) {
69-
return new InsertSelectModelBuilder(table, selectModelBuilder.build());
68+
public InsertSelectDSL withSelectStatement(Buildable<SelectModel> selectModelBuilder) {
69+
return new InsertSelectDSL(table, selectModelBuilder.build());
7070
}
7171
}
7272

@@ -79,8 +79,8 @@ private SelectGatherer(SqlTable table, List<SqlColumn<?>> columns) {
7979
this.columns = columns;
8080
}
8181

82-
public InsertSelectModelBuilder withSelectStatement(Buildable<SelectModel> selectModelBuilder) {
83-
return new InsertSelectModelBuilder(table, columns, selectModelBuilder.build());
82+
public InsertSelectDSL withSelectStatement(Buildable<SelectModel> selectModelBuilder) {
83+
return new InsertSelectDSL(table, columns, selectModelBuilder.build());
8484
}
8585
}
8686
}

0 commit comments

Comments
 (0)