Is there any way to prevent NPE when accessing a nested bean using commons-beanutils?
Here is my code:
new BeanUtilsBean().getProperty(human, "parent.name");
In this case I want getProperty() to either return empty string (“”) when human.getParent() == null or handle it in a way other that throwing an NPE.
They were thinking of adding language features to JDK7, but ultimately they weren’t added
For now you’ll have to manually check. You can just hack it and create a function like
Kind of sucks, but it will work.