Skip to content

Commit 11a1538

Browse files
committed
Polish 'Support nested @PropertyMapping annotations'
See gh-23146
1 parent edf4c83 commit 11a1538

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,10 +73,10 @@ private Map<String, Object> getProperties(Class<?> source) {
7373
return properties;
7474
}
7575

76-
private void collectProperties(String prefix, SkipPropertyMapping defaultSkip, MergedAnnotation<?> annotation,
76+
private void collectProperties(String prefix, SkipPropertyMapping skip, MergedAnnotation<?> annotation,
7777
Method attribute, Map<String, Object> properties) {
7878
MergedAnnotation<?> attributeMapping = MergedAnnotations.from(attribute).get(PropertyMapping.class);
79-
SkipPropertyMapping skip = attributeMapping.getValue("skip", SkipPropertyMapping.class).orElse(defaultSkip);
79+
skip = attributeMapping.getValue("skip", SkipPropertyMapping.class).orElse(skip);
8080
if (skip == SkipPropertyMapping.YES) {
8181
return;
8282
}
@@ -127,7 +127,8 @@ private void putProperties(String name, SkipPropertyMapping defaultSkip, Object
127127
}
128128
}
129129
else if (value instanceof MergedAnnotation<?>) {
130-
for (Method attribute : ((MergedAnnotation<?>) value).getType().getDeclaredMethods()) {
130+
MergedAnnotation<?> annotation = (MergedAnnotation<?>) value;
131+
for (Method attribute : annotation.getType().getDeclaredMethods()) {
131132
collectProperties(name, defaultSkip, (MergedAnnotation<?>) value, attribute, properties);
132133
}
133134
}

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)