Example usage for org.springframework.beans.factory.config ConstructorArgumentValues hasIndexedArgumentValue

List of usage examples for org.springframework.beans.factory.config ConstructorArgumentValues hasIndexedArgumentValue

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config ConstructorArgumentValues hasIndexedArgumentValue.

Prototype

public boolean hasIndexedArgumentValue(int index) 

Source Link

Document

Check whether an argument value has been registered for the given index.

Usage

From source file:org.constretto.spring.ConfigurationAnnotationConfigurer.java

@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
    for (String beanName : beanFactory.getBeanDefinitionNames()) {
        final BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
        final Class<?> beanType = beanFactory.getType(beanName);
        if (!configurableConstructorCache.containsKey(beanType)) {
            configurableConstructorCache.put(beanType, resolveConfigurableConstructor(beanType));
        }// w w w  .  jav a  2s  .c o  m
        final Constructor<?> resolvedConstructor = configurableConstructorCache.get(beanType);
        if (resolvedConstructor != null) {
            final ConstructorArgumentValues constructorArgumentValues = beanDefinition
                    .getConstructorArgumentValues();
            final ArgumentDescription[] argumentDescriptions = ArgumentDescriptionFactory
                    .create(resolvedConstructor).resolveParameters();
            for (int i = 0; i < argumentDescriptions.length; i++) {
                ArgumentDescription argumentDescription = argumentDescriptions[i];
                if (!constructorArgumentValues.hasIndexedArgumentValue(i)) {
                    final String keyName = argumentDescription.constrettoConfigurationKeyCandidate();
                    if (configuration.hasValue(keyName)) {
                        constructorArgumentValues.addIndexedArgumentValue(i,
                                configuration.evaluateTo(argumentDescription.getType(), keyName));
                    }
                }
            }
        }

    }
}