use of jodd.petite.PropertyInjectionPoint in project jodd by oblac.
the class PropertyResolver method resolve.
/**
* Resolves all properties for given type.
*/
public PropertyInjectionPoint[] resolve(Class type, boolean autowire) {
// lookup fields
ClassDescriptor cd = ClassIntrospector.lookup(type);
List<PropertyInjectionPoint> list = new ArrayList<>();
PropertyDescriptor[] allPropertyDescriptors = cd.getAllPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : allPropertyDescriptors) {
if (propertyDescriptor.isGetterOnly()) {
continue;
}
Class propertyType = propertyDescriptor.getType();
if (ReflectUtil.isTypeOf(propertyType, Collection.class)) {
continue;
}
MethodDescriptor writeMethodDescriptor = propertyDescriptor.getWriteMethodDescriptor();
FieldDescriptor fieldDescriptor = propertyDescriptor.getFieldDescriptor();
PetiteInject ref = null;
if (writeMethodDescriptor != null) {
ref = writeMethodDescriptor.getMethod().getAnnotation(PetiteInject.class);
}
if (ref == null && fieldDescriptor != null) {
ref = fieldDescriptor.getField().getAnnotation(PetiteInject.class);
}
if ((!autowire) && (ref == null)) {
continue;
}
String[] refName = null;
if (ref != null) {
String name = ref.value().trim();
if (name.length() != 0) {
refName = new String[] { name };
}
}
list.add(injectionPointFactory.createPropertyInjectionPoint(propertyDescriptor, refName));
}
PropertyInjectionPoint[] fields;
if (list.isEmpty()) {
fields = PropertyInjectionPoint.EMPTY;
} else {
fields = list.toArray(new PropertyInjectionPoint[list.size()]);
}
return fields;
}
Aggregations