使用Apache Commons BeanUtils / PropertyUtils的反思:在Path中实例化NULL

时间:2016-03-07 18:24:14

标签: java reflection apache-commons-beanutils

我使用Apache BeanUtils / PropertyUtils通过反射来获取/设置嵌套属性。但有时候,树中的某个地方可能会有一个NULL对象。

e.g。

PropertyUtils.setNestedProperty(object, "a.b.c.d", 4);

如果b为NULL,请查看Apache Commons的代码,

if (nestedBean == null) {
         throw new NestedNullException
                ("Null property value for '" + name +
                 "' on bean class '" + bean.getClass() + "'");
}

我正在寻找的行为是实例化缺少的对象以填充NULL。这样的功能是否随处可用?这被称为"懒惰路径"属性?

0 个答案:

没有答案