Merge branch '1.5.x' into 2.0.x

pull/13061/head
Stephane Nicoll 7 years ago
commit 782d8c63da

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

@ -735,6 +735,17 @@ public class ConfigurationMetadataAnnotationProcessorTests {
.fromSource(AdditionalMetadata.class)); .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 @Test
public void mergeExistingPropertyDefaultValue() throws Exception { public void mergeExistingPropertyDefaultValue() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "flag", null, null, ItemMetadata property = ItemMetadata.newProperty("simple", "flag", null, null,

Loading…
Cancel
Save