Skip to content

Commit ae2b10b

Browse files
committed
Checkstyle and Sonar Updates
1 parent 554d4ab commit ae2b10b

File tree

9 files changed

+62
-55
lines changed

9 files changed

+62
-55
lines changed

src/main/java/org/mybatis/dynamic/sql/delete/DeleteDSL.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ protected DeleteWhereBuilder getThis() {
8181
return this;
8282
}
8383

84-
@Override
8584
protected WhereModel buildWhereModel() {
86-
return super.buildWhereModel();
85+
return internalBuild();
8786
}
8887
}
8988
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
import org.mybatis.dynamic.sql.where.AbstractWhereDSL;
3535
import org.mybatis.dynamic.sql.where.AbstractWhereSupportingDSL;
3636

37-
public abstract class AbstractQueryExpressionDSL<W extends AbstractWhereDSL<?>, T extends AbstractQueryExpressionDSL<W, T, R>, R>
37+
public abstract class AbstractQueryExpressionDSL<
38+
W extends AbstractWhereDSL<?>,
39+
T extends AbstractQueryExpressionDSL<W, T, R>,
40+
R
41+
>
3842
extends AbstractWhereSupportingDSL<W>
3943
implements Buildable<R> {
4044

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
*
3636
* @author Jeff Butler
3737
*/
38-
public class CountDSL<R> extends AbstractQueryExpressionDSL<CountDSL<R>.CountWhereBuilder, CountDSL<R>, R> implements Buildable<R> {
38+
public class CountDSL<R> extends AbstractQueryExpressionDSL<CountDSL<R>.CountWhereBuilder, CountDSL<R>, R>
39+
implements Buildable<R> {
3940

4041
private final Function<SelectModel, R> adapterFunction;
4142
private final CountWhereBuilder whereBuilder = new CountWhereBuilder();
@@ -130,9 +131,8 @@ protected CountWhereBuilder getThis() {
130131
return this;
131132
}
132133

133-
@Override
134134
protected WhereModel buildWhereModel() {
135-
return super.buildWhereModel();
135+
return internalBuild();
136136
}
137137
}
138138
}

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@
2323

2424
import org.jetbrains.annotations.NotNull;
2525
import org.mybatis.dynamic.sql.BasicColumn;
26-
import org.mybatis.dynamic.sql.BindableColumn;
2726
import org.mybatis.dynamic.sql.SortSpecification;
28-
import org.mybatis.dynamic.sql.SqlCriterion;
2927
import org.mybatis.dynamic.sql.SqlTable;
3028
import org.mybatis.dynamic.sql.TableExpression;
31-
import org.mybatis.dynamic.sql.VisitableCondition;
3229
import org.mybatis.dynamic.sql.select.join.JoinCondition;
3330
import org.mybatis.dynamic.sql.select.join.JoinCriterion;
3431
import org.mybatis.dynamic.sql.select.join.JoinSpecification;
3532
import org.mybatis.dynamic.sql.select.join.JoinType;
3633
import org.mybatis.dynamic.sql.util.Buildable;
3734
import org.mybatis.dynamic.sql.where.AbstractWhereDSL;
38-
import org.mybatis.dynamic.sql.where.WhereApplier;
35+
import org.mybatis.dynamic.sql.where.AbstractWhereSupportingDSL;
3936
import org.mybatis.dynamic.sql.where.WhereModel;
4037

41-
public class QueryExpressionDSL<R> extends AbstractQueryExpressionDSL<QueryExpressionDSL<R>.QueryExpressionWhereBuilder, QueryExpressionDSL<R>, R>
38+
public class QueryExpressionDSL<R>
39+
extends AbstractQueryExpressionDSL<QueryExpressionDSL<R>.QueryExpressionWhereBuilder, QueryExpressionDSL<R>, R>
4240
implements Buildable<R> {
4341

4442
private final String connector;
@@ -284,9 +282,8 @@ protected QueryExpressionWhereBuilder getThis() {
284282
return this;
285283
}
286284

287-
@Override
288285
protected WhereModel buildWhereModel() {
289-
return super.buildWhereModel();
286+
return internalBuild();
290287
}
291288
}
292289

@@ -309,7 +306,8 @@ public JoinSpecificationFinisher on(BasicColumn joinColumn, JoinCondition onJoin
309306
}
310307
}
311308

312-
public class JoinSpecificationFinisher implements Buildable<R> {
309+
public class JoinSpecificationFinisher extends AbstractWhereSupportingDSL<QueryExpressionWhereBuilder>
310+
implements Buildable<R> {
313311
private final JoinSpecification.Builder joinSpecificationBuilder;
314312

315313
public JoinSpecificationFinisher(TableExpression table, BasicColumn joinColumn,
@@ -349,19 +347,11 @@ public R build() {
349347
return QueryExpressionDSL.this.build();
350348
}
351349

350+
@Override
352351
public QueryExpressionWhereBuilder where() {
353352
return QueryExpressionDSL.this.where();
354353
}
355354

356-
public <T> QueryExpressionWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition,
357-
SqlCriterion<?>...subCriteria) {
358-
return QueryExpressionDSL.this.where(column, condition, subCriteria);
359-
}
360-
361-
public QueryExpressionWhereBuilder applyWhere(WhereApplier whereApplier) {
362-
return QueryExpressionDSL.this.applyWhere(whereApplier);
363-
}
364-
365355
public JoinSpecificationFinisher and(BasicColumn joinColumn, JoinCondition joinCondition) {
366356
JoinCriterion joinCriterion = new JoinCriterion.Builder()
367357
.withConnector("and") //$NON-NLS-1$

src/main/java/org/mybatis/dynamic/sql/update/UpdateDSL.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ protected UpdateWhereBuilder getThis() {
153153
return this;
154154
}
155155

156-
@Override
157156
protected WhereModel buildWhereModel() {
158-
return super.buildWhereModel();
157+
return internalBuild();
159158
}
160159
}
161160
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private <S> void addCriterion(String connector, BindableColumn<S> column, Visita
125125
criteria.add(criterion);
126126
}
127127

128-
protected WhereModel buildWhereModel() {
128+
protected WhereModel internalBuild() {
129129
return WhereModel.of(criteria);
130130
}
131131

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1+
/*
2+
* Copyright 2016-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.mybatis.dynamic.sql.where;
217

3-
import org.mybatis.dynamic.sql.BindableColumn;
4-
import org.mybatis.dynamic.sql.SqlCriterion;
5-
import org.mybatis.dynamic.sql.VisitableCondition;
6-
718
import java.util.Arrays;
819
import java.util.List;
920
import java.util.function.Consumer;
1021

22+
import org.mybatis.dynamic.sql.BindableColumn;
23+
import org.mybatis.dynamic.sql.SqlCriterion;
24+
import org.mybatis.dynamic.sql.VisitableCondition;
25+
1126
/**
1227
* Base class for DSLs that support where clauses.
1328
*
1429
* @param <W> the implementation of the Where DSL.
1530
*/
1631
public abstract class AbstractWhereSupportingDSL<W extends AbstractWhereDSL<?>> {
1732

33+
public abstract W where();
34+
1835
public <T> W where(BindableColumn<T> column, VisitableCondition<T> condition, SqlCriterion<?>...subCriteria) {
1936
return where(column, condition, Arrays.asList(subCriteria));
2037
}
@@ -32,6 +49,4 @@ private W apply(Consumer<W> block) {
3249
block.accept(dsl);
3350
return dsl;
3451
}
35-
36-
public abstract W where();
3752
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public static WhereDSL where() {
3131
}
3232

3333
public WhereModel build() {
34-
return buildWhereModel();
34+
return internalBuild();
3535
}
3636
}

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinBaseBuilders.kt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ abstract class KotlinBaseBuilder<D: AbstractWhereSupportingDSL<*>, B: KotlinBase
3838
}
3939

4040
fun <T> where(column: BindableColumn<T>, condition: VisitableCondition<T>, subCriteria: CriteriaReceiver) =
41-
applyToWhere(subCriteria) { sq ->
42-
where(column, condition, sq)
41+
applyToWhere(subCriteria) { sc ->
42+
where(column, condition, sc)
4343
}
4444

4545
fun applyWhere(whereApplier: WhereApplier) =
@@ -53,8 +53,8 @@ abstract class KotlinBaseBuilder<D: AbstractWhereSupportingDSL<*>, B: KotlinBase
5353
}
5454

5555
fun <T> and(column: BindableColumn<T>, condition: VisitableCondition<T>, subCriteria: CriteriaReceiver) =
56-
applyToWhere(subCriteria) { sq ->
57-
and(column, condition, sq)
56+
applyToWhere(subCriteria) { sc ->
57+
and(column, condition, sc)
5858
}
5959

6060
fun <T> or(column: BindableColumn<T>, condition: VisitableCondition<T>) =
@@ -63,24 +63,24 @@ abstract class KotlinBaseBuilder<D: AbstractWhereSupportingDSL<*>, B: KotlinBase
6363
}
6464

6565
fun <T> or(column: BindableColumn<T>, condition: VisitableCondition<T>, subCriteria: CriteriaReceiver) =
66-
applyToWhere(subCriteria) { sq ->
67-
or(column, condition, sq)
66+
applyToWhere(subCriteria) { sc ->
67+
or(column, condition, sc)
6868
}
6969

7070
fun allRows() = self()
7171

72-
private fun applyToWhere(block: AbstractWhereDSL<*>.() -> Unit): B {
73-
getDsl().where().apply(block)
74-
return self()
75-
}
72+
private fun applyToWhere(block: AbstractWhereDSL<*>.() -> Unit) =
73+
self().also{
74+
getDsl().where().apply(block)
75+
}
7676

7777
private fun applyToWhere(
7878
subCriteria: CriteriaReceiver,
7979
block: AbstractWhereDSL<*>.(List<SqlCriterion<*>>) -> Unit
80-
): B {
81-
getDsl().where().block(CriteriaCollector().apply(subCriteria).criteria)
82-
return self()
83-
}
80+
) =
81+
self().also {
82+
getDsl().where().block(CriteriaCollector().apply(subCriteria).criteria)
83+
}
8484

8585
protected abstract fun self(): B
8686

@@ -163,17 +163,17 @@ abstract class KotlinBaseJoiningBuilder<D: AbstractQueryExpressionDSL<*, *, *>,
163163
rightJoin(sq, sq.correlationName, jc.onJoinCriterion, jc.andJoinCriteria)
164164
}
165165

166-
private fun applyToDsl(joinCriteria: JoinReceiver, applyJoin: D.(JoinCollector) -> Unit): B {
167-
getDsl().applyJoin(JoinCollector().apply(joinCriteria))
168-
return self()
169-
}
166+
private fun applyToDsl(joinCriteria: JoinReceiver, applyJoin: D.(JoinCollector) -> Unit) =
167+
self().also {
168+
getDsl().applyJoin(JoinCollector().apply(joinCriteria))
169+
}
170170

171171
private fun applyToDsl(
172172
subQuery: KotlinQualifiedSubQueryBuilder.() -> Unit,
173173
joinCriteria: JoinReceiver,
174174
applyJoin: D.(KotlinQualifiedSubQueryBuilder, JoinCollector) -> Unit
175-
): B {
176-
getDsl().applyJoin(KotlinQualifiedSubQueryBuilder().apply(subQuery), JoinCollector().apply(joinCriteria))
177-
return self()
178-
}
175+
) =
176+
self().also {
177+
getDsl().applyJoin(KotlinQualifiedSubQueryBuilder().apply(subQuery), JoinCollector().apply(joinCriteria))
178+
}
179179
}

0 commit comments

Comments
 (0)