Skip to content

Commit 96c1889

Browse files
authored
Merge pull request #223 from jeffgbutler/kotlin-polishing
Kotlin Polishing
2 parents f8ad7be + ca6b474 commit 96c1889

33 files changed

+489
-365
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)

src/main/java/org/mybatis/dynamic/sql/select/GroupByModel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 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.
@@ -16,7 +16,7 @@
1616
package org.mybatis.dynamic.sql.select;
1717

1818
import java.util.ArrayList;
19-
import java.util.Arrays;
19+
import java.util.Collection;
2020
import java.util.List;
2121
import java.util.function.Function;
2222
import java.util.stream.Stream;
@@ -26,15 +26,15 @@
2626
public class GroupByModel {
2727
private List<BasicColumn> columns = new ArrayList<>();
2828

29-
private GroupByModel(List<BasicColumn> columns) {
29+
private GroupByModel(Collection<BasicColumn> columns) {
3030
this.columns.addAll(columns);
3131
}
3232

3333
public <R> Stream<R> mapColumns(Function<BasicColumn, R> mapper) {
3434
return columns.stream().map(mapper);
3535
}
3636

37-
public static GroupByModel of(BasicColumn...columns) {
38-
return new GroupByModel(Arrays.asList(columns));
37+
public static GroupByModel of(Collection<BasicColumn> columns) {
38+
return new GroupByModel(columns);
3939
}
4040
}

src/main/java/org/mybatis/dynamic/sql/select/OrderByModel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017 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.
@@ -16,7 +16,7 @@
1616
package org.mybatis.dynamic.sql.select;
1717

1818
import java.util.ArrayList;
19-
import java.util.Arrays;
19+
import java.util.Collection;
2020
import java.util.List;
2121
import java.util.function.Function;
2222
import java.util.stream.Stream;
@@ -26,15 +26,15 @@
2626
public class OrderByModel {
2727
private List<SortSpecification> columns = new ArrayList<>();
2828

29-
private OrderByModel(List<SortSpecification> columns) {
29+
private OrderByModel(Collection<SortSpecification> columns) {
3030
this.columns.addAll(columns);
3131
}
3232

3333
public <R> Stream<R> mapColumns(Function<SortSpecification, R> mapper) {
3434
return columns.stream().map(mapper);
3535
}
3636

37-
public static OrderByModel of(SortSpecification...columns) {
38-
return new OrderByModel(Arrays.asList(columns));
37+
public static OrderByModel of(Collection<SortSpecification> columns) {
38+
return new OrderByModel(columns);
3939
}
4040
}

src/main/java/org/mybatis/dynamic/sql/select/QueryExpressionDSL.java

Lines changed: 9 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.
@@ -115,11 +115,19 @@ public JoinSpecificationStarter fullJoin(SqlTable joinTable, String tableAlias)
115115
}
116116

117117
public GroupByFinisher groupBy(BasicColumn...columns) {
118+
return groupBy(Arrays.asList(columns));
119+
}
120+
121+
public GroupByFinisher groupBy(Collection<BasicColumn> columns) {
118122
groupByModel = GroupByModel.of(columns);
119123
return new GroupByFinisher();
120124
}
121125

122126
public SelectDSL<R> orderBy(SortSpecification...columns) {
127+
return orderBy(Arrays.asList(columns));
128+
}
129+
130+
public SelectDSL<R> orderBy(Collection<SortSpecification> columns) {
123131
selectDSL.orderBy(columns);
124132
return selectDSL;
125133
}

src/main/java/org/mybatis/dynamic/sql/select/SelectDSL.java

Lines changed: 2 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.
@@ -138,7 +138,7 @@ QueryExpressionDSL<R> newQueryExpression(FromGatherer<R> fromGatherer, String ta
138138
return queryExpression;
139139
}
140140

141-
void orderBy(SortSpecification...columns) {
141+
void orderBy(Collection<SortSpecification> columns) {
142142
orderByModel = OrderByModel.of(columns);
143143
}
144144

src/main/java/org/mybatis/dynamic/sql/where/AbstractWhereDSL.java

Lines changed: 12 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.
@@ -19,6 +19,7 @@
1919
import java.util.Arrays;
2020
import java.util.List;
2121

22+
import org.jetbrains.annotations.NotNull;
2223
import org.mybatis.dynamic.sql.BindableColumn;
2324
import org.mybatis.dynamic.sql.SqlCriterion;
2425
import org.mybatis.dynamic.sql.VisitableCondition;
@@ -30,51 +31,61 @@ protected AbstractWhereDSL() {
3031
super();
3132
}
3233

34+
@NotNull
3335
public <S> T where(BindableColumn<S> column, VisitableCondition<S> condition) {
3436
addCriterion(column, condition);
3537
return getThis();
3638
}
3739

40+
@NotNull
3841
public <S> T where(BindableColumn<S> column, VisitableCondition<S> condition, SqlCriterion<?>...subCriteria) {
3942
addCriterion(column, condition, Arrays.asList(subCriteria));
4043
return getThis();
4144
}
4245

46+
@NotNull
4347
public <S> T where(BindableColumn<S> column, VisitableCondition<S> condition, List<SqlCriterion<?>> subCriteria) {
4448
addCriterion(column, condition, subCriteria);
4549
return getThis();
4650
}
4751

52+
@NotNull
4853
public T applyWhere(WhereApplier whereApplier) {
4954
whereApplier.accept(this);
5055
return getThis();
5156
}
5257

58+
@NotNull
5359
public <S> T and(BindableColumn<S> column, VisitableCondition<S> condition) {
5460
addCriterion("and", column, condition); //$NON-NLS-1$
5561
return getThis();
5662
}
5763

64+
@NotNull
5865
public <S> T and(BindableColumn<S> column, VisitableCondition<S> condition, SqlCriterion<?>...subCriteria) {
5966
addCriterion("and", column, condition, Arrays.asList(subCriteria)); //$NON-NLS-1$
6067
return getThis();
6168
}
6269

70+
@NotNull
6371
public <S> T and(BindableColumn<S> column, VisitableCondition<S> condition, List<SqlCriterion<?>> subCriteria) {
6472
addCriterion("and", column, condition, subCriteria); //$NON-NLS-1$
6573
return getThis();
6674
}
6775

76+
@NotNull
6877
public <S> T or(BindableColumn<S> column, VisitableCondition<S> condition) {
6978
addCriterion("or", column, condition); //$NON-NLS-1$
7079
return getThis();
7180
}
7281

82+
@NotNull
7383
public <S> T or(BindableColumn<S> column, VisitableCondition<S> condition, SqlCriterion<?>...subCriteria) {
7484
addCriterion("or", column, condition, Arrays.asList(subCriteria)); //$NON-NLS-1$
7585
return getThis();
7686
}
7787

88+
@NotNull
7889
public <S> T or(BindableColumn<S> column, VisitableCondition<S> condition, List<SqlCriterion<?>> subCriteria) {
7990
addCriterion("or", column, condition, subCriteria); //$NON-NLS-1$
8091
return getThis();

0 commit comments

Comments
 (0)