Reference ref = field.getAnnotation(Reference.class);
String name = ref.name() != null && !ref.name().equals("") ? ref.name() : field.getName();
Object value = getReference(name, field.getType(), sc);
setField(instance, field, value);
} else if (field.isAnnotationPresent(Property.class)) {
Property prop = field.getAnnotation(Property.class);
String name = prop.name() != null && !prop.name().equals("") ? prop.name() : field.getName();
Object value = getProperty(name, sc);
setField(instance, field, value);
} else if (field.isAnnotationPresent(ComponentName.class)) {
RuntimeComponent rc = (RuntimeComponent)sc.getAttribute(COMPONENT_ATTR);
setField(instance, field, rc.getName());
} else if (field.isAnnotationPresent(Context.class)) {
setField(instance, field, getComponentContext(sc));
}
}
for (Method method : clazz.getDeclaredMethods()) {
if (!method.getName().startsWith("set") || method.getParameterTypes().length != 1) {
continue;
}
String targetName = method.getName().substring(3);
Class<?> type = method.getParameterTypes()[0];
if (method.isAnnotationPresent(Reference.class)) {
Reference ref = method.getAnnotation(Reference.class);
String name = ref.name() != null && !ref.name().equals("") ? ref.name() : targetName;
Object value = getReference(name, type, sc);
setMethod(instance, method, value);
} else if (method.isAnnotationPresent(Property.class)) {
Property prop = method.getAnnotation(Property.class);
String name = prop.name() != null && !prop.name().equals("") ? prop.name() : targetName;
Object value = getProperty(name, sc);
setMethod(instance, method, value);
} else if (method.isAnnotationPresent(ComponentName.class)) {
RuntimeComponent rc = (RuntimeComponent)sc.getAttribute(COMPONENT_ATTR);
setMethod(instance, method, rc.getName());