added Field context variant to TypeConverter interface in beans module; @Value injection works in combination with formatting rules such as @DateTimeFormat

Issue: SPR-9637
This commit is contained in:
Juergen Hoeller
2012-09-04 22:36:12 +02:00
parent 780a259c70
commit e904589bd1
11 changed files with 195 additions and 121 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.validation;
import java.beans.PropertyEditor;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
@@ -547,12 +548,18 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
return getTypeConverter().convertIfNecessary(value, requiredType);
}
public <T> T convertIfNecessary(
Object value, Class<T> requiredType, MethodParameter methodParam) throws TypeMismatchException {
public <T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam)
throws TypeMismatchException {
return getTypeConverter().convertIfNecessary(value, requiredType, methodParam);
}
public <T> T convertIfNecessary(Object value, Class<T> requiredType, Field field)
throws TypeMismatchException {
return getTypeConverter().convertIfNecessary(value, requiredType, field);
}
/**
* Bind the given property values to this binder's target.