1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.dynamic.sql.update;
17
18 import java.util.Objects;
19 import java.util.function.Function;
20
21 import org.jspecify.annotations.Nullable;
22 import org.mybatis.dynamic.sql.SqlTable;
23 import org.mybatis.dynamic.sql.dsl.AbstractUpdateDSL;
24
25 public class UpdateDSL<R> extends AbstractUpdateDSL<R, UpdateDSL<R>> {
26
27 private final Function<UpdateModel, R> adapterFunction;
28
29 private UpdateDSL(SqlTable table, @Nullable String tableAlias, Function<UpdateModel, R> adapterFunction) {
30 super(table, tableAlias);
31 this.adapterFunction = Objects.requireNonNull(adapterFunction);
32 }
33
34
35
36
37
38
39
40 @Override
41 public R build() {
42 return buildUpdateModel().map(adapterFunction);
43 }
44
45 @Override
46 protected UpdateDSL<R> getThis() {
47 return this;
48 }
49
50 public static <R> UpdateDSL<R> update(Function<UpdateModel, R> adapterFunction, SqlTable table,
51 @Nullable String tableAlias) {
52 return new UpdateDSL<>(table, tableAlias, adapterFunction);
53 }
54
55 public static UpdateDSL<UpdateModel> update(SqlTable table) {
56 return update(Function.identity(), table, null);
57 }
58
59 public static UpdateDSL<UpdateModel> update(SqlTable table, String tableAlias) {
60 return update(Function.identity(), table, tableAlias);
61 }
62 }