{
setter.invoke(parent, new Object[]{child});
}
catch(Exception e)
{
throw new NestedRuntimeException("Failed to set field value " +
child +
" with setter " +
setter
+ " on " + parent + ": ", e
);
}
}
else if(field != null)
{
if(!field.isAccessible())
{
field.setAccessible(true);
}
try
{
field.set(parent, child);
}
catch(IllegalArgumentException e)
{
throw new NestedRuntimeException("Failed to set field value " +
child +
" with field " +
field.getName() +
" on " +
parent +
": field type is " +
field.getType() + ", value type is " + (child == null ? null : child.getClass()), e
);
}
catch(IllegalAccessException e)
{
throw new NestedRuntimeException("Failed to set field value " +
child +
" with field " +
field.getName()
+ " on " + parent + ": ", e
);