@Override
public void visit(BeanDefinition definition) {
if(definition.isResolved()) {
return;
}
ConstructorModel model = definition.getConstructorModel();
List<Class<?>> types = new ArrayList<>();
Map<String, BeanDefinition> resolvedBeans = new HashMap<>();
for(BeanDefinition dependency: existing.getBeanDefinitions()) {
types.add(dependency.getType());
resolvedBeans.put(dependency.getName(), dependency);
}
if(resolvedBeans.keySet().containsAll(definition.getConstructorRefs()) && !definition.getConstructorRefs().isEmpty() ) {
for(String ref: definition.getConstructorRefs()) {
definition.addContructorArg(resolvedBeans.get(ref).getPayload());
}
definition.instantiate();
existing.addDefinition(definition);
definition.markResolved();
return;
}
Constructor best = model.findBestConstructorsForTypes(types, definition.getConstructorArgs());
if( best != null ) {
for(Class type: best.getParameterTypes()) {
List<BeanDefinition> potential = new ArrayList<>();
for(BeanDefinition def: existing.getBeanDefinitions()) {