BeanPathTools contains a set of static helpers, which provides a convenient way for manipulating with object's properties. For example, it allows to retrieve object's properties using filters and place them in a map.
Type Params | Return Type | Name and description |
---|---|---|
|
static Map |
buildMapFromPaths(Object source, List<String> propList, boolean useDelegatingBean = false) Provides an ability to retrieve object's fields into a map. |
|
static GrailsParameterMap |
flattenMap(HttpServletRequest request, Map jsonMap = null) takes a request and an optional map. |
|
static Object |
getFieldValue(Object domain, String field) |
|
static List |
getFields(Object domain) |
|
static GrailsParameterMap |
getGrailsParameterMap(Map p, HttpServletRequest request) |
|
static List<String> |
getIncludes(String className, List<String> fields) |
|
static def |
getNestedBean(Object bean, String path) Returns the deepest nested bean |
|
static Map |
propsToMap(Object source, String propertyPath, Map currentMap) Provides an ability to retrieve a property of a source object and add it to a map. |
Provides an ability to retrieve object's fields into a map. It is possible to specify a query of fields which should be picked up. Note: propList = ['*'] represents all fields.
source
- a source objectpropList
- a query of properties to include to a maptakes a request and an optional map. call the MapFlattener and returns a GrailsParameterMap to be used for binding example: [xxx:[yyy:123]] will turn into a GrailsParameterMap with ["xxx.yyy":123]
Returns the deepest nested bean
Provides an ability to retrieve a property of a source object and add it to a map. In case if 'propertyPath' is set to '*', it will extract all properties from a source object. It is possible to extract a nested property by using the '.' symbol, e.g. 'property.nestedProperty' For example: object = new Test(id: 1, value: 10, nested: new Test1(foo: '1')) results of propsToMap for the object will be: propsToMap(object, '*', map) // [id: 1, value: 10, nested: [foo: 1]] propsToMap(object, 'id', map) // [id: 1] propsToMap(object, 'nested.foo', map) // [nested: [foo: 1]]
source
- a source objectpropertyPath
- a property name, e.g. 'someField', 'someField.nestedField', '*' (for all properties)currentMap
- a destination map