GormUtils provides a set of static helpers for working with domain classes. It allows to copy domain instances, to copy separate properties of an object, etc.
Type | Name and description |
---|---|
static List<String> |
IGNORED_PROPERTIES The list of domain properties which are ignored during copying. |
Type Params | Return Type | Name and description |
---|---|---|
<T> |
static GormEntity<T> |
bind(GormEntity<T> target, Map<String, Object> source, Map<String, Object> override = [:], boolean ignoreAssociations = false) Faster, simplier binder. |
<T> |
static T |
copyDomain(Class<T> domainClass, Object source, Map override = [:], boolean ignoreAssociations = true) Creates an instance of a given domain class and copies properties from source object. |
|
static Object |
copyDomain(Object target, Object source, Map override = [:], boolean ignoreAssociations = true) Copies properties from source to target object. |
|
static void |
copyProperties(Object source, Object target, String... propNames) Copy all given property values from source to target if and only if target's properties are null. |
|
static void |
copyProperties(Object source, Object target, boolean copyOnlyIfNull, String... propNames) Copy all given property values from source to target. |
|
static Object |
getPropertyValue(Object source, String property) Return the value of the (possibly nested) property of the specified name, for the specified source object |
Faster, simplier binder. Copies properties from source to target object.
target
- domain instance to copy properties tosource
- - domain class to copy properties fromoverride
- - properties to override after copyingignoreAssociations
- - should associations be copied ? - ignored by defaultCreates an instance of a given domain class and copies properties from source object.
domainClass
- Domain classsource
- - domain class to copy properties fromoverride
- - properties to override after copyingignoreAssociations
- - should associations be copied ? - ignored by defaultCopies properties from source to target object.
target
- domain instance to copy properties tosource
- - domain class to copy properties fromoverride
- - properties to override after copyingignoreAssociations
- - should associations be copied ? - ignored by defaultCopy all given property values from source to target if and only if target's properties are null.
source
- a source objecttarget
- a target objectpropNames
- array of property names which should be copiedCopy all given property values from source to target. It can be specified whether to copy values or not in case target's properties are not null.
source
- a source objecttarget
- a target objectcopyOnlyIfNull
- if 'true' then it will copy a value only if target's property is nullpropNames
- an array of property names which should be copiedReturn the value of the (possibly nested) property of the specified name, for the specified source object Example getPropertyValue(source, "x.y.z")
source
- - The source objectproperty
- - the property