[SPR-6174] DataBinder now uses var-args to set allowed/disallowed/required fields.

This commit is contained in:
Sam Brannen 2009-10-01 23:28:27 +00:00
parent 0eda92a51a
commit 5c055ed6dd
1 changed files with 7 additions and 3 deletions

View File

@ -344,7 +344,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @see #isAllowed(String) * @see #isAllowed(String)
* @see org.springframework.web.bind.ServletRequestDataBinder * @see org.springframework.web.bind.ServletRequestDataBinder
*/ */
public void setAllowedFields(String[] allowedFields) { public void setAllowedFields(String... allowedFields) {
this.allowedFields = PropertyAccessorUtils.canonicalPropertyNames(allowedFields); this.allowedFields = PropertyAccessorUtils.canonicalPropertyNames(allowedFields);
} }
@ -368,7 +368,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @see #isAllowed(String) * @see #isAllowed(String)
* @see org.springframework.web.bind.ServletRequestDataBinder * @see org.springframework.web.bind.ServletRequestDataBinder
*/ */
public void setDisallowedFields(String[] disallowedFields) { public void setDisallowedFields(String... disallowedFields) {
this.disallowedFields = PropertyAccessorUtils.canonicalPropertyNames(disallowedFields); this.disallowedFields = PropertyAccessorUtils.canonicalPropertyNames(disallowedFields);
} }
@ -390,7 +390,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @see #setBindingErrorProcessor * @see #setBindingErrorProcessor
* @see DefaultBindingErrorProcessor#MISSING_FIELD_ERROR_CODE * @see DefaultBindingErrorProcessor#MISSING_FIELD_ERROR_CODE
*/ */
public void setRequiredFields(String[] requiredFields) { public void setRequiredFields(String... requiredFields) {
this.requiredFields = PropertyAccessorUtils.canonicalPropertyNames(requiredFields); this.requiredFields = PropertyAccessorUtils.canonicalPropertyNames(requiredFields);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("DataBinder requires binding of required fields [" + logger.debug("DataBinder requires binding of required fields [" +
@ -492,14 +492,17 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
// Implementation of PropertyEditorRegistry/TypeConverter interface // Implementation of PropertyEditorRegistry/TypeConverter interface
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) { public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) {
getPropertyEditorRegistry().registerCustomEditor(requiredType, propertyEditor); getPropertyEditorRegistry().registerCustomEditor(requiredType, propertyEditor);
} }
@SuppressWarnings("unchecked")
public void registerCustomEditor(Class requiredType, String field, PropertyEditor propertyEditor) { public void registerCustomEditor(Class requiredType, String field, PropertyEditor propertyEditor) {
getPropertyEditorRegistry().registerCustomEditor(requiredType, field, propertyEditor); getPropertyEditorRegistry().registerCustomEditor(requiredType, field, propertyEditor);
} }
@SuppressWarnings("unchecked")
public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) { public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) {
return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath); return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath);
} }
@ -671,6 +674,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @throws BindException if there were any errors in the bind operation * @throws BindException if there were any errors in the bind operation
* @see BindingResult#getModel() * @see BindingResult#getModel()
*/ */
@SuppressWarnings("unchecked")
public Map close() throws BindException { public Map close() throws BindException {
if (getBindingResult().hasErrors()) { if (getBindingResult().hasErrors()) {
throw new BindException(getBindingResult()); throw new BindException(getBindingResult());