Support for nested path using field access
This commit adds a nested path support for DirectFieldAccessor that is similar to what BeanWrapper provides. It is now possible to use expressions such as "person.address.city.name" to access the name of the city that a given person lives in using fields to traverse the graph. DirectFieldAccessor also now supports an auto-grow option to create a default instance for a "null" intermediate path. This option is false by default and leads to a NullValueInNestedPathException in such a case. This commit also harmonizes part of the tests suite so that core tests are shared between BeanWrapperImpl and DirectFieldAccessor. Note that map and list access is not implemented as part of this commit. Issue: SPR-9705
This commit is contained in:
@@ -189,8 +189,8 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||
* <p>If "true", a null path location will be populated with a default object value and traversed
|
||||
* instead of resulting in an exception. This flag also enables auto-growth of collection elements
|
||||
* when accessing an out-of-bounds index.
|
||||
* <p>Default is "true" on a standard DataBinder. Note that this feature is only supported
|
||||
* for bean property access (DataBinder's default mode), not for field access.
|
||||
* <p>Default is "true" on a standard DataBinder. Note that since Spring 4.1 this feature is supported
|
||||
* for bean property access (DataBinder's default mode) and field access.
|
||||
* @see #initBeanPropertyAccess()
|
||||
* @see org.springframework.beans.BeanWrapper#setAutoGrowNestedPaths
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user