use of org.mule.runtime.config.internal.dsl.spring.WrapperElementType.COLLECTION in project mule by mulesoft.
the class BeanDefinitionFactory method getWrapperIdentifierAndTypeMap.
private <T> Map<String, WrapperElementType> getWrapperIdentifierAndTypeMap(ComponentBuildingDefinition<T> buildingDefinition) {
final Map<String, WrapperElementType> wrapperIdentifierAndTypeMap = new HashMap<>();
AbstractAttributeDefinitionVisitor wrapperIdentifiersCollector = new AbstractAttributeDefinitionVisitor() {
@Override
public void onComplexChildCollection(Class<?> type, Optional<String> wrapperIdentifierOptional) {
wrapperIdentifierOptional.ifPresent(wrapperIdentifier -> wrapperIdentifierAndTypeMap.put(wrapperIdentifier, COLLECTION));
}
@Override
public void onComplexChild(Class<?> type, Optional<String> wrapperIdentifierOptional, Optional<String> childIdentifier) {
wrapperIdentifierOptional.ifPresent(wrapperIdentifier -> wrapperIdentifierAndTypeMap.put(wrapperIdentifier, SINGLE));
}
@Override
public void onComplexChildMap(Class<?> keyType, Class<?> valueType, String wrapperIdentifier) {
wrapperIdentifierAndTypeMap.put(wrapperIdentifier, MAP);
}
@Override
public void onMultipleValues(KeyAttributeDefinitionPair[] definitions) {
for (KeyAttributeDefinitionPair attributeDefinition : definitions) {
attributeDefinition.getAttributeDefinition().accept(this);
}
}
};
Consumer<AttributeDefinition> collectWrappersConsumer = attributeDefinition -> attributeDefinition.accept(wrapperIdentifiersCollector);
buildingDefinition.getSetterParameterDefinitions().stream().map(setterAttributeDefinition -> setterAttributeDefinition.getAttributeDefinition()).forEach(collectWrappersConsumer);
buildingDefinition.getConstructorAttributeDefinition().stream().forEach(collectWrappersConsumer);
return wrapperIdentifierAndTypeMap;
}
Aggregations