Skip to content

Commit d7ad798

Browse files
authored
Merge pull request #417 from domaframework/improve-docs
Improve documents and polish the related code
2 parents cd77a14 + 15f95a2 commit d7ad798

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1059
-613
lines changed

docs/criteria-api.rst

Lines changed: 526 additions & 186 deletions
Large diffs are not rendered by default.

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/command/AssociateCommand.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.seasar.doma.jdbc.criteria.command;
22

3-
import static java.util.stream.Collectors.*;
3+
import static java.util.stream.Collectors.toList;
44

55
import java.util.LinkedHashMap;
66
import java.util.List;
@@ -21,10 +21,8 @@ public class AssociateCommand<ENTITY> implements Command<List<ENTITY>> {
2121
private final SelectQuery query;
2222

2323
public AssociateCommand(SelectContext context, SelectQuery query) {
24-
Objects.requireNonNull(context);
25-
Objects.requireNonNull(query);
26-
this.context = context;
27-
this.query = query;
24+
this.context = Objects.requireNonNull(context);
25+
this.query = Objects.requireNonNull(query);
2826
}
2927

3028
@Override

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/command/EntityKey.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ public final class EntityKey {
1010
private final List<?> items;
1111

1212
public EntityKey(EntityDef<?> entityDef, List<?> items) {
13-
Objects.requireNonNull(entityDef);
13+
this.entityDef = Objects.requireNonNull(entityDef);
1414
Objects.requireNonNull(items);
15-
this.entityDef = entityDef;
1615
this.items = Collections.unmodifiableList(items);
1716
}
1817

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/command/EntityPoolIterationHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public class EntityPoolIterationHandler
1414

1515
public EntityPoolIterationHandler(List<EntityDef<?>> entityDefs) {
1616
super(new ResultListCallback<>());
17-
Objects.requireNonNull(entityDefs);
18-
this.entityDefs = entityDefs;
17+
this.entityDefs = Objects.requireNonNull(entityDefs);
1918
}
2019

2120
@Override

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/command/EntityPoolProvider.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@
2727
import org.seasar.doma.wrapper.Wrapper;
2828

2929
public class EntityPoolProvider implements ObjectProvider<EntityPool> {
30-
3130
private final List<EntityDef<?>> entityDefs;
32-
3331
private final JdbcMappingVisitor jdbcMappingVisitor;
3432

3533
public EntityPoolProvider(List<EntityDef<?>> entityDefs, Query query) {
36-
Objects.requireNonNull(entityDefs);
34+
this.entityDefs = Objects.requireNonNull(entityDefs);
3735
Objects.requireNonNull(query);
38-
this.entityDefs = entityDefs;
3936
this.jdbcMappingVisitor = query.getConfig().getDialect().getJdbcMappingVisitor();
4037
}
4138

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/command/MappedResultProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public class MappedResultProvider<RESULT> extends AbstractObjectProvider<RESULT>
1717

1818
public MappedResultProvider(Query query, Function<Row, RESULT> mapper) {
1919
Objects.requireNonNull(query);
20-
Objects.requireNonNull(mapper);
21-
this.mapper = mapper;
20+
this.mapper = Objects.requireNonNull(mapper);
2221
this.jdbcMappingVisitor = query.getConfig().getDialect().getJdbcMappingVisitor();
2322
}
2423

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/context/Criterion.java

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Collections;
44
import java.util.List;
5+
import java.util.Objects;
56
import org.seasar.doma.jdbc.criteria.option.LikeOption;
67
import org.seasar.doma.jdbc.criteria.tuple.Tuple2;
78

@@ -13,8 +14,8 @@ class Eq implements Criterion {
1314
public final Operand right;
1415

1516
public Eq(Operand.Prop left, Operand right) {
16-
this.left = left;
17-
this.right = right;
17+
this.left = Objects.requireNonNull(left);
18+
this.right = Objects.requireNonNull(right);
1819
}
1920

2021
@Override
@@ -28,8 +29,8 @@ class Ne implements Criterion {
2829
public final Operand right;
2930

3031
public Ne(Operand.Prop left, Operand right) {
31-
this.left = left;
32-
this.right = right;
32+
this.left = Objects.requireNonNull(left);
33+
this.right = Objects.requireNonNull(right);
3334
}
3435

3536
@Override
@@ -43,8 +44,8 @@ class Gt implements Criterion {
4344
public final Operand right;
4445

4546
public Gt(Operand.Prop left, Operand right) {
46-
this.left = left;
47-
this.right = right;
47+
this.left = Objects.requireNonNull(left);
48+
this.right = Objects.requireNonNull(right);
4849
}
4950

5051
@Override
@@ -58,8 +59,8 @@ class Ge implements Criterion {
5859
public final Operand right;
5960

6061
public Ge(Operand.Prop left, Operand right) {
61-
this.left = left;
62-
this.right = right;
62+
this.left = Objects.requireNonNull(left);
63+
this.right = Objects.requireNonNull(right);
6364
}
6465

6566
@Override
@@ -73,8 +74,8 @@ class Lt implements Criterion {
7374
public final Operand right;
7475

7576
public Lt(Operand.Prop left, Operand right) {
76-
this.left = left;
77-
this.right = right;
77+
this.left = Objects.requireNonNull(left);
78+
this.right = Objects.requireNonNull(right);
7879
}
7980

8081
@Override
@@ -88,8 +89,8 @@ class Le implements Criterion {
8889
public final Operand right;
8990

9091
public Le(Operand.Prop left, Operand right) {
91-
this.left = left;
92-
this.right = right;
92+
this.left = Objects.requireNonNull(left);
93+
this.right = Objects.requireNonNull(right);
9394
}
9495

9596
@Override
@@ -102,7 +103,7 @@ class IsNull implements Criterion {
102103
public final Operand.Prop prop;
103104

104105
public IsNull(Operand.Prop prop) {
105-
this.prop = prop;
106+
this.prop = Objects.requireNonNull(prop);
106107
}
107108

108109
@Override
@@ -115,7 +116,7 @@ class IsNotNull implements Criterion {
115116
public final Operand.Prop prop;
116117

117118
public IsNotNull(Operand.Prop prop) {
118-
this.prop = prop;
119+
this.prop = Objects.requireNonNull(prop);
119120
}
120121

121122
@Override
@@ -130,9 +131,9 @@ class Like implements Criterion {
130131
public final LikeOption option;
131132

132133
public Like(Operand.Prop left, Operand right, LikeOption option) {
133-
this.left = left;
134-
this.right = right;
135-
this.option = option;
134+
this.left = Objects.requireNonNull(left);
135+
this.right = Objects.requireNonNull(right);
136+
this.option = Objects.requireNonNull(option);
136137
}
137138

138139
@Override
@@ -147,9 +148,9 @@ class NotLike implements Criterion {
147148
public final LikeOption option;
148149

149150
public NotLike(Operand.Prop left, Operand right, LikeOption option) {
150-
this.left = left;
151-
this.right = right;
152-
this.option = option;
151+
this.left = Objects.requireNonNull(left);
152+
this.right = Objects.requireNonNull(right);
153+
this.option = Objects.requireNonNull(option);
153154
}
154155

155156
@Override
@@ -164,9 +165,9 @@ class Between implements Criterion {
164165
public final Operand.Param end;
165166

166167
public Between(Operand.Prop prop, Operand.Param start, Operand.Param end) {
167-
this.prop = prop;
168-
this.start = start;
169-
this.end = end;
168+
this.prop = Objects.requireNonNull(prop);
169+
this.start = Objects.requireNonNull(start);
170+
this.end = Objects.requireNonNull(end);
170171
}
171172

172173
@Override
@@ -180,8 +181,8 @@ class In implements Criterion {
180181
public final List<Operand.Param> right;
181182

182183
public In(Operand.Prop left, List<Operand.Param> right) {
183-
this.left = left;
184-
this.right = right;
184+
this.left = Objects.requireNonNull(left);
185+
this.right = Objects.requireNonNull(right);
185186
}
186187

187188
@Override
@@ -195,8 +196,8 @@ class NotIn implements Criterion {
195196
public final List<Operand.Param> right;
196197

197198
public NotIn(Operand.Prop left, List<Operand.Param> right) {
198-
this.left = left;
199-
this.right = right;
199+
this.left = Objects.requireNonNull(left);
200+
this.right = Objects.requireNonNull(right);
200201
}
201202

202203
@Override
@@ -210,8 +211,8 @@ class InSubQuery implements Criterion {
210211
public final SelectContext right;
211212

212213
public InSubQuery(Operand.Prop left, SelectContext right) {
213-
this.left = left;
214-
this.right = right;
214+
this.left = Objects.requireNonNull(left);
215+
this.right = Objects.requireNonNull(right);
215216
}
216217

217218
@Override
@@ -225,8 +226,8 @@ class NotInSubQuery implements Criterion {
225226
public final SelectContext right;
226227

227228
public NotInSubQuery(Operand.Prop left, SelectContext right) {
228-
this.left = left;
229-
this.right = right;
229+
this.left = Objects.requireNonNull(left);
230+
this.right = Objects.requireNonNull(right);
230231
}
231232

232233
@Override
@@ -241,8 +242,8 @@ class InTuple2 implements Criterion {
241242

242243
public InTuple2(
243244
Tuple2<Operand.Prop, Operand.Prop> left, List<Tuple2<Operand.Param, Operand.Param>> right) {
244-
this.left = left;
245-
this.right = right;
245+
this.left = Objects.requireNonNull(left);
246+
this.right = Objects.requireNonNull(right);
246247
}
247248

248249
@Override
@@ -257,8 +258,8 @@ class NotInTuple2 implements Criterion {
257258

258259
public NotInTuple2(
259260
Tuple2<Operand.Prop, Operand.Prop> left, List<Tuple2<Operand.Param, Operand.Param>> right) {
260-
this.left = left;
261-
this.right = right;
261+
this.left = Objects.requireNonNull(left);
262+
this.right = Objects.requireNonNull(right);
262263
}
263264

264265
@Override
@@ -272,8 +273,8 @@ class InTuple2SubQuery implements Criterion {
272273
public final SelectContext right;
273274

274275
public InTuple2SubQuery(Tuple2<Operand.Prop, Operand.Prop> left, SelectContext right) {
275-
this.left = left;
276-
this.right = right;
276+
this.left = Objects.requireNonNull(left);
277+
this.right = Objects.requireNonNull(right);
277278
}
278279

279280
@Override
@@ -287,8 +288,8 @@ class NotInTuple2SubQuery implements Criterion {
287288
public final SelectContext right;
288289

289290
public NotInTuple2SubQuery(Tuple2<Operand.Prop, Operand.Prop> left, SelectContext right) {
290-
this.left = left;
291-
this.right = right;
291+
this.left = Objects.requireNonNull(left);
292+
this.right = Objects.requireNonNull(right);
292293
}
293294

294295
@Override
@@ -301,7 +302,7 @@ class Exists implements Criterion {
301302
public final SelectContext context;
302303

303304
public Exists(SelectContext context) {
304-
this.context = context;
305+
this.context = Objects.requireNonNull(context);
305306
}
306307

307308
@Override
@@ -314,7 +315,7 @@ class NotExists implements Criterion {
314315
public final SelectContext context;
315316

316317
public NotExists(SelectContext context) {
317-
this.context = context;
318+
this.context = Objects.requireNonNull(context);
318319
}
319320

320321
@Override
@@ -327,6 +328,7 @@ class And implements Criterion {
327328
public final List<Criterion> criterionList;
328329

329330
public And(List<Criterion> criterionList) {
331+
Objects.requireNonNull(criterionList);
330332
this.criterionList = Collections.unmodifiableList(criterionList);
331333
}
332334

@@ -340,6 +342,7 @@ class Or implements Criterion {
340342
public final List<Criterion> criterionList;
341343

342344
public Or(List<Criterion> criterionList) {
345+
Objects.requireNonNull(criterionList);
343346
this.criterionList = Collections.unmodifiableList(criterionList);
344347
}
345348

@@ -353,6 +356,7 @@ class Not implements Criterion {
353356
public final List<Criterion> criterionList;
354357

355358
public Not(List<Criterion> criterionList) {
359+
Objects.requireNonNull(criterionList);
356360
this.criterionList = Collections.unmodifiableList(criterionList);
357361
}
358362

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/context/DeleteContext.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ public class DeleteContext implements Context {
1010
public final EntityDef<?> entityDef;
1111
public final List<EntityDef<?>> entityDefs;
1212
public List<Criterion> where = new ArrayList<>();
13-
public final DeleteSettings options = new DeleteSettings();
13+
public final DeleteSettings settings = new DeleteSettings();
1414

1515
public DeleteContext(EntityDef<?> entityDef) {
16-
Objects.requireNonNull(entityDef);
17-
this.entityDef = entityDef;
16+
this.entityDef = Objects.requireNonNull(entityDef);
1817
this.entityDefs = Collections.singletonList(entityDef);
1918
}
2019

@@ -35,6 +34,6 @@ public void setWhere(List<Criterion> where) {
3534

3635
@Override
3736
public DeleteSettings getSettings() {
38-
return options;
37+
return settings;
3938
}
4039
}

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/context/DeleteSettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.seasar.doma.jdbc.criteria.context;
22

33
public class DeleteSettings extends Settings {
4-
int batchSize = 0;
5-
boolean allowEmptyWhere;
4+
private int batchSize = 0;
5+
private boolean allowEmptyWhere;
66

77
public int getBatchSize() {
88
return batchSize;

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/context/InsertContext.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
public class InsertContext implements Context {
1111
public final EntityDef<?> entityDef;
1212
public final List<EntityDef<?>> entityDefs;
13-
public Map<Operand.Prop, Operand.Param> values = new LinkedHashMap<>();
14-
public final InsertSettings options = new InsertSettings();
13+
public final Map<Operand.Prop, Operand.Param> values = new LinkedHashMap<>();
14+
public final InsertSettings settings = new InsertSettings();
1515

1616
public InsertContext(EntityDef<?> entityDef) {
17-
Objects.requireNonNull(entityDef);
18-
this.entityDef = entityDef;
17+
this.entityDef = Objects.requireNonNull(entityDef);
1918
this.entityDefs = Collections.singletonList(entityDef);
2019
}
2120

@@ -36,6 +35,6 @@ public void setWhere(List<Criterion> where) {
3635

3736
@Override
3837
public InsertSettings getSettings() {
39-
return options;
38+
return settings;
4039
}
4140
}

0 commit comments

Comments
 (0)