Merge branch '2.0.x'

pull/13022/merge
Stephane Nicoll 7 years ago
commit 44fd7d953e

@ -145,8 +145,8 @@ public class ConfigurationMetadata {
}
private ItemMetadata findMatchingItemMetadata(ItemMetadata metadata) {
List<ItemMetadata> candidates = this.items.get(metadata.getName());
if (candidates == null || candidates.isEmpty()) {
List<ItemMetadata> candidates = getCandidates(metadata.getName());
if (candidates.isEmpty()) {
return null;
}
candidates.removeIf((itemMetadata) -> !itemMetadata.hasSameType(metadata));
@ -161,6 +161,11 @@ public class ConfigurationMetadata {
return null;
}
private List<ItemMetadata> getCandidates(String name) {
List<ItemMetadata> candidates = this.items.get(name);
return (candidates != null ? new ArrayList<>(candidates) : new ArrayList<>());
}
private boolean nullSafeEquals(Object o1, Object o2) {
if (o1 == o2) {
return true;

@ -735,6 +735,17 @@ public class ConfigurationMetadataAnnotationProcessorTests {
.fromSource(AdditionalMetadata.class));
}
@Test
public void mergingOfAdditionalPropertyMatchingGroup() throws Exception {
ItemMetadata property = ItemMetadata.newProperty(null, "simple",
"java.lang.String", null, null, null, null, null);
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata).has(Metadata.withGroup("simple")
.fromSource(SimpleProperties.class));
assertThat(metadata).has(Metadata.withProperty("simple", String.class));
}
@Test
public void mergeExistingPropertyDefaultValue() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "flag", null, null,

Loading…
Cancel
Save