Package: grails.web.databinding

## [Java] Class DataBindingUtils

- grails.web.databinding.DataBindingUtils

- Utility methods to perform data binding from Grails objects.

  Authors:
    Graeme Rocher
  Since:
    1.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `DATA_BINDER_BEAN_NAME` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static void` | `assignBidirectionalAssociations(java.lang.Object object, java.util.Map source, GrailsDomainClass domainClass)` Associations both sides of any bidirectional relationships found in the object and source map to bind
    `` | `static void` | `assignBidirectionalAssociations(java.lang.Object object, java.util.Map source, org.grails.datastore.mapping.model.PersistentEntity persistentEntity)` Associations both sides of any bidirectional relationships found in the object and source map to bind
    `` | `static org.springframework.validation.BindingResult` | `bindObjectToDomainInstance(GrailsDomainClass domain, java.lang.Object object, java.lang.Object source)` Binds the given source object to the given target object performing type conversion if necessary
    `` | `static org.springframework.validation.BindingResult` | `bindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source)` Binds the given source object to the given target object performing type conversion if necessary
    `` | `static org.springframework.validation.BindingResult` | `bindObjectToDomainInstance(GrailsDomainClass domain, java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)` Binds the given source object to the given target object performing type conversion if necessary
    `` | `static org.springframework.validation.BindingResult` | `bindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)` Binds the given source object to the given target object performing type conversion if necessary
    `` | `static org.springframework.validation.BindingResult` | `bindObjectToInstance(java.lang.Object object, java.lang.Object source)` Binds the given source object to the given target object performing type conversion if necessary
    `` | `static org.springframework.validation.BindingResult` | `bindObjectToInstance(java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)` Binds the given source object to the given target object performing type conversion if necessary
    `<T>` | `static void` | `bindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, CollectionDataBindingSource collectionBindingSource)` For each DataBindingSource provided by collectionBindingSource a new instance of targetType is created, data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of collectionToPopulate
    `<T>` | `static void` | `bindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, javax.servlet.ServletRequest request)`
    `` | `static java.util.Map` | `convertPotentialGStrings(java.util.Map<java.lang.Object, java.lang.Object> args)`
    `` | `static CollectionDataBindingSource` | `createCollectionDataBindingSource(GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)`
    `` | `static DataBindingSource` | `createDataBindingSource(GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)`
    `` | `static DataBindingSourceRegistry` | `getDataBindingSourceRegistry(GrailsApplication grailsApplication)`
    `` | `protected static java.lang.String[]` | `getMessageCodes(java.lang.String messageCode, java.lang.Class objectType)`
    `` | `static MimeType` | `getMimeType(GrailsApplication grailsApplication, java.lang.Object bindingSource)`
    `` | `static MimeTypeResolver` | `getMimeTypeResolver(GrailsApplication grailsApplication)`
    `` | `static MimeType` | `resolveMimeType(java.lang.Object bindingSource, MimeTypeResolver mimeTypeResolver)`

  - ### Inherited Methods Summary

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

- - ### Field Detail

    - #### public static final java.lang.String DATA_BINDER_BEAN_NAME

  - ### Method Detail

    - #### @java.lang.Deprecated public static void assignBidirectionalAssociations(java.lang.Object object, java.util.Map source, GrailsDomainClass domainClass)

      Associations both sides of any bidirectional relationships found in the object and source map to bind

      deprecated:
        Use assignBidirectionalAssociations(Object, Map, PersistentEntity) instead
      Parameters:
        `object` - The object
        `source` - The source map
        `domainClass` - The DomainClass for the object

    - #### public static void assignBidirectionalAssociations(java.lang.Object object, java.util.Map source, org.grails.datastore.mapping.model.PersistentEntity persistentEntity)

      Associations both sides of any bidirectional relationships found in the object and source map to bind

      Parameters:
        `object` - The object
        `source` - The source map
        `persistentEntity` - The PersistentEntity for the object

    - #### @java.lang.Deprecated public static org.springframework.validation.BindingResult bindObjectToDomainInstance(GrailsDomainClass domain, java.lang.Object object, java.lang.Object source)

      Binds the given source object to the given target object performing type conversion if necessary

      deprecated:
        Use bindObjectToDomainInstance(PersistentEntity, Object, Object) instead
      Parameters:
        `domain` - The GrailsDomainClass instance
        `object` - The object to bind to
        `source` - The source object
      See Also:
        GrailsDomainClass
      Returns:
        A BindingResult if there were errors or null if it was successful

    - #### public static org.springframework.validation.BindingResult bindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source)

      Binds the given source object to the given target object performing type conversion if necessary

      Parameters:
        `entity` - The PersistentEntity instance
        `object` - The object to bind to
        `source` - The source object
      See Also:
        org.grails.datastore.mapping.model.PersistentEntity
      Returns:
        A BindingResult if there were errors or null if it was successful

    - #### @java.lang.SuppressWarnings("unchecked") @java.lang.Deprecated public static org.springframework.validation.BindingResult bindObjectToDomainInstance(GrailsDomainClass domain, java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)

      Binds the given source object to the given target object performing type conversion if necessary

      deprecated:
        Use bindObjectToDomainInstance(PersistentEntity, Object, Object, List, List, String) instead
      Parameters:
        `domain` - The GrailsDomainClass instance
        `object` - The object to bind to
        `source` - The source object
        `include` - The list of properties to include
        `exclude` - The list of properties to exclude
        `filter` - The prefix to filter by
      See Also:
        GrailsDomainClass
      Returns:
        A BindingResult if there were errors or null if it was successful

    - #### @java.lang.SuppressWarnings("unchecked") public static org.springframework.validation.BindingResult bindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)

      Binds the given source object to the given target object performing type conversion if necessary

      Parameters:
        `entity` - The PersistentEntity instance
        `object` - The object to bind to
        `source` - The source object
        `include` - The list of properties to include
        `exclude` - The list of properties to exclude
        `filter` - The prefix to filter by
      See Also:
        org.grails.datastore.mapping.model.PersistentEntity
      Returns:
        A BindingResult if there were errors or null if it was successful

    - #### public static org.springframework.validation.BindingResult bindObjectToInstance(java.lang.Object object, java.lang.Object source)

      Binds the given source object to the given target object performing type conversion if necessary

      Parameters:
        `object` - The object to bind to
        `source` - The source object
      Returns:
        A BindingResult if there were errors or null if it was successful

    - #### public static org.springframework.validation.BindingResult bindObjectToInstance(java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)

      Binds the given source object to the given target object performing type conversion if necessary

      Parameters:
        `object` - The object to bind to
        `source` - The source object
        `include` - The list of properties to include
        `exclude` - The list of properties to exclude
        `filter` - The prefix to filter by
      Returns:
        A BindingResult if there were errors or null if it was successful

    - #### <T> public static void bindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, CollectionDataBindingSource collectionBindingSource)

      For each DataBindingSource provided by collectionBindingSource a new instance of targetType is created, data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of collectionToPopulate

      Parameters:
        `targetType` - The type of objects to create, must be a concrete class
        `collectionToPopulate` - A collection to populate with new instances of targetType
        `collectionBindingSource` - A CollectionDataBindingSource
      Since:
        2.3

    - #### <T> public static void bindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, javax.servlet.ServletRequest request)

    - #### @java.lang.SuppressWarnings("unchecked") public static java.util.Map convertPotentialGStrings(java.util.Map<java.lang.Object, java.lang.Object> args)

    - #### public static CollectionDataBindingSource createCollectionDataBindingSource(GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)

    - #### public static DataBindingSource createDataBindingSource(GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)

    - #### public static DataBindingSourceRegistry getDataBindingSourceRegistry(GrailsApplication grailsApplication)

    - #### protected static java.lang.String[] getMessageCodes(java.lang.String messageCode, java.lang.Class objectType)

    - #### public static MimeType getMimeType(GrailsApplication grailsApplication, java.lang.Object bindingSource)

    - #### public static MimeTypeResolver getMimeTypeResolver(GrailsApplication grailsApplication)

    - #### public static MimeType resolveMimeType(java.lang.Object bindingSource, MimeTypeResolver mimeTypeResolver)