Is there ready made routine to check if bean has getter for specific property name given by string?
You could do this, from BeanUtils:
static boolean propertyExists (Object bean, String property) {
return PropertyUtils.isReadable(bean, property) &&
PropertyUtils.isWriteable(bean, property);
}
As far as I know there isn't a one-liner that encapsulates both of those, since readability / writeability are independent.
If you're only interested in the getter, PropertyUtils.isReadable()
alone will work.
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