|
|
|
@ -18,7 +18,6 @@ package org.springframework.boot.context.properties.bind; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.annotation.Annotation; |
|
|
|
import java.lang.annotation.Annotation; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.TreeSet; |
|
|
|
import java.util.TreeSet; |
|
|
|
import java.util.function.Supplier; |
|
|
|
import java.util.function.Supplier; |
|
|
|
@ -83,22 +82,24 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> { |
|
|
|
ResolvableType aggregateType, ResolvableType elementType) { |
|
|
|
ResolvableType aggregateType, ResolvableType elementType) { |
|
|
|
ConfigurationProperty property = source.getConfigurationProperty(root); |
|
|
|
ConfigurationProperty property = source.getConfigurationProperty(root); |
|
|
|
if (property != null) { |
|
|
|
if (property != null) { |
|
|
|
Collection<Object> elements; |
|
|
|
bindValue(target, collection.get(), aggregateType, elementType, |
|
|
|
Object value = property.getValue(); |
|
|
|
property.getValue()); |
|
|
|
if (value instanceof String && !StringUtils.hasText((String) value)) { |
|
|
|
|
|
|
|
elements = Collections.emptyList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
Object aggregate = convert(value, aggregateType, target.getAnnotations()); |
|
|
|
bindIndexed(source, root, elementBinder, collection, elementType); |
|
|
|
ResolvableType collectionType = ResolvableType |
|
|
|
|
|
|
|
.forClassWithGenerics(collection.get().getClass(), elementType); |
|
|
|
|
|
|
|
elements = convert(aggregate, collectionType); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
collection.get().addAll(elements); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
bindIndexed(source, root, elementBinder, collection, elementType); |
|
|
|
private void bindValue(Bindable<?> target, Collection<Object> collection, |
|
|
|
|
|
|
|
ResolvableType aggregateType, ResolvableType elementType, Object value) { |
|
|
|
|
|
|
|
if (value instanceof String && !StringUtils.hasText((String) value)) { |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Object aggregate = convert(value, aggregateType, target.getAnnotations()); |
|
|
|
|
|
|
|
ResolvableType collectionType = ResolvableType |
|
|
|
|
|
|
|
.forClassWithGenerics(collection.getClass(), elementType); |
|
|
|
|
|
|
|
Collection<Object> elements = convert(aggregate, collectionType); |
|
|
|
|
|
|
|
collection.addAll(elements); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void bindIndexed(ConfigurationPropertySource source, |
|
|
|
private void bindIndexed(ConfigurationPropertySource source, |
|
|
|
|