Skip to content

Commit 3ec17f7

Browse files
committed
Refactor nested class
1 parent 06983bf commit 3ec17f7

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.mybatis.dynamic.sql.util.Buildable;
2727

2828
public class MultiSelectDSL implements Buildable<MultiSelectModel> {
29-
private final List<MultiSelectModel.UnionQuery> unionQueries = new ArrayList<>();
29+
private final List<UnionQuery> unionQueries = new ArrayList<>();
3030
private final SelectModel initialSelect;
3131
private OrderByModel orderByModel;
3232
private Long limit;
@@ -38,12 +38,12 @@ public MultiSelectDSL(Buildable<SelectModel> builder) {
3838
}
3939

4040
public MultiSelectDSL union(Buildable<SelectModel> builder) {
41-
unionQueries.add(new MultiSelectModel.UnionQuery("union", builder.build())); //$NON-NLS-1$
41+
unionQueries.add(new UnionQuery("union", builder.build())); //$NON-NLS-1$
4242
return this;
4343
}
4444

4545
public MultiSelectDSL unionAll(Buildable<SelectModel> builder) {
46-
unionQueries.add(new MultiSelectModel.UnionQuery("union all", builder.build())); //$NON-NLS-1$
46+
unionQueries.add(new UnionQuery("union all", builder.build())); //$NON-NLS-1$
4747
return this;
4848
}
4949

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,4 @@ public MultiSelectModel build() {
101101
return new MultiSelectModel(this);
102102
}
103103
}
104-
105-
public static class UnionQuery {
106-
private final String connector;
107-
private final SelectModel selectModel;
108-
109-
public UnionQuery(String connector, SelectModel selectModel) {
110-
this.connector = Objects.requireNonNull(connector);
111-
this.selectModel = Objects.requireNonNull(selectModel);
112-
}
113-
114-
public String connector() {
115-
return connector;
116-
}
117-
118-
public SelectModel selectModel() {
119-
return selectModel;
120-
}
121-
}
122104
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2016-2023 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+
* https://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+
*/
16+
package org.mybatis.dynamic.sql.select;
17+
18+
import java.util.Objects;
19+
20+
public class UnionQuery {
21+
private final String connector;
22+
private final SelectModel selectModel;
23+
24+
public UnionQuery(String connector, SelectModel selectModel) {
25+
this.connector = Objects.requireNonNull(connector);
26+
this.selectModel = Objects.requireNonNull(selectModel);
27+
}
28+
29+
public String connector() {
30+
return connector;
31+
}
32+
33+
public SelectModel selectModel() {
34+
return selectModel;
35+
}
36+
}

src/main/java/org/mybatis/dynamic/sql/select/render/MultiSelectRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.mybatis.dynamic.sql.select.MultiSelectModel;
2727
import org.mybatis.dynamic.sql.select.PagingModel;
2828
import org.mybatis.dynamic.sql.select.SelectModel;
29+
import org.mybatis.dynamic.sql.select.UnionQuery;
2930
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
3031
import org.mybatis.dynamic.sql.util.FragmentCollector;
3132

@@ -72,7 +73,7 @@ private FragmentAndParameters renderSelect(SelectModel selectModel) {
7273
.build();
7374
}
7475

75-
private FragmentAndParameters renderSelect(MultiSelectModel.UnionQuery unionQuery) {
76+
private FragmentAndParameters renderSelect(UnionQuery unionQuery) {
7677
SelectStatementProvider selectStatement = SelectRenderer.withSelectModel(unionQuery.selectModel())
7778
.withRenderingStrategy(renderingStrategy)
7879
.withSequence(sequence)

0 commit comments

Comments
 (0)