Skip to content

Commit a3ed867

Browse files
committed
Apply java 17 best praticles
1 parent 7adfd84 commit a3ed867

File tree

92 files changed

+352
-413
lines changed

Some content is hidden

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

92 files changed

+352
-413
lines changed

querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ private List evaluateSingleSource(
163163
final List<Expression<?>> sources = Collections.<Expression<?>>singletonList(source);
164164
final Iterable<?> iterable = iterables.values().iterator().next();
165165
List<?> list;
166-
if (iterable instanceof List) {
167-
list = (List) iterable;
166+
if (iterable instanceof List<?> list1) {
167+
list = list1;
168168
} else {
169169
list = IteratorAdapter.asList(iterable.iterator());
170170
}

querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/MultiComparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public MultiComparator(Evaluator<Object[]> ev, boolean[] directions, boolean[] n
4545

4646
@Override
4747
public int compare(T o1, T o2) {
48-
if (o1 instanceof Object[]) {
49-
return innerCompare(ev.evaluate((Object[]) o1), ev.evaluate((Object[]) o2));
48+
if (o1 instanceof Object[] objects) {
49+
return innerCompare(ev.evaluate(objects), ev.evaluate((Object[]) o2));
5050
} else {
5151
return innerCompare(ev.evaluate(o1), ev.evaluate(o2));
5252
}

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/BooleanBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public BooleanBuilder clone() throws CloneNotSupportedException {
113113
public boolean equals(Object o) {
114114
if (o == this) {
115115
return true;
116-
} else if (o instanceof BooleanBuilder) {
117-
return Objects.equals(((BooleanBuilder) o).getValue(), predicate);
116+
} else if (o instanceof BooleanBuilder builder) {
117+
return Objects.equals(builder.getValue(), predicate);
118118
} else {
119119
return false;
120120
}

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/DefaultQueryMetadata.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void addLastJoin() {
158158
public void addJoin(JoinType joinType, Expression<?> expr) {
159159
addLastJoin();
160160
if (!exprInJoins.contains(expr)) {
161-
if (expr instanceof Path && ((Path<?>) expr).getMetadata().isRoot()) {
161+
if (expr instanceof Path<?> path && path.getMetadata().isRoot()) {
162162
exprInJoins.add(expr);
163163
} else {
164164
validate(expr);
@@ -378,8 +378,7 @@ public void setValidatingVisitor(ValidatingVisitor visitor) {
378378

379379
@Override
380380
public boolean equals(Object o) {
381-
if (o instanceof QueryMetadata) {
382-
var q = (QueryMetadata) o;
381+
if (o instanceof QueryMetadata q) {
383382
return q.getFlags().equals(flags)
384383
&& q.getGroupBy().equals(groupBy)
385384
&& Objects.equals(q.getHaving(), having)

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinExpression.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public int hashCode() {
107107
public boolean equals(Object o) {
108108
if (o == this) {
109109
return true;
110-
} else if (o instanceof JoinExpression) {
111-
var j = (JoinExpression) o;
110+
} else if (o instanceof JoinExpression j) {
112111
return Objects.equals(condition, j.condition)
113112
&& Objects.equals(target, j.target)
114113
&& Objects.equals(type, j.type);

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinFlag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ public int hashCode() {
106106
public boolean equals(Object obj) {
107107
if (obj == this) {
108108
return true;
109-
} else if (obj instanceof JoinFlag) {
110-
return ((JoinFlag) obj).flag.equals(flag);
109+
} else if (obj instanceof JoinFlag joinFlag) {
110+
return joinFlag.flag.equals(flag);
111111
} else {
112112
return false;
113113
}

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryFlag.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ public int hashCode() {
103103
public boolean equals(Object obj) {
104104
if (obj == this) {
105105
return true;
106-
} else if (obj instanceof QueryFlag) {
107-
var other = (QueryFlag) obj;
106+
} else if (obj instanceof QueryFlag other) {
108107
return other.position.equals(position) && other.flag.equals(flag);
109108
} else {
110109
return false;

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryModifiers.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ public <T> List<T> subList(List<T> list) {
120120
public boolean equals(Object o) {
121121
if (o == this) {
122122
return true;
123-
} else if (o instanceof QueryModifiers) {
124-
var qm = (QueryModifiers) o;
123+
} else if (o instanceof QueryModifiers qm) {
125124
return Objects.equals(qm.getLimit(), limit) && Objects.equals(qm.getOffset(), offset);
126125
} else {
127126
return false;

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/alias/Alias.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ public final class Alias {
162162
final Object current = aliasFactory.getCurrentAndReset();
163163
if (arg instanceof CollectionPath) {
164164
return (CollectionPath<D, SimpleExpression<D>>) arg; // NOSONAR
165-
} else if (arg instanceof ManagedObject) {
166-
return (CollectionPath<D, SimpleExpression<D>>) ((ManagedObject) arg).__mappedPath();
165+
} else if (arg instanceof ManagedObject object) {
166+
return (CollectionPath<D, SimpleExpression<D>>) object.__mappedPath();
167167
} else {
168168
return (CollectionPath<D, SimpleExpression<D>>) current;
169169
}
@@ -242,8 +242,8 @@ public final class Alias {
242242
final Object current = aliasFactory.getCurrentAndReset();
243243
if (arg instanceof ListPath) {
244244
return (ListPath<D, SimpleExpression<D>>) arg; // NOSONAR
245-
} else if (arg instanceof ManagedObject) {
246-
return (ListPath<D, SimpleExpression<D>>) ((ManagedObject) arg).__mappedPath();
245+
} else if (arg instanceof ManagedObject object) {
246+
return (ListPath<D, SimpleExpression<D>>) object.__mappedPath();
247247
} else {
248248
return (ListPath<D, SimpleExpression<D>>) current;
249249
}
@@ -272,8 +272,8 @@ public final class Alias {
272272
final Object current = aliasFactory.getCurrentAndReset();
273273
if (arg instanceof MapPath) {
274274
return (MapPath<K, V, SimpleExpression<V>>) arg; // NOSONAR
275-
} else if (arg instanceof ManagedObject) {
276-
return (MapPath<K, V, SimpleExpression<V>>) ((ManagedObject) arg).__mappedPath();
275+
} else if (arg instanceof ManagedObject object) {
276+
return (MapPath<K, V, SimpleExpression<V>>) object.__mappedPath();
277277
} else {
278278
return (MapPath<K, V, SimpleExpression<V>>) current;
279279
}
@@ -291,8 +291,8 @@ public final class Alias {
291291
final Object current = aliasFactory.getCurrentAndReset();
292292
if (arg instanceof SetPath) {
293293
return (SetPath<D, SimpleExpression<D>>) arg; // NOSONAR
294-
} else if (arg instanceof ManagedObject) {
295-
return (SetPath<D, SimpleExpression<D>>) ((ManagedObject) arg).__mappedPath();
294+
} else if (arg instanceof ManagedObject object) {
295+
return (SetPath<D, SimpleExpression<D>>) object.__mappedPath();
296296
} else {
297297
return (SetPath<D, SimpleExpression<D>>) current;
298298
}
@@ -351,8 +351,8 @@ public final class Alias {
351351
final Object current = aliasFactory.getCurrentAndReset();
352352
if (arg instanceof EntityPath<?>) {
353353
return (EntityPathBase<D>) arg; // NOSONAR
354-
} else if (arg instanceof ManagedObject) {
355-
return (EntityPathBase<D>) ((ManagedObject) arg).__mappedPath();
354+
} else if (arg instanceof ManagedObject object) {
355+
return (EntityPathBase<D>) object.__mappedPath();
356356
} else {
357357
return (EntityPathBase<D>) current;
358358
}
@@ -364,8 +364,8 @@ private static <D, P extends Path<D>> P getPath(D arg) {
364364
final Object current = aliasFactory.getCurrentAndReset();
365365
if (arg instanceof Path<?>) {
366366
return (P) arg;
367-
} else if (arg instanceof ManagedObject) {
368-
return (P) ((ManagedObject) arg).__mappedPath();
367+
} else if (arg instanceof ManagedObject object) {
368+
return (P) object.__mappedPath();
369369
} else {
370370
return (P) current;
371371
}
@@ -415,8 +415,8 @@ public static <A> A alias(Class<A> cl, String var) {
415415
@SuppressWarnings("unchecked")
416416
public static <D> Expression<D> getAny(D arg) {
417417
Object current = aliasFactory.getCurrentAndReset();
418-
if (arg instanceof ManagedObject) {
419-
return (Expression<D>) ((ManagedObject) arg).__mappedPath();
418+
if (arg instanceof ManagedObject object) {
419+
return (Expression<D>) object.__mappedPath();
420420
} else if (current != null) {
421421
return (Expression<D>) current;
422422
} else {

querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/AbstractGroupByTransformer.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,12 @@ protected AbstractGroupByTransformer(Expression<K> key, Expression<?>... express
7474
projection.add(key);
7575

7676
for (Expression<?> expr : expressions) {
77-
if (expr instanceof GroupExpression<?, ?>) {
78-
GroupExpression<?, ?> groupExpr = (GroupExpression<?, ?>) expr;
77+
if (expr instanceof GroupExpression<?, ?> groupExpr) {
7978
groupExpressions.add(groupExpr);
8079
Expression<?> colExpression = groupExpr.getExpression();
81-
if (colExpression instanceof Operation
82-
&& ((Operation) colExpression).getOperator() == Ops.ALIAS) {
83-
projection.add(((Operation) colExpression).getArg(0));
80+
if (colExpression instanceof Operation<?> operation
81+
&& operation.getOperator() == Ops.ALIAS) {
82+
projection.add(operation.getArg(0));
8483
} else {
8584
projection.add(colExpression);
8685
}
@@ -100,8 +99,8 @@ protected static FactoryExpression<Tuple> withoutGroupExpressions(
10099
final FactoryExpression<Tuple> expr) {
101100
List<Expression<?>> args = new ArrayList<>(expr.getArgs().size());
102101
for (Expression<?> arg : expr.getArgs()) {
103-
if (arg instanceof GroupExpression) {
104-
args.add(((GroupExpression) arg).getExpression());
102+
if (arg instanceof GroupExpression<?, ?> expression) {
103+
args.add(expression.getExpression());
105104
} else {
106105
args.add(arg);
107106
}

0 commit comments

Comments
 (0)