if(field.isAnnotationPresent(Property.class)) {
Object value=Configurator.getField(field, prot);
if(value != null) {
annotation=field.getAnnotation(Property.class);
Class<?> conv_class=annotation.converter();
PropertyConverter conv=null;
try {
conv=(PropertyConverter)conv_class.newInstance();
}
catch(Exception e) {
}
String tmp=conv != null? conv.toString(value) : value.toString();
retval.put(field.getName(), tmp);
}
}
}
// copy all setters marked with @Property
Method[] methods=clazz.getDeclaredMethods();
for(Method method: methods) {
String methodName=method.getName();
if(method.isAnnotationPresent(Property.class) && Configurator.isSetPropertyMethod(method)) {
annotation=method.getAnnotation(Property.class);
List<String> possible_names=new LinkedList<String>();
if(annotation.name() != null)
possible_names.add(annotation.name());
possible_names.add(methodName.substring(3));
possible_names.add(Configurator.renameFromJavaCodingConvention(methodName.substring(3)));
Field field=findField(prot, possible_names);
if(field != null) {
Object value=Configurator.getField(field, prot);
if(value != null) {
Class<?> conv_class=annotation.converter();
PropertyConverter conv=null;
try {
conv=(PropertyConverter)conv_class.newInstance();
}
catch(Exception e) {
}
String tmp=conv != null? conv.toString(value) : value.toString();
retval.put(field.getName(), tmp);
}
}
}
}