T
The Griz
I have an class, MyClass, that has several objects (which are properties of
the class) which inherit from MyAbstractClass (an abstract class of
course).
Using jakarata commons beanutils I would like to get all the properties
from MyClass that inherit from MyAbstract class. It seems it should be
simple (and probably is) but I can't seem to get it right.
I am using the PropertyUtilsBean to get a list of the properties in
MyClass. After that I need to somehow compare each property type to see if
it is derived from MyAbstractClass like so
PropertyUtilsBean utils = new PropertyUtilsBean();
PropertyDescriptor [] descriptors = utils.getPropertyDescriptors(myClass);
for (int i = 0; i < descriptors.length; i++) {
PropertyDescriptor descriptor = descriptors;
Class descClass = descriptor.getPropertyType();
if (descClass.isInstance(MyAbstractClass.class) {
// do my stuff
}
}
Instead of getting the derived objects, I get any class. Clearly I am
doing something completely wrong. I have been browsing the javadoc for
beanutils and class but I am not finding any joy.
If someone could point me in the correct direction I would appreciate it
greatly.
Thanks
the class) which inherit from MyAbstractClass (an abstract class of
course).
Using jakarata commons beanutils I would like to get all the properties
from MyClass that inherit from MyAbstract class. It seems it should be
simple (and probably is) but I can't seem to get it right.
I am using the PropertyUtilsBean to get a list of the properties in
MyClass. After that I need to somehow compare each property type to see if
it is derived from MyAbstractClass like so
PropertyUtilsBean utils = new PropertyUtilsBean();
PropertyDescriptor [] descriptors = utils.getPropertyDescriptors(myClass);
for (int i = 0; i < descriptors.length; i++) {
PropertyDescriptor descriptor = descriptors;
Class descClass = descriptor.getPropertyType();
if (descClass.isInstance(MyAbstractClass.class) {
// do my stuff
}
}
Instead of getting the derived objects, I get any class. Clearly I am
doing something completely wrong. I have been browsing the javadoc for
beanutils and class but I am not finding any joy.
If someone could point me in the correct direction I would appreciate it
greatly.
Thanks