private boolean hasDescendants(ConfigurationPropertyName name) { for (ConfigurationPropertySource source : getContext().getSources()) { if (source.containsDescendantOf(name) == ConfigurationPropertyState.PRESENT) { return true; } } return false; }
private boolean isScalarValue(ConfigurationPropertySource source, ConfigurationPropertyName name) { Class<?> resolved = this.valueType.resolve(Object.class); if (!resolved.getName().startsWith("java.lang") && !resolved.isEnum()) { return false; } ConfigurationProperty property = source.getConfigurationProperty(name); if (property == null) { return false; } Object value = property.getValue(); value = getContext().getPlaceholdersResolver().resolvePlaceholders(value); return getContext().getConverter().canConvert(value, this.valueType); }
public void bindEntries(ConfigurationPropertySource source, Map<Object, Object> map) { if (source instanceof IterableConfigurationPropertySource) { for (ConfigurationPropertyName name : (IterableConfigurationPropertySource) source) { Bindable<?> valueBindable = getValueBindable(name); ConfigurationPropertyName entryName = getEntryName(source, name); Object key = getContext().getConverter() .convert(getKeyName(entryName), this.keyType); map.computeIfAbsent(key, (k) -> this.elementBinder.bind(entryName, valueBindable)); } } }
@Override protected Object bindAggregate(ConfigurationPropertyName name, Bindable<?> target, AggregateElementBinder elementBinder) { Map<Object, Object> map = CollectionFactory.createMap((target.getValue() != null) ? Map.class : target.getType().resolve(Object.class), 0); Bindable<?> resolvedTarget = resolveTarget(target); boolean hasDescendants = hasDescendants(name); for (ConfigurationPropertySource source : getContext().getSources()) { if (!ConfigurationPropertyName.EMPTY.equals(name)) { ConfigurationProperty property = source.getConfigurationProperty(name); if (property != null && !hasDescendants) { return getContext().getConverter().convert(property.getValue(), target); } source = source.filter(name::isAncestorOf); } new EntryBinder(name, resolvedTarget, elementBinder).bindEntries(source, map); } return map.isEmpty() ? null : map; }