Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.properties.bind;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import java.util.TreeSet;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.boot.context.properties.bind.Binder.Context;
import org.springframework.boot.context.properties.source.ConfigurationProperty;
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
import org.springframework.boot.context.properties.source.ConfigurationPropertyName.Form;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.IterableConfigurationPropertySource;
import org.springframework.core.ResolvableType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
/**
* Base class for {@link AggregateBinder AggregateBinders} that read a sequential run of
* indexed items.
*
* @param the type being bound
* @author Phillip Webb
* @author Madhura Bhave
*/
abstract class IndexedElementsBinder extends AggregateBinder {
private static final String INDEX_ZERO = "[0]";
IndexedElementsBinder(Context context) {
super(context);
}
@Override
protected boolean isAllowRecursiveBinding(ConfigurationPropertySource source) {
return source == null || source instanceof IterableConfigurationPropertySource;
}
/**
* Bind indexed elements to the supplied collection.
* @param name the name of the property to bind
* @param target the target bindable
* @param elementBinder the binder to use for elements
* @param aggregateType the aggregate type, may be a collection or an array
* @param elementType the element type
* @param result the destination for results
*/
protected final void bindIndexed(ConfigurationPropertyName name, Bindable target,
AggregateElementBinder elementBinder, ResolvableType aggregateType, ResolvableType elementType,
IndexedCollectionSupplier result) {
for (ConfigurationPropertySource source : getContext().getSources()) {
bindIndexed(source, name, target, elementBinder, result, aggregateType, elementType);
if (result.wasSupplied() && result.get() != null) {
return;
}
}
}
private void bindIndexed(ConfigurationPropertySource source, ConfigurationPropertyName root, Bindable target,
AggregateElementBinder elementBinder, IndexedCollectionSupplier collection, ResolvableType aggregateType,
ResolvableType elementType) {
ConfigurationProperty property = source.getConfigurationProperty(root);
if (property != null) {
bindValue(target, collection.get(), aggregateType, elementType, property.getValue());
}
else {
bindIndexed(source, root, elementBinder, collection, elementType);
}
}
private void bindValue(Bindable target, Collection