BindInitializer (Grails 6.0.0)

Package: grails.databinding

## [Java] Annotation Type BindInitializer

- grails.databinding.BindInitializer

-     @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
      }

  Since:
    3.2.11
  See Also:
    BindingHelper
    DataBindingSource

- - ### Element Summary

    Required Element Summary
    Type | Name and Description
    --- | ---
    `java.lang.Class<?>` | `value`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), 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()`

- - ### Element Detail

    - #### public java.lang.Class<?> value