Package: grails.databinding

## [Groovy] Class SimpleDataBinder

- grails.databinding.SimpleDataBinder

- All Implemented Interfaces and Traits:
    DataBinder

      @groovy.transform.CompileStatic
      class SimpleDataBinder
      extends java.lang.Object
      implements DataBinder

  A data binder that will bind nested Maps to an object.

       class Person {
           String firstName
           Address homeAddress
       }

       class Address {
           String city
           String state
       }

       def person = new Person()
       def binder = new SimpleDataBinder()
       binder.bind person, [firstName: 'Steven', homeAddress: [city: 'St. Louis', state: 'Missouri']]
       assert person.firstName == 'Steven'
       assert person.homeAddress.city == 'St. Louis'
       assert person.homeAddress.state == 'Missouri'

  Authors:
    Jeff Brown
    Graeme Rocher
  Since:
    3.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static java.util.List<java.lang.Class>` | `BASIC_TYPES` |
    `private static java.lang.Object` | `INDEXED_PROPERTY_REGEX` |
    `private int` | `autoGrowCollectionLimit` |
    `protected java.util.Map<java.lang.Class, java.util.List<ValueConverter>>` | `conversionHelpers` |
    `private ConversionService` | `conversionService` |
    `protected java.util.Map<java.lang.Class, FormattedValueConverter>` | `formattedValueConversionHelpers` |
    `protected java.util.Map<java.lang.Class, StructuredBindingEditor>` | `structuredEditors` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `static java.lang.Object` | `INDEXED_PROPERTY_REGEX`
    `int` | `autoGrowCollectionLimit`
    `ConversionService` | `conversionService`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `SimpleDataBinder ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected java.lang.Object` | `addBindingError(java.lang.Object obj, java.lang.String propName, java.lang.Object propertyValue, java.lang.Exception e, DataBindingListener listener, java.lang.Object errors)`
    `` | `protected java.lang.Object` | `addElementToArrayAt(java.lang.Object array, java.lang.Object index, java.lang.Object val)`
    `` | `protected java.lang.Object` | `addElementToCollection(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, java.lang.Object propertyValue, boolean clearCollection)`
    `` | `protected java.lang.Object` | `addElementToCollectionAt(java.lang.Object obj, java.lang.String propertyName, java.util.Collection collection, java.lang.Object index, java.lang.Object val)`
    `` | `private void` | `addElementsToCollection(java.lang.Object obj, java.lang.String collectionPropertyName, java.util.Collection collection, boolean removeExistingElements)`
    `` | `void` | `bind(java.lang.Object obj, DataBindingSource source)` Parameters: `obj` - The object being bound to
    `` | `void` | `bind(java.lang.Object obj, DataBindingSource source, DataBindingListener listener)` Parameters: `obj` - The object being bound to
    `` | `void` | `bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList)` Parameters: `obj` - The object being bound to
    `` | `void` | `bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList, java.util.List blackList)` Parameters: `obj` - The object being bound to
    `` | `void` | `bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath)` Parameters: `obj` - The object being bound to
    `` | `void` | `bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList)` Parameters: `obj` - The object being bound to
    `` | `void` | `bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)` Parameters: `obj` - The object being bound to
    `` | `protected java.lang.Object` | `bindProperty(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, java.lang.Object errors)`
    `` | `protected java.lang.Object` | `convert(java.lang.Class typeToConvertTo, java.lang.Object value)`
    `` | `protected java.lang.Object` | `convertStringToEnum(java.lang.Class<? extends java.lang.Enum> enumClass, java.lang.String value)`
    `` | `protected void` | `doBind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener, java.lang.Object errors)`
    `` | `protected ValueConverter` | `getConverter(java.lang.Class typeToConvertTo, java.lang.Object value)`
    `` | `protected java.lang.Object` | `getDefaultCollectionInstanceForType(java.lang.Class type)`
    `` | `protected java.lang.reflect.Field` | `getField(java.lang.Class clazz, java.lang.String fieldName)`
    `` | `protected java.lang.String` | `getFormatString(java.lang.annotation.Annotation annotation)` Parameters: `annotation` - An instance of grails.databinding.BindingFormat or org.grails.databinding.BindingFormat
    `` | `protected ValueConverter` | `getFormattedConverter(java.lang.reflect.Field field, java.lang.String formattingValue)` Get a ValueConverter for field
    `` | `protected IndexedPropertyReferenceDescriptor` | `getIndexedPropertyReferenceDescriptor(java.lang.Object propName)`
    `` | `protected ValueInitializer` | `getPropertyInitializer(java.lang.Object obj, java.lang.String propName)`
    `` | `protected java.lang.Class<?>` | `getReferencedTypeForCollection(java.lang.String propertyName, java.lang.Object obj)`
    `` | `protected java.lang.Class<?>` | `getReferencedTypeForCollectionInClass(java.lang.String propertyName, java.lang.Class clazz)`
    `` | `protected ValueConverter` | `getValueConverter(java.lang.Object obj, java.lang.String propName)`
    `` | `protected ValueConverter` | `getValueConverterForClass(java.lang.Object obj, java.lang.String propName)`
    `` | `protected ValueConverter` | `getValueConverterForField(java.lang.Object obj, java.lang.String propName)`
    `` | `protected ValueInitializer` | `getValueInitializerForField(java.lang.Object obj, java.lang.String propName)`
    `` | `protected java.lang.Class` | `getValueOfBindInitializer(java.lang.annotation.Annotation annotation)` Parameters: `annotation` - An instance of grails.databinding.BindInitializer
    `` | `protected java.lang.Class` | `getValueOfBindUsing(java.lang.annotation.Annotation annotation)` Parameters: `annotation` - An instance of grails.databinding.BindingUsing or org.grails.databinding.BindingUsing
    `` | `protected java.lang.Object` | `initializeArray(java.lang.Object obj, java.lang.String propertyName, java.lang.Class arrayType, int index)`
    `` | `protected java.util.Collection` | `initializeCollection(java.lang.Object obj, java.lang.String propertyName, java.lang.Class type, boolean reuseExistingCollectionIfExists)`
    `` | `protected java.util.Map` | `initializeMap(java.lang.Object obj, java.lang.String propertyName)`
    `` | `protected java.lang.Object` | `initializeProperty(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, DataBindingSource source)`
    `` | `protected boolean` | `isBasicType(java.lang.Class c)`
    `` | `protected boolean` | `isOkToAddElementAt(java.util.Collection collection, int index)`
    `` | `protected boolean` | `isOkToBind(java.lang.String propName, java.util.List whiteList, java.util.List blackList)`
    `` | `protected boolean` | `isOkToBind(groovy.lang.MetaProperty property, java.util.List whitelist, java.util.List blacklist)`
    `` | `protected java.lang.Object` | `preprocessValue(java.lang.Object propertyValue)`
    `` | `protected java.lang.Object` | `processIndexedProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)`
    `` | `protected java.lang.Object` | `processProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)`
    `` | `void` | `registerConverter(ValueConverter converter)`
    `` | `void` | `registerFormattedValueConverter(FormattedValueConverter converter)`
    `` | `void` | `registerStructuredEditor(java.lang.Class clazz, StructuredBindingEditor editor)`
    `` | `protected java.lang.Object` | `setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener)`
    `` | `protected java.lang.Object` | `setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, boolean convertCollectionElements)`
    `` | `protected SimpleMapDataBindingSource` | `splitIndexedStruct(IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, DataBindingSource source)`

  - ### 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()`

- - ### Field Detail

    - #### protected static final java.util.List<java.lang.Class> BASIC_TYPES

    - #### private static final java.lang.Object INDEXED_PROPERTY_REGEX

    - #### private int autoGrowCollectionLimit

    - #### protected java.util.Map<java.lang.Class, java.util.List<ValueConverter>> conversionHelpers

    - #### private ConversionService conversionService

    - #### protected java.util.Map<java.lang.Class, FormattedValueConverter> formattedValueConversionHelpers

    - #### protected java.util.Map<java.lang.Class, StructuredBindingEditor> structuredEditors

  - ### Property Detail

    - #### static final java.lang.Object INDEXED_PROPERTY_REGEX

    - #### int autoGrowCollectionLimit

    - #### ConversionService conversionService

  - ### Constructor Detail

    - #### SimpleDataBinder()

  - ### Method Detail

    - #### protected java.lang.Object addBindingError(java.lang.Object obj, java.lang.String propName, java.lang.Object propertyValue, java.lang.Exception e, DataBindingListener listener, java.lang.Object errors)

    - #### @groovy.transform.CompileStatic(value: TypeCheckingMode.SKIP) protected java.lang.Object addElementToArrayAt(java.lang.Object array, java.lang.Object index, java.lang.Object val)

    - #### protected java.lang.Object addElementToCollection(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, java.lang.Object propertyValue, boolean clearCollection)

    - #### @groovy.transform.CompileStatic(value: TypeCheckingMode.SKIP) protected java.lang.Object addElementToCollectionAt(java.lang.Object obj, java.lang.String propertyName, java.util.Collection collection, java.lang.Object index, java.lang.Object val)

    - #### private void addElementsToCollection(java.lang.Object obj, java.lang.String collectionPropertyName, java.util.Collection collection, boolean removeExistingElements)

    - #### void bind(java.lang.Object obj, DataBindingSource source)

      Parameters:
        `obj` - The object being bound to
        `source` - The data binding source
      See Also:
        DataBindingSource

    - #### void bind(java.lang.Object obj, DataBindingSource source, DataBindingListener listener)

      Parameters:
        `obj` - The object being bound to
        `source` - The data binding source
        `listener` - A listener which will be notified of data binding events triggered by this binding
      See Also:
        DataBindingSource
        DataBindingListener

    - #### void bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList)

      Parameters:
        `obj` - The object being bound to
        `source` - The data binding source
        `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
      See Also:
        DataBindingSource

    - #### void bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList, java.util.List blackList)

      Parameters:
        `obj` - The object being bound to
        `source` - The data binding source
        `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
        `blackList` - A list of properties names to be excluded during this data binding.
      See Also:
        DataBindingSource

    - #### void bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath)

      Parameters:
        `obj` - The object being bound to
        `gpath` - A GPathResult which represents the data being bound.
      See Also:
        DataBindingSource

    - #### void bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList)

      Parameters:
        `obj` - The object being bound to
        `source` - The data binding source
        `filter` - Only properties beginning with filter will be included in the data binding. For example, if filter is "person" and the binding source contains data for properties "person.name" and "author.name" the value of "person.name" will be bound to obj.name. The value of "author.name" will be ignored.
        `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
        `blackList` - A list of properties names to be excluded during this data binding.
      See Also:
        DataBindingSource

    - #### void bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)

      Parameters:
        `obj` - The object being bound to
        `source` - The data binding source
        `filter` - Only properties beginning with filter will be included in the data binding. For example, if filter is "person" and the binding source contains data for properties "person.name" and "author.name" the value of "person.name" will be bound to obj.name. The value of "author.name" will be ignored.
        `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
        `blackList` - A list of properties names to be excluded during this data binding.
        `listener` - A listener which will be notified of data binding events triggered by this binding
      See Also:
        DataBindingSource
        DataBindingListener

    - #### protected java.lang.Object bindProperty(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, java.lang.Object errors)

    - #### protected java.lang.Object convert(java.lang.Class typeToConvertTo, java.lang.Object value)

    - #### @groovy.transform.CompileStatic(value: TypeCheckingMode.SKIP) protected java.lang.Object convertStringToEnum(java.lang.Class<? extends java.lang.Enum> enumClass, java.lang.String value)

    - #### protected void doBind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener, java.lang.Object errors)

    - #### protected ValueConverter getConverter(java.lang.Class typeToConvertTo, java.lang.Object value)

    - #### protected java.lang.Object getDefaultCollectionInstanceForType(java.lang.Class type)

    - #### protected java.lang.reflect.Field getField(java.lang.Class clazz, java.lang.String fieldName)

    - #### protected java.lang.String getFormatString(java.lang.annotation.Annotation annotation)

      Parameters:
        `annotation` - An instance of grails.databinding.BindingFormat or org.grails.databinding.BindingFormat
      Returns:
        the value String of the annotation

    - #### protected ValueConverter getFormattedConverter(java.lang.reflect.Field field, java.lang.String formattingValue)

      Get a ValueConverter for field

      Parameters:
        `field` - The field to retrieve a converter for
        `formattingValue` - The format that the converter will use
      Returns:
        a ValueConverter for field which uses formattingValue for its format
      See Also:
        BindingFormat

    - #### protected IndexedPropertyReferenceDescriptor getIndexedPropertyReferenceDescriptor(java.lang.Object propName)

    - #### protected ValueInitializer getPropertyInitializer(java.lang.Object obj, java.lang.String propName)

    - #### protected java.lang.Class<?> getReferencedTypeForCollection(java.lang.String propertyName, java.lang.Object obj)

    - #### protected java.lang.Class<?> getReferencedTypeForCollectionInClass(java.lang.String propertyName, java.lang.Class clazz)

    - #### protected ValueConverter getValueConverter(java.lang.Object obj, java.lang.String propName)

    - #### protected ValueConverter getValueConverterForClass(java.lang.Object obj, java.lang.String propName)

    - #### protected ValueConverter getValueConverterForField(java.lang.Object obj, java.lang.String propName)

    - #### protected ValueInitializer getValueInitializerForField(java.lang.Object obj, java.lang.String propName)

    - #### protected java.lang.Class getValueOfBindInitializer(java.lang.annotation.Annotation annotation)

      Parameters:
        `annotation` - An instance of grails.databinding.BindInitializer
      Returns:
        the value Class of the annotation

    - #### protected java.lang.Class getValueOfBindUsing(java.lang.annotation.Annotation annotation)

      Parameters:
        `annotation` - An instance of grails.databinding.BindingUsing or org.grails.databinding.BindingUsing
      Returns:
        the value Class of the annotation

    - #### @groovy.transform.CompileStatic(value: TypeCheckingMode.SKIP) protected java.lang.Object initializeArray(java.lang.Object obj, java.lang.String propertyName, java.lang.Class arrayType, int index)

    - #### protected java.util.Collection initializeCollection(java.lang.Object obj, java.lang.String propertyName, java.lang.Class type, boolean reuseExistingCollectionIfExists)

    - #### protected java.util.Map initializeMap(java.lang.Object obj, java.lang.String propertyName)

    - #### protected java.lang.Object initializeProperty(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, DataBindingSource source)

    - #### protected boolean isBasicType(java.lang.Class c)

    - #### protected boolean isOkToAddElementAt(java.util.Collection collection, int index)

    - #### protected boolean isOkToBind(java.lang.String propName, java.util.List whiteList, java.util.List blackList)

    - #### protected boolean isOkToBind(groovy.lang.MetaProperty property, java.util.List whitelist, java.util.List blacklist)

    - #### protected java.lang.Object preprocessValue(java.lang.Object propertyValue)

    - #### protected java.lang.Object processIndexedProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)

    - #### protected java.lang.Object processProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)

    - #### void registerConverter(ValueConverter converter)

    - #### void registerFormattedValueConverter(FormattedValueConverter converter)

    - #### void registerStructuredEditor(java.lang.Class clazz, StructuredBindingEditor editor)

    - #### protected java.lang.Object setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener)

    - #### protected java.lang.Object setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, boolean convertCollectionElements)

    - #### protected SimpleMapDataBindingSource splitIndexedStruct(IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, DataBindingSource source)