@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) public @interface BindInitializer
This annotation may be applied to a a field to customize initialization of object properties in the data binding process. When the annotation is applied to a field, the value assigned to the annotation should be a Closure which accepts 1 parameter. The parameter is the object that data binding is being applied to. The value returned by the Closure will be bound to the field. The following code demonstrates using this technique to bind a contact to user with the same account as the user.
class Contact{ Account account String firstName } class User { @BindInitializer({ obj -> new Contact(account:obj.account) }) Contact contact Account account }
Type | Name and Description |
---|---|
java.lang.Class<?> |
value |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |