try {
IJavaElement source = ((AutowireBeanReference) ref).getSource();
if (source instanceof IField) {
String propertyName = source.getElementName();
if (!autowiredProperties.contains(propertyName)) {
IBeanProperty newProperty = new BeanProperty(entry.getKey(), new PropertyValue(
propertyName, new RuntimeBeanReference(ref.getBeanName())));
bean.addBeanProperty(newProperty);
autowiredProperties.add(propertyName);
}
}
else if (source instanceof IMethod && ((IMethod) source).isConstructor()) {
IBeanConstructorArgument newConstructorArg = new BeanConstructorArgument(
entry.getKey(), ((AutowireBeanReference) ref).getParameterIndex(),
new ValueHolder(new RuntimeBeanReference(ref.getBeanName())));
bean.addBeanConstructorArgument(newConstructorArg);
}
else if (source instanceof IMethod && !((IMethod) source).isConstructor()) {
String propertyName = source.getElementName();
if (propertyName.startsWith("set")) {
propertyName = Introspector.decapitalize(propertyName.substring(3));
}
if (!autowiredProperties.contains(propertyName)) {
IBeanProperty newProperty = new BeanProperty(entry.getKey(), new PropertyValue(
propertyName, new RuntimeBeanReference(ref.getBeanName())));
bean.addBeanProperty(newProperty);
autowiredProperties.add(propertyName);
}
}