@groovy.transform.CompileStatic class SimpleDataBinder extends java.lang.Object
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'
Modifiers | Name | Description |
---|---|---|
protected static java.util.List<java.lang.Class> |
BASIC_TYPES |
|
protected java.util.Map<java.lang.Class, java.util.List<ValueConverter>> |
conversionHelpers |
|
protected java.util.Map<java.lang.Class, FormattedValueConverter> |
formattedValueConvertersionHelpers |
|
protected java.util.Map<java.lang.Class, StructuredBindingEditor> |
structuredEditors |
Type | Name and description |
---|---|
static java.lang.Object |
INDEXED_PROPERTY_REGEX |
int |
autoGrowCollectionLimit |
ConversionService |
conversionService |
Constructor and description |
---|
SimpleDataBinder
() |
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) |
void |
bind(java.lang.Object obj, DataBindingSource source) @param obj The object being bound to |
void |
bind(java.lang.Object obj, DataBindingSource source, DataBindingListener listener) @param obj The object being bound to |
void |
bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList) @param obj The object being bound to |
void |
bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList, java.util.List blackList) @param obj The object being bound to |
void |
bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath) @param 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) @param 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) @param 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(BindingFormat annotation) |
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 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 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 = true) |
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 java.lang.Object |
isOkToBind(java.lang.String propName, 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) |
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() |
obj
- The object being bound tosource
- The data binding source
obj
- The object being bound tosource
- The data binding sourcelistener
- A listener which will be notified of data binding events triggered
by this binding
obj
- The object being bound tosource
- The data binding sourcewhiteList
- A list of property names to be included during this
data binding. All other properties represented in the binding source
will be ignored
obj
- The object being bound tosource
- The data binding sourcewhiteList
- A list of property names to be included during this
data binding. All other properties represented in the binding source
will be ignoredblackList
- A list of properties names to be excluded during
this data binding.
obj
- The object being bound togpath
- A GPathResult which represents the data being bound.
obj
- The object being bound tosource
- The data binding sourcefilter
- 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 ignoredblackList
- A list of properties names to be excluded during
this data binding.
obj
- The object being bound tosource
- The data binding sourcefilter
- 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 ignoredblackList
- 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 bindingGet a ValueConverter for field
field
- The field to retrieve a converter forformattingValue
- The format that the converter will useGroovy Documentation