2121import java .util .List ;
2222import java .util .Objects ;
2323import java .util .function .Consumer ;
24- import java .util .function .Function ;
2524import java .util .function .Supplier ;
2625
2726import org .jspecify .annotations .Nullable ;
4746import org .mybatis .dynamic .sql .where .AbstractWhereStarter ;
4847import org .mybatis .dynamic .sql .where .EmbeddedWhereModel ;
4948
50- public class UpdateDSL < R > implements AbstractWhereStarter <UpdateDSL < R > .UpdateWhereBuilder , UpdateDSL < R > >,
51- Buildable <R > {
49+ public class UpdateDSL implements AbstractWhereStarter <UpdateDSL .UpdateWhereBuilder , UpdateDSL >,
50+ Buildable <UpdateModel > {
5251
53- private final Function <UpdateModel , R > adapterFunction ;
5452 private final List <AbstractColumnMapping > columnMappings = new ArrayList <>();
5553 private final SqlTable table ;
5654 private final @ Nullable String tableAlias ;
@@ -59,10 +57,9 @@ public class UpdateDSL<R> implements AbstractWhereStarter<UpdateDSL<R>.UpdateWhe
5957 private @ Nullable Long limit ;
6058 private @ Nullable OrderByModel orderByModel ;
6159
62- private UpdateDSL (SqlTable table , @ Nullable String tableAlias , Function < UpdateModel , R > adapterFunction ) {
60+ private UpdateDSL (SqlTable table , @ Nullable String tableAlias ) {
6361 this .table = Objects .requireNonNull (table );
6462 this .tableAlias = tableAlias ;
65- this .adapterFunction = Objects .requireNonNull (adapterFunction );
6663 }
6764
6865 public <T > SetClauseFinisher <T > set (SqlColumn <T > column ) {
@@ -75,20 +72,20 @@ public UpdateWhereBuilder where() {
7572 return whereBuilder ;
7673 }
7774
78- public UpdateDSL < R > limit (long limit ) {
75+ public UpdateDSL limit (long limit ) {
7976 return limitWhenPresent (limit );
8077 }
8178
82- public UpdateDSL < R > limitWhenPresent (@ Nullable Long limit ) {
79+ public UpdateDSL limitWhenPresent (@ Nullable Long limit ) {
8380 this .limit = limit ;
8481 return this ;
8582 }
8683
87- public UpdateDSL < R > orderBy (SortSpecification ... columns ) {
84+ public UpdateDSL orderBy (SortSpecification ... columns ) {
8885 return orderBy (Arrays .asList (columns ));
8986 }
9087
91- public UpdateDSL < R > orderBy (Collection <? extends SortSpecification > columns ) {
88+ public UpdateDSL orderBy (Collection <? extends SortSpecification > columns ) {
9289 orderByModel = OrderByModel .of (columns );
9390 return this ;
9491 }
@@ -100,36 +97,29 @@ public UpdateDSL<R> orderBy(Collection<? extends SortSpecification> columns) {
10097 * @return the update model
10198 */
10299 @ Override
103- public R build () {
104- UpdateModel updateModel = UpdateModel .withTable (table )
100+ public UpdateModel build () {
101+ return UpdateModel .withTable (table )
105102 .withTableAlias (tableAlias )
106103 .withColumnMappings (columnMappings )
107104 .withLimit (limit )
108105 .withOrderByModel (orderByModel )
109106 .withWhereModel (whereBuilder == null ? null : whereBuilder .buildWhereModel ())
110107 .withStatementConfiguration (statementConfiguration )
111108 .build ();
112-
113- return adapterFunction .apply (updateModel );
114109 }
115110
116111 @ Override
117- public UpdateDSL < R > configureStatement (Consumer <StatementConfiguration > consumer ) {
112+ public UpdateDSL configureStatement (Consumer <StatementConfiguration > consumer ) {
118113 consumer .accept (statementConfiguration );
119114 return this ;
120115 }
121116
122- public static <R > UpdateDSL <R > update (Function <UpdateModel , R > adapterFunction , SqlTable table ,
123- @ Nullable String tableAlias ) {
124- return new UpdateDSL <>(table , tableAlias , adapterFunction );
125- }
126-
127- public static UpdateDSL <UpdateModel > update (SqlTable table ) {
128- return update (Function .identity (), table , null );
117+ public static UpdateDSL update (SqlTable table , @ Nullable String tableAlias ) {
118+ return new UpdateDSL (table , tableAlias );
129119 }
130120
131- public static UpdateDSL < UpdateModel > update (SqlTable table , String tableAlias ) {
132- return update (Function . identity (), table , tableAlias );
121+ public static UpdateDSL update (SqlTable table ) {
122+ return update (table , null );
133123 }
134124
135125 public class SetClauseFinisher <T > {
@@ -140,84 +130,85 @@ public SetClauseFinisher(SqlColumn<T> column) {
140130 this .column = column ;
141131 }
142132
143- public UpdateDSL < R > equalToNull () {
133+ public UpdateDSL equalToNull () {
144134 columnMappings .add (NullMapping .of (column ));
145135 return UpdateDSL .this ;
146136 }
147137
148- public UpdateDSL < R > equalToConstant (String constant ) {
138+ public UpdateDSL equalToConstant (String constant ) {
149139 columnMappings .add (ConstantMapping .of (column , constant ));
150140 return UpdateDSL .this ;
151141 }
152142
153- public UpdateDSL < R > equalToStringConstant (String constant ) {
143+ public UpdateDSL equalToStringConstant (String constant ) {
154144 columnMappings .add (StringConstantMapping .of (column , constant ));
155145 return UpdateDSL .this ;
156146 }
157147
158- public UpdateDSL < R > equalTo (T value ) {
148+ public UpdateDSL equalTo (T value ) {
159149 return equalTo (() -> value );
160150 }
161151
162- public UpdateDSL < R > equalTo (Supplier <T > valueSupplier ) {
152+ public UpdateDSL equalTo (Supplier <T > valueSupplier ) {
163153 columnMappings .add (ValueMapping .of (column , valueSupplier ));
164154 return UpdateDSL .this ;
165155 }
166156
167- public UpdateDSL < R > equalTo (Buildable <SelectModel > buildable ) {
157+ public UpdateDSL equalTo (Buildable <SelectModel > buildable ) {
168158 columnMappings .add (SelectMapping .of (column , buildable ));
169159 return UpdateDSL .this ;
170160 }
171161
172- public UpdateDSL < R > equalTo (BasicColumn rightColumn ) {
162+ public UpdateDSL equalTo (BasicColumn rightColumn ) {
173163 columnMappings .add (ColumnToColumnMapping .of (column , rightColumn ));
174164 return UpdateDSL .this ;
175165 }
176166
177- public UpdateDSL < R > equalToOrNull (@ Nullable T value ) {
167+ public UpdateDSL equalToOrNull (@ Nullable T value ) {
178168 return equalToOrNull (() -> value );
179169 }
180170
181- public UpdateDSL < R > equalToOrNull (Supplier <@ Nullable T > valueSupplier ) {
171+ public UpdateDSL equalToOrNull (Supplier <@ Nullable T > valueSupplier ) {
182172 columnMappings .add (ValueOrNullMapping .of (column , valueSupplier ));
183173 return UpdateDSL .this ;
184174 }
185175
186- public UpdateDSL < R > equalToWhenPresent (@ Nullable T value ) {
176+ public UpdateDSL equalToWhenPresent (@ Nullable T value ) {
187177 return equalToWhenPresent (() -> value );
188178 }
189179
190- public UpdateDSL < R > equalToWhenPresent (Supplier <@ Nullable T > valueSupplier ) {
180+ public UpdateDSL equalToWhenPresent (Supplier <@ Nullable T > valueSupplier ) {
191181 columnMappings .add (ValueWhenPresentMapping .of (column , valueSupplier ));
192182 return UpdateDSL .this ;
193183 }
194184 }
195185
196- public class UpdateWhereBuilder extends AbstractWhereFinisher <UpdateWhereBuilder > implements Buildable <R > {
186+ public class UpdateWhereBuilder extends AbstractWhereFinisher <UpdateWhereBuilder >
187+ implements Buildable <UpdateModel > {
197188
198189 private UpdateWhereBuilder () {
199190 super (UpdateDSL .this );
200191 }
201192
202- public UpdateDSL < R > limit (long limit ) {
193+ public UpdateDSL limit (long limit ) {
203194 return limitWhenPresent (limit );
204195 }
205196
206- public UpdateDSL < R > limitWhenPresent (Long limit ) {
197+ public UpdateDSL limitWhenPresent (Long limit ) {
207198 return UpdateDSL .this .limitWhenPresent (limit );
208199 }
209200
210- public UpdateDSL < R > orderBy (SortSpecification ... columns ) {
201+ public UpdateDSL orderBy (SortSpecification ... columns ) {
211202 return orderBy (Arrays .asList (columns ));
212203 }
213204
214- public UpdateDSL < R > orderBy (Collection <? extends SortSpecification > columns ) {
205+ public UpdateDSL orderBy (Collection <? extends SortSpecification > columns ) {
215206 orderByModel = OrderByModel .of (columns );
216207 return UpdateDSL .this ;
217208 }
218209
219210 @ Override
220- public R build () {
211+ public UpdateModel build () {
221212 return UpdateDSL .this .build ();
222213 }
223214
0 commit comments