1919import java .util .Collection ;
2020import java .util .Objects ;
2121import java .util .function .Consumer ;
22- import java .util .function .Function ;
2322
2423import org .jspecify .annotations .Nullable ;
2524import org .mybatis .dynamic .sql .SortSpecification ;
3231import org .mybatis .dynamic .sql .where .AbstractWhereStarter ;
3332import org .mybatis .dynamic .sql .where .EmbeddedWhereModel ;
3433
35- public class DeleteDSL < R > implements AbstractWhereStarter <DeleteDSL < R > .DeleteWhereBuilder , DeleteDSL < R > >,
36- Buildable <R > {
34+ public class DeleteDSL implements AbstractWhereStarter <DeleteDSL .DeleteWhereBuilder , DeleteDSL >,
35+ Buildable <DeleteModel > {
3736
38- private final Function <DeleteModel , R > adapterFunction ;
3937 private final SqlTable table ;
4038 private final @ Nullable String tableAlias ;
4139 private @ Nullable DeleteWhereBuilder whereBuilder ;
4240 private final StatementConfiguration statementConfiguration = new StatementConfiguration ();
4341 private @ Nullable Long limit ;
4442 private @ Nullable OrderByModel orderByModel ;
4543
46- private DeleteDSL (SqlTable table , @ Nullable String tableAlias , Function < DeleteModel , R > adapterFunction ) {
44+ private DeleteDSL (SqlTable table , @ Nullable String tableAlias ) {
4745 this .table = Objects .requireNonNull (table );
4846 this .tableAlias = tableAlias ;
49- this .adapterFunction = Objects .requireNonNull (adapterFunction );
5047 }
5148
5249 @ Override
@@ -55,20 +52,20 @@ public DeleteWhereBuilder where() {
5552 return whereBuilder ;
5653 }
5754
58- public DeleteDSL < R > limit (long limit ) {
55+ public DeleteDSL limit (long limit ) {
5956 return limitWhenPresent (limit );
6057 }
6158
62- public DeleteDSL < R > limitWhenPresent (@ Nullable Long limit ) {
59+ public DeleteDSL limitWhenPresent (@ Nullable Long limit ) {
6360 this .limit = limit ;
6461 return this ;
6562 }
6663
67- public DeleteDSL < R > orderBy (SortSpecification ... columns ) {
64+ public DeleteDSL orderBy (SortSpecification ... columns ) {
6865 return orderBy (Arrays .asList (columns ));
6966 }
7067
71- public DeleteDSL < R > orderBy (Collection <? extends SortSpecification > columns ) {
68+ public DeleteDSL orderBy (Collection <? extends SortSpecification > columns ) {
7269 orderByModel = OrderByModel .of (columns );
7370 return this ;
7471 }
@@ -80,62 +77,55 @@ public DeleteDSL<R> orderBy(Collection<? extends SortSpecification> columns) {
8077 * @return the model class
8178 */
8279 @ Override
83- public R build () {
84- DeleteModel deleteModel = DeleteModel .withTable (table )
80+ public DeleteModel build () {
81+ return DeleteModel .withTable (table )
8582 .withTableAlias (tableAlias )
8683 .withLimit (limit )
8784 .withOrderByModel (orderByModel )
8885 .withWhereModel (whereBuilder == null ? null : whereBuilder .buildWhereModel ())
8986 .withStatementConfiguration (statementConfiguration )
9087 .build ();
91-
92- return adapterFunction .apply (deleteModel );
9388 }
9489
9590 @ Override
96- public DeleteDSL < R > configureStatement (Consumer <StatementConfiguration > consumer ) {
91+ public DeleteDSL configureStatement (Consumer <StatementConfiguration > consumer ) {
9792 consumer .accept (statementConfiguration );
9893 return this ;
9994 }
10095
101- public static <R > DeleteDSL <R > deleteFrom (Function <DeleteModel , R > adapterFunction , SqlTable table ,
102- @ Nullable String tableAlias ) {
103- return new DeleteDSL <>(table , tableAlias , adapterFunction );
104- }
105-
106- public static DeleteDSL <DeleteModel > deleteFrom (SqlTable table ) {
107- return deleteFrom (Function .identity (), table , null );
96+ public static DeleteDSL deleteFrom (SqlTable table ) {
97+ return deleteFrom (table , null );
10898 }
10999
110- public static DeleteDSL < DeleteModel > deleteFrom (SqlTable table , String tableAlias ) {
111- return deleteFrom ( Function . identity (), table , tableAlias );
100+ public static DeleteDSL deleteFrom (SqlTable table , @ Nullable String tableAlias ) {
101+ return new DeleteDSL ( table , tableAlias );
112102 }
113103
114- public class DeleteWhereBuilder extends AbstractWhereFinisher <DeleteWhereBuilder > implements Buildable <R > {
104+ public class DeleteWhereBuilder extends AbstractWhereFinisher <DeleteWhereBuilder > implements Buildable <DeleteModel > {
115105
116106 private DeleteWhereBuilder () {
117107 super (DeleteDSL .this );
118108 }
119109
120- public DeleteDSL < R > limit (long limit ) {
110+ public DeleteDSL limit (long limit ) {
121111 return limitWhenPresent (limit );
122112 }
123113
124- public DeleteDSL < R > limitWhenPresent (Long limit ) {
114+ public DeleteDSL limitWhenPresent (Long limit ) {
125115 return DeleteDSL .this .limitWhenPresent (limit );
126116 }
127117
128- public DeleteDSL < R > orderBy (SortSpecification ... columns ) {
118+ public DeleteDSL orderBy (SortSpecification ... columns ) {
129119 return orderBy (Arrays .asList (columns ));
130120 }
131121
132- public DeleteDSL < R > orderBy (Collection <? extends SortSpecification > columns ) {
122+ public DeleteDSL orderBy (Collection <? extends SortSpecification > columns ) {
133123 orderByModel = OrderByModel .of (columns );
134124 return DeleteDSL .this ;
135125 }
136126
137127 @ Override
138- public R build () {
128+ public DeleteModel build () {
139129 return DeleteDSL .this .build ();
140130 }
141131
0 commit comments