Skip to content

Commit e7bc5c3

Browse files
committed
polishing
1 parent c1cd613 commit e7bc5c3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Diff for: src/main/java/org/springframework/data/mapping/model/PersistentEntityIsNewStrategy.java

+13-9
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,31 @@ class PersistentEntityIsNewStrategy implements IsNewStrategy {
4141
* Creates a new {@link PersistentEntityIsNewStrategy} for the given entity.
4242
*
4343
* @param entity must not be {@literal null}.
44+
* @param idOnly {@code true} if should consider only the ID property of the {@link PersistentEntity}, {@code false}
45+
* if other properties such as {@link PersistentEntity#getVersionProperty() version} shall be
46+
* considered.
4447
*/
4548
private PersistentEntityIsNewStrategy(PersistentEntity<?, ?> entity, boolean idOnly) {
4649

4750
Assert.notNull(entity, "PersistentEntity must not be null");
4851

49-
this.valueLookup = entity.hasVersionProperty() && !idOnly //
50-
? source -> entity.getPropertyAccessor(source).getProperty(entity.getRequiredVersionProperty())
51-
: source -> entity.getIdentifierAccessor(source).getIdentifier();
52-
53-
this.valueType = entity.hasVersionProperty() && !idOnly //
54-
? entity.getRequiredVersionProperty().getType() //
55-
: entity.hasIdProperty() ? entity.getRequiredIdProperty().getType() : null;
52+
if (entity.hasVersionProperty() && !idOnly) {
53+
this.valueLookup = source -> entity.getPropertyAccessor(source).getProperty(entity.getRequiredVersionProperty());
54+
this.valueType = entity.getRequiredVersionProperty().getType();
55+
} else {
56+
this.valueLookup = source -> entity.getIdentifierAccessor(source).getIdentifier();
57+
this.valueType = entity.hasIdProperty() ? entity.getRequiredIdProperty().getType() : null;
58+
}
5659

5760
Class<?> type = valueType;
5861

5962
if (type != null && type.isPrimitive()) {
6063

6164
if (!ClassUtils.isAssignable(Number.class, type)) {
6265

63-
throw new IllegalArgumentException(String
64-
.format("Only numeric primitives are supported as identifier / version field types; Got: %s", valueType));
66+
throw new IllegalArgumentException(
67+
String.format("Only numeric primitives are supported as identifier / version field types; Got: %s",
68+
valueType));
6569
}
6670
}
6771
}

Diff for: src/main/java/org/springframework/data/repository/query/Parameters.java

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
/**
3939
* Abstracts method parameters that have to be bound to query parameters or applied to the query independently.
4040
*
41+
* @param <T> The exact type of {@link Parameter} inside {@link Parameters}
42+
* @param <S> The exact type of {@link Parameters} to be used. Generified to allow for recursive generics.
4143
* @author Oliver Gierke
4244
* @author Christoph Strobl
4345
* @author Johannes Englmeier

0 commit comments

Comments
 (0)