Skip to content

Commit 91d2852

Browse files
committed
Insert DSLs are buildable
1 parent f8ad7be commit 91d2852

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

src/main/java/org/mybatis/dynamic/sql/insert/GeneralInsertDSL.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
import org.mybatis.dynamic.sql.SqlColumn;
2424
import org.mybatis.dynamic.sql.SqlTable;
2525
import org.mybatis.dynamic.sql.util.AbstractColumnMapping;
26+
import org.mybatis.dynamic.sql.util.Buildable;
2627
import org.mybatis.dynamic.sql.util.ConstantMapping;
2728
import org.mybatis.dynamic.sql.util.NullMapping;
2829
import org.mybatis.dynamic.sql.util.StringConstantMapping;
2930
import org.mybatis.dynamic.sql.util.ValueMapping;
3031
import org.mybatis.dynamic.sql.util.ValueWhenPresentMapping;
3132

32-
public class GeneralInsertDSL {
33+
public class GeneralInsertDSL implements Buildable<GeneralInsertModel> {
3334
private List<AbstractColumnMapping> insertMappings = new ArrayList<>();
3435
private SqlTable table;
3536

@@ -40,7 +41,8 @@ private GeneralInsertDSL(SqlTable table) {
4041
public <T> SetClauseFinisher<T> set(SqlColumn<T> column) {
4142
return new SetClauseFinisher<>(column);
4243
}
43-
44+
45+
@Override
4446
public GeneralInsertModel build() {
4547
return new GeneralInsertModel.Builder()
4648
.withTable(table)

src/main/java/org/mybatis/dynamic/sql/insert/GeneralInsertModel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.util.function.Function;
2222
import java.util.stream.Stream;
2323

24+
import org.jetbrains.annotations.NotNull;
2425
import org.mybatis.dynamic.sql.SqlTable;
2526
import org.mybatis.dynamic.sql.insert.render.GeneralInsertRenderer;
2627
import org.mybatis.dynamic.sql.insert.render.GeneralInsertStatementProvider;
@@ -45,6 +46,7 @@ public SqlTable table() {
4546
return table;
4647
}
4748

49+
@NotNull
4850
public GeneralInsertStatementProvider render(RenderingStrategy renderingStrategy) {
4951
return GeneralInsertRenderer.withInsertModel(this)
5052
.withRenderingStrategy(renderingStrategy)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import org.mybatis.dynamic.sql.SqlColumn;
2323
import org.mybatis.dynamic.sql.SqlTable;
2424
import org.mybatis.dynamic.sql.util.AbstractColumnMapping;
25+
import org.mybatis.dynamic.sql.util.Buildable;
2526
import org.mybatis.dynamic.sql.util.ConstantMapping;
2627
import org.mybatis.dynamic.sql.util.NullMapping;
2728
import org.mybatis.dynamic.sql.util.PropertyMapping;
2829
import org.mybatis.dynamic.sql.util.PropertyWhenPresentMapping;
2930
import org.mybatis.dynamic.sql.util.StringConstantMapping;
3031

31-
public class InsertDSL<T> {
32+
public class InsertDSL<T> implements Buildable<InsertModel<T>> {
3233

3334
private T record;
3435
private SqlTable table;
@@ -43,6 +44,7 @@ public <F> ColumnMappingFinisher<F> map(SqlColumn<F> column) {
4344
return new ColumnMappingFinisher<>(column);
4445
}
4546

47+
@Override
4648
public InsertModel<T> build() {
4749
return InsertModel.withRecord(record)
4850
.withTable(table)

src/main/java/org/mybatis/dynamic/sql/insert/InsertModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.util.function.Function;
2222
import java.util.stream.Stream;
2323

24+
import org.jetbrains.annotations.NotNull;
2425
import org.mybatis.dynamic.sql.SqlTable;
2526
import org.mybatis.dynamic.sql.insert.render.InsertRenderer;
2627
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
@@ -49,7 +50,8 @@ public T record() {
4950
public SqlTable table() {
5051
return table;
5152
}
52-
53+
54+
@NotNull
5355
public InsertStatementProvider<T> render(RenderingStrategy renderingStrategy) {
5456
return InsertRenderer.withInsertModel(this)
5557
.withRenderingStrategy(renderingStrategy)

src/main/java/org/mybatis/dynamic/sql/insert/MultiRowInsertDSL.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,12 +23,13 @@
2323
import org.mybatis.dynamic.sql.SqlColumn;
2424
import org.mybatis.dynamic.sql.SqlTable;
2525
import org.mybatis.dynamic.sql.util.AbstractColumnMapping;
26+
import org.mybatis.dynamic.sql.util.Buildable;
2627
import org.mybatis.dynamic.sql.util.ConstantMapping;
2728
import org.mybatis.dynamic.sql.util.NullMapping;
2829
import org.mybatis.dynamic.sql.util.PropertyMapping;
2930
import org.mybatis.dynamic.sql.util.StringConstantMapping;
3031

31-
public class MultiRowInsertDSL<T> {
32+
public class MultiRowInsertDSL<T> implements Buildable<MultiRowInsertModel<T>> {
3233

3334
private Collection<T> records;
3435
private SqlTable table;
@@ -42,7 +43,8 @@ private MultiRowInsertDSL(Collection<T> records, SqlTable table) {
4243
public <F> ColumnMappingFinisher<F> map(SqlColumn<F> column) {
4344
return new ColumnMappingFinisher<>(column);
4445
}
45-
46+
47+
@Override
4648
public MultiRowInsertModel<T> build() {
4749
return MultiRowInsertModel.withRecords(records)
4850
.withTable(table)

src/main/java/org/mybatis/dynamic/sql/insert/MultiRowInsertModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717

1818
import java.util.Collection;
1919

20+
import org.jetbrains.annotations.NotNull;
2021
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertRenderer;
2122
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
2223
import org.mybatis.dynamic.sql.render.RenderingStrategy;
@@ -26,7 +27,8 @@ public class MultiRowInsertModel<T> extends AbstractMultiRowInsertModel<T> {
2627
private MultiRowInsertModel(Builder<T> builder) {
2728
super(builder);
2829
}
29-
30+
31+
@NotNull
3032
public MultiRowInsertStatementProvider<T> render(RenderingStrategy renderingStrategy) {
3133
return MultiRowInsertRenderer.withMultiRowInsertModel(this)
3234
.withRenderingStrategy(renderingStrategy)

0 commit comments

Comments
 (0)