Store attribute type
mhagnumdw opened this issue · 1 comments
mhagnumdw commented
Currently, the BeanMetaInfo class stores only the attribute name. In some cases it would be interesting to know the attribute type as well.
mhagnumdw commented
Perhaps, in order not to overload the API, it is better to store in the generated class the original class type and just that.
It would be up to those who make use of the API to retrieve the attribute type. Being able to do something like this:
public class ReflectionUtils {
public static Class<?> getType(Object classOrObject, String attributeName) throws NoSuchFieldException, SecurityException {
final Class<?> clazz;
if (classOrObject instanceof Class) { // It's a class
clazz = (Class<?>) classOrObject;
} else { // It is an object
clazz = classOrObject.getClass();
}
return clazz.getDeclaredField(attributeName).getType();
}
}
Advantage: does not overload the API and the code above is a simple solution.
Disadvantage: If it is a batch call with thousands or millions of calls, it would be much faster if the type information was already available statically.