In the book "Thinking in Java" there is an example of how to get information for a bean via Reflection/Introspection.
BeanInfo bi = Introspector.getBeanInfo(Car.class, Object.class);
for (PropertyDescriptor d: bi.getPropertyDescriptors()) {
Class<?> p = d.getPropertyType();
if (p == null) continue;
[...]
}
In line 4 of that sample above there is a check if the PropertyType is null. When and under what circumstances does that happen? Can you give an example?
From the JavaDoc:
Returns null if the type is an indexed property that does not support non-indexed access.
So I guess if the property type is an indexed property(like an array) it will return null
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With