Skip to content

Commit b945060

Browse files
committed
Polishing.
Move off deprecated getRequiredLeafProperty() method in other places. See #1489
1 parent e106b20 commit b945060

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515
*/
1616
package org.springframework.data.jdbc.core;
1717

18-
import java.util.*;
18+
import java.util.ArrayList;
19+
import java.util.Arrays;
20+
import java.util.Collections;
21+
import java.util.HashMap;
22+
import java.util.HashSet;
23+
import java.util.LinkedHashMap;
24+
import java.util.List;
25+
import java.util.Map;
26+
import java.util.Optional;
27+
import java.util.Set;
1928
import java.util.function.BiConsumer;
2029
import java.util.stream.Collectors;
2130

@@ -386,7 +395,7 @@ <T> void stage(DbAction<?> action, PersistentPropertyPath path, @Nullable Object
386395

387396
private MultiValueAggregator getAggregatorFor(PersistentPropertyPath path) {
388397

389-
PersistentProperty property = path.getRequiredLeafProperty();
398+
PersistentProperty property = path.getLeafProperty();
390399
for (MultiValueAggregator aggregator : aggregators) {
391400
if (aggregator.handles(property)) {
392401
return aggregator;

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public void delete(Object rootId, PersistentPropertyPath<RelationalPersistentPro
212212

213213
Class<?> ownerType = getOwnerTyp(propertyPath);
214214
String statement = namespace(ownerType) + ".delete-" + toDashPath(propertyPath);
215-
Class<?> leafType = propertyPath.getRequiredLeafProperty().getTypeInformation().getType();
215+
Class<?> leafType = propertyPath.getLeafProperty().getTypeInformation().getType();
216216
MyBatisContext parameter = new MyBatisContext(rootId, null, leafType, Collections.emptyMap());
217217

218218
sqlSession().delete(statement, parameter);
@@ -234,7 +234,7 @@ public <T> void deleteAll(Class<T> domainType) {
234234
@Override
235235
public void deleteAll(PersistentPropertyPath<RelationalPersistentProperty> propertyPath) {
236236

237-
Class<?> leafType = propertyPath.getRequiredLeafProperty().getTypeInformation().getType();
237+
Class<?> leafType = propertyPath.getLeafProperty().getTypeInformation().getType();
238238

239239
String statement = namespace(getOwnerTyp(propertyPath)) + ".deleteAll-" + toDashPath(propertyPath);
240240
MyBatisContext parameter = new MyBatisContext(null, null, leafType, Collections.emptyMap());
@@ -293,7 +293,7 @@ public Iterable<Object> findAllByPath(Identifier identifier,
293293
String statementName = namespace(getOwnerTyp(path)) + ".findAllByPath-" + path.toDotPath();
294294

295295
return sqlSession().selectList(statementName,
296-
new MyBatisContext(identifier, null, path.getRequiredLeafProperty().getType()));
296+
new MyBatisContext(identifier, null, path.getLeafProperty().getType()));
297297
}
298298

299299
@Override

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategyUnitTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void findAllByPath() {
274274
when(path.getBaseProperty()).thenReturn(property);
275275
when(property.getOwner().getType()).thenReturn((Class) String.class);
276276

277-
when(path.getRequiredLeafProperty()).thenReturn(property);
277+
when(path.getLeafProperty()).thenReturn(property);
278278
when(property.getType()).thenReturn((Class) Number.class);
279279

280280
when(path.toDotPath()).thenReturn("dot.path");

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ interface WithPropertyPath<T> extends DbAction<T> {
552552
@SuppressWarnings("unchecked")
553553
@Override
554554
default Class<T> getEntityType() {
555-
return (Class<T>) getPropertyPath().getRequiredLeafProperty().getActualType();
555+
return (Class<T>) getPropertyPath().getLeafProperty().getActualType();
556556
}
557557
}
558558
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/PathNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class PathNode {
5757
*/
5858
Object getActualValue() {
5959

60-
return getPath().getRequiredLeafProperty().isQualified() //
60+
return getPath().getLeafProperty().isQualified() //
6161
? ((Pair<?,?>) getValue()).getSecond() //
6262
: getValue();
6363
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ private List<DbAction<?>> insertReferenced() {
123123
private List<? extends DbAction<?>> insertAll(PersistentPropertyPath<RelationalPersistentProperty> path) {
124124

125125
RelationalPersistentEntity<?> persistentEntity = context
126-
.getRequiredPersistentEntity(path.getRequiredLeafProperty());
126+
.getRequiredPersistentEntity(path.getLeafProperty());
127127
List<DbAction.Insert<Object>> inserts = new ArrayList<>();
128128
from(path).forEach(node -> {
129129

130130
DbAction.WithEntity<?> parentAction = getAction(node.getParent());
131131
Map<PersistentPropertyPath<RelationalPersistentProperty>, Object> qualifiers = new HashMap<>();
132132
Object instance;
133-
if (node.getPath().getRequiredLeafProperty().isQualified()) {
133+
if (node.getPath().getLeafProperty().isQualified()) {
134134

135135
Pair<Object, Object> value = (Pair) node.getValue();
136136
qualifiers.put(node.getPath(), value.getFirst());
@@ -213,8 +213,8 @@ private List<PathNode> from(PersistentPropertyPath<RelationalPersistentProperty>
213213
// todo: this should go into pathnode
214214
Object parentValue = parentNode.getActualValue();
215215

216-
Object value = path.getRequiredLeafProperty().getOwner().getPropertyAccessor(parentValue)
217-
.getProperty(path.getRequiredLeafProperty());
216+
Object value = path.getLeafProperty().getOwner().getPropertyAccessor(parentValue)
217+
.getProperty(path.getLeafProperty());
218218

219219
nodes.addAll(createNodes(path, parentNode, value));
220220
});
@@ -265,11 +265,11 @@ private List<PathNode> createNodes(PersistentPropertyPath<RelationalPersistentPr
265265
}
266266

267267
List<PathNode> nodes = new ArrayList<>();
268-
if (path.getRequiredLeafProperty().isEmbedded()) {
268+
if (path.getLeafProperty().isEmbedded()) {
269269
nodes.add(new PathNode(path, parentNode, value));
270-
} else if (path.getRequiredLeafProperty().isQualified()) {
270+
} else if (path.getLeafProperty().isQualified()) {
271271

272-
if (path.getRequiredLeafProperty().isMap()) {
272+
if (path.getLeafProperty().isMap()) {
273273
((Map<?, ?>) value).forEach((k, v) -> nodes.add(new PathNode(path, parentNode, Pair.of(k, v))));
274274
} else {
275275

@@ -278,7 +278,7 @@ private List<PathNode> createNodes(PersistentPropertyPath<RelationalPersistentPr
278278
nodes.add(new PathNode(path, parentNode, Pair.of(k, listValue.get(k))));
279279
}
280280
}
281-
} else if (path.getRequiredLeafProperty().isCollectionLike()) { // collection value
281+
} else if (path.getLeafProperty().isCollectionLike()) { // collection value
282282
if (value.getClass().isArray()) {
283283
asList((Object[]) value).forEach(v -> nodes.add(new PathNode(path, parentNode, v)));
284284
} else {

0 commit comments

Comments
 (0)