parameterization of random classes with warnings

This commit is contained in:
robokaso
2008-07-22 15:57:16 +00:00
parent d98015626d
commit f777e62736
4 changed files with 35 additions and 31 deletions

View File

@@ -76,12 +76,12 @@ import org.springframework.validation.ObjectError;
* @author Dave Syer
*
*/
public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar implements FieldSetMapper,
public class BeanWrapperFieldSetMapper<T> extends DefaultPropertyEditorRegistrar implements FieldSetMapper<T>,
BeanFactoryAware, InitializingBean {
private String name;
private Class<?> type;
private Class<? extends T> type;
private BeanFactory beanFactory;
@@ -125,7 +125,7 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar im
*
* @param type the type to set
*/
public void setTargetType(Class<?> type) {
public void setTargetType(Class<? extends T> type) {
this.type = type;
}
@@ -156,8 +156,8 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar im
* @see org.springframework.batch.item.file.mapping.FieldSetMapper#mapLine(org.springframework.batch.item.file.mapping.FieldSet, int)
*/
@SuppressWarnings("unchecked")
public Object mapLine(FieldSet fs, int lineNum) {
Object copy = getBean();
public T mapLine(FieldSet fs, int lineNum) {
T copy = getBean();
DataBinder binder = createBinder(copy);
binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));
if (binder.getBindingResult().hasErrors()) {
@@ -204,9 +204,10 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar im
protected void initBinder(DataBinder binder) {
}
private Object getBean() {
@SuppressWarnings("unchecked")
private T getBean() {
if (name != null) {
return beanFactory.getBean(name);
return (T) beanFactory.getBean(name);
}
try {
return type.newInstance();

View File

@@ -29,8 +29,9 @@ import org.springframework.util.Assert;
* @author Dave Syer
*
*/
@SuppressWarnings("unchecked")
public class SubclassExceptionClassifier extends ExceptionClassifierSupport {
private Map classified = new HashMap();
/**

View File

@@ -46,6 +46,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* @author Dave Syer
*
*/
@SuppressWarnings("unchecked")
public class TransactionAwareProxyFactory {
private Object target;