Eliminate warnings in .validation package
Issue: SPR-8062
This commit is contained in:
parent
150838bfc1
commit
f4e1cde33b
|
|
@ -39,7 +39,7 @@ public interface PropertyEditorRegistry {
|
|||
* @param requiredType the type of the property
|
||||
* @param propertyEditor the editor to register
|
||||
*/
|
||||
void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor);
|
||||
void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor);
|
||||
|
||||
/**
|
||||
* Register the given custom property editor for the given type and
|
||||
|
|
@ -64,7 +64,7 @@ public interface PropertyEditorRegistry {
|
|||
* <code>null</code> if registering an editor for all properties of the given type
|
||||
* @param propertyEditor editor to register
|
||||
*/
|
||||
void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor);
|
||||
void registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor);
|
||||
|
||||
/**
|
||||
* Find a custom property editor for the given type and property.
|
||||
|
|
@ -74,6 +74,6 @@ public interface PropertyEditorRegistry {
|
|||
* <code>null</code> if looking for an editor for all properties of the given type
|
||||
* @return the registered editor, or <code>null</code> if none
|
||||
*/
|
||||
PropertyEditor findCustomEditor(Class requiredType, String propertyPath);
|
||||
PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import org.springframework.util.StringUtils;
|
|||
* @since 2.0
|
||||
* @see Errors
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class AbstractBindingResult extends AbstractErrors implements BindingResult, Serializable {
|
||||
|
||||
private final String objectName;
|
||||
|
|
@ -131,7 +132,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
|||
}
|
||||
|
||||
public String[] resolveMessageCodes(String errorCode, String field) {
|
||||
Class fieldType = getFieldType(field);
|
||||
Class<?> fieldType = getFieldType(field);
|
||||
return getMessageCodesResolver().resolveMessageCodes(
|
||||
errorCode, getObjectName(), fixedField(field), fieldType);
|
||||
}
|
||||
|
|
@ -237,7 +238,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
|||
* @see #getActualFieldValue
|
||||
*/
|
||||
@Override
|
||||
public Class getFieldType(String field) {
|
||||
public Class<?> getFieldType(String field) {
|
||||
Object value = getActualFieldValue(fixedField(field));
|
||||
if (value != null) {
|
||||
return value.getClass();
|
||||
|
|
@ -286,10 +287,10 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
|||
* {@link #getPropertyEditorRegistry() PropertyEditorRegistry}'s
|
||||
* editor lookup facility, if available.
|
||||
*/
|
||||
public PropertyEditor findEditor(String field, Class valueType) {
|
||||
public PropertyEditor findEditor(String field, Class<?> valueType) {
|
||||
PropertyEditorRegistry editorRegistry = getPropertyEditorRegistry();
|
||||
if (editorRegistry != null) {
|
||||
Class valueTypeToUse = valueType;
|
||||
Class<?> valueTypeToUse = valueType;
|
||||
if (valueTypeToUse == null) {
|
||||
valueTypeToUse = getFieldType(field);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author Juergen Hoeller
|
||||
* @since 2.5.3
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class AbstractErrors implements Errors, Serializable {
|
||||
|
||||
private String nestedPath = "";
|
||||
|
|
@ -146,8 +147,8 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
|||
}
|
||||
|
||||
public ObjectError getGlobalError() {
|
||||
List globalErrors = getGlobalErrors();
|
||||
return (!globalErrors.isEmpty() ? (ObjectError) globalErrors.get(0) : null);
|
||||
List<ObjectError> globalErrors = getGlobalErrors();
|
||||
return (!globalErrors.isEmpty() ? globalErrors.get(0) : null);
|
||||
}
|
||||
|
||||
public boolean hasFieldErrors() {
|
||||
|
|
@ -159,8 +160,8 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
|||
}
|
||||
|
||||
public FieldError getFieldError() {
|
||||
List fieldErrors = getFieldErrors();
|
||||
return (!fieldErrors.isEmpty() ? (FieldError) fieldErrors.get(0) : null);
|
||||
List<FieldError> fieldErrors = getFieldErrors();
|
||||
return (!fieldErrors.isEmpty() ? fieldErrors.get(0) : null);
|
||||
}
|
||||
|
||||
public boolean hasFieldErrors(String field) {
|
||||
|
|
@ -184,12 +185,12 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
|||
}
|
||||
|
||||
public FieldError getFieldError(String field) {
|
||||
List fieldErrors = getFieldErrors(field);
|
||||
List<FieldError> fieldErrors = getFieldErrors(field);
|
||||
return (!fieldErrors.isEmpty() ? (FieldError) fieldErrors.get(0) : null);
|
||||
}
|
||||
|
||||
|
||||
public Class getFieldType(String field) {
|
||||
public Class<?> getFieldType(String field) {
|
||||
Object value = getFieldValue(field);
|
||||
if (value != null) {
|
||||
return value.getClass();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.springframework.util.Assert;
|
|||
* @see org.springframework.beans.PropertyAccessor
|
||||
* @see org.springframework.beans.ConfigurablePropertyAccessor
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class AbstractPropertyBindingResult extends AbstractBindingResult {
|
||||
|
||||
private ConversionService conversionService;
|
||||
|
|
@ -85,7 +86,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
|
|||
* @see #getPropertyAccessor()
|
||||
*/
|
||||
@Override
|
||||
public Class getFieldType(String field) {
|
||||
public Class<?> getFieldType(String field) {
|
||||
return getPropertyAccessor().getPropertyType(fixedField(field));
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +134,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
|
|||
* @return the custom PropertyEditor, or <code>null</code>
|
||||
*/
|
||||
protected PropertyEditor getCustomEditor(String fixedField) {
|
||||
Class targetType = getPropertyAccessor().getPropertyType(fixedField);
|
||||
Class<?> targetType = getPropertyAccessor().getPropertyType(fixedField);
|
||||
PropertyEditor editor = getPropertyAccessor().findCustomEditor(targetType, fixedField);
|
||||
if (editor == null) {
|
||||
editor = BeanUtils.findEditorByConvention(targetType);
|
||||
|
|
@ -146,8 +147,8 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
|
|||
* if applicable.
|
||||
*/
|
||||
@Override
|
||||
public PropertyEditor findEditor(String field, Class valueType) {
|
||||
Class valueTypeForLookup = valueType;
|
||||
public PropertyEditor findEditor(String field, Class<?> valueType) {
|
||||
Class<?> valueTypeForLookup = valueType;
|
||||
if (valueTypeForLookup == null) {
|
||||
valueTypeForLookup = getFieldType(field);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.springframework.util.Assert;
|
|||
* @see DataBinder#initBeanPropertyAccess()
|
||||
* @see DirectFieldBindingResult
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class BeanPropertyBindingResult extends AbstractPropertyBindingResult implements Serializable {
|
||||
|
||||
private final Object target;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.springframework.util.Assert;
|
|||
* @see DataBinder#getBindingResult()
|
||||
* @see DataBinder#close()
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class BindException extends Exception implements BindingResult {
|
||||
|
||||
private final BindingResult bindingResult;
|
||||
|
|
@ -134,7 +135,7 @@ public class BindException extends Exception implements BindingResult {
|
|||
return this.bindingResult.getErrorCount();
|
||||
}
|
||||
|
||||
public List getAllErrors() {
|
||||
public List<ObjectError> getAllErrors() {
|
||||
return this.bindingResult.getAllErrors();
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +147,7 @@ public class BindException extends Exception implements BindingResult {
|
|||
return this.bindingResult.getGlobalErrorCount();
|
||||
}
|
||||
|
||||
public List getGlobalErrors() {
|
||||
public List<ObjectError> getGlobalErrors() {
|
||||
return this.bindingResult.getGlobalErrors();
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +163,7 @@ public class BindException extends Exception implements BindingResult {
|
|||
return this.bindingResult.getFieldErrorCount();
|
||||
}
|
||||
|
||||
public List getFieldErrors() {
|
||||
public List<FieldError> getFieldErrors() {
|
||||
return this.bindingResult.getFieldErrors();
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +179,7 @@ public class BindException extends Exception implements BindingResult {
|
|||
return this.bindingResult.getFieldErrorCount(field);
|
||||
}
|
||||
|
||||
public List getFieldErrors(String field) {
|
||||
public List<FieldError> getFieldErrors(String field) {
|
||||
return this.bindingResult.getFieldErrors(field);
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +191,7 @@ public class BindException extends Exception implements BindingResult {
|
|||
return this.bindingResult.getFieldValue(field);
|
||||
}
|
||||
|
||||
public Class getFieldType(String field) {
|
||||
public Class<?> getFieldType(String field) {
|
||||
return this.bindingResult.getFieldType(field);
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +207,7 @@ public class BindException extends Exception implements BindingResult {
|
|||
return this.bindingResult.getRawFieldValue(field);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public PropertyEditor findEditor(String field, Class valueType) {
|
||||
return this.bindingResult.findEditor(field, valueType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public interface BindingResult extends Errors {
|
|||
* is given but should be specified in any case for consistency checking)
|
||||
* @return the registered editor, or <code>null</code> if none
|
||||
*/
|
||||
PropertyEditor findEditor(String field, Class valueType);
|
||||
PropertyEditor findEditor(String field, Class<?> valueType);
|
||||
|
||||
/**
|
||||
* Return the underlying PropertyEditorRegistry.
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public abstract class BindingResultUtils {
|
|||
* @return the BindingResult, or <code>null</code> if none found
|
||||
* @throws IllegalStateException if the attribute found is not of type BindingResult
|
||||
*/
|
||||
public static BindingResult getBindingResult(Map model, String name) {
|
||||
public static BindingResult getBindingResult(Map<?, ?> model, String name) {
|
||||
Assert.notNull(model, "Model map must not be null");
|
||||
Assert.notNull(name, "Name must not be null");
|
||||
Object attr = model.get(BindingResult.MODEL_KEY_PREFIX + name);
|
||||
|
|
@ -53,7 +53,7 @@ public abstract class BindingResultUtils {
|
|||
* @return the BindingResult (never <code>null</code>)
|
||||
* @throws IllegalStateException if no BindingResult found
|
||||
*/
|
||||
public static BindingResult getRequiredBindingResult(Map model, String name) {
|
||||
public static BindingResult getRequiredBindingResult(Map<?, ?> model, String name) {
|
||||
BindingResult bindingResult = getBindingResult(model, name);
|
||||
if (bindingResult == null) {
|
||||
throw new IllegalStateException("No BindingResult attribute found for name '" + name +
|
||||
|
|
|
|||
|
|
@ -509,18 +509,15 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
|||
return this.conversionService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) {
|
||||
public void registerCustomEditor(Class<?> requiredType, PropertyEditor 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);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) {
|
||||
public PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath) {
|
||||
return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath);
|
||||
}
|
||||
|
||||
|
|
@ -700,8 +697,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
|||
* @throws BindException if there were any errors in the bind operation
|
||||
* @see BindingResult#getModel()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map close() throws BindException {
|
||||
public Map<?, ?> close() throws BindException {
|
||||
if (getBindingResult().hasErrors()) {
|
||||
throw new BindException(getBindingResult());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author Juergen Hoeller
|
||||
* @since 1.0.1
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class DefaultMessageCodesResolver implements MessageCodesResolver, Serializable {
|
||||
|
||||
/**
|
||||
|
|
@ -119,7 +120,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
|||
* details on the generated codes.
|
||||
* @return the list of codes
|
||||
*/
|
||||
public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class fieldType) {
|
||||
public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class<?> fieldType) {
|
||||
List<String> codeList = new ArrayList<String>();
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
buildFieldList(field, fieldList);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.springframework.util.Assert;
|
|||
* @see DataBinder#initDirectFieldAccess()
|
||||
* @see BeanPropertyBindingResult
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class DirectFieldBindingResult extends AbstractPropertyBindingResult {
|
||||
|
||||
private final Object target;
|
||||
|
|
|
|||
|
|
@ -296,6 +296,6 @@ public interface Errors {
|
|||
* @param field the field name
|
||||
* @return the type of the field, or <code>null</code> if not determinable
|
||||
*/
|
||||
Class getFieldType(String field);
|
||||
Class<?> getFieldType(String field);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.springframework.util.ObjectUtils;
|
|||
* @since 10.03.2003
|
||||
* @see DefaultMessageCodesResolver
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class FieldError extends ObjectError {
|
||||
|
||||
private final String field;
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ import org.springframework.util.Assert;
|
|||
* @since 2.0
|
||||
* @see java.util.Map
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MapBindingResult extends AbstractBindingResult implements Serializable {
|
||||
|
||||
private final Map target;
|
||||
private final Map<?, ?> target;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -43,14 +44,14 @@ public class MapBindingResult extends AbstractBindingResult implements Serializa
|
|||
* @param target the target Map to bind onto
|
||||
* @param objectName the name of the target object
|
||||
*/
|
||||
public MapBindingResult(Map target, String objectName) {
|
||||
public MapBindingResult(Map<?, ?> target, String objectName) {
|
||||
super(objectName);
|
||||
Assert.notNull(target, "Target Map must not be null");
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
|
||||
public final Map getTargetMap() {
|
||||
public final Map<?, ?> getTargetMap() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,6 @@ public interface MessageCodesResolver {
|
|||
* @param fieldType the field type (may be <code>null</code> if not determinable)
|
||||
* @return the message codes to use
|
||||
*/
|
||||
String[] resolveMessageCodes(String errorCode, String objectName, String field, Class fieldType);
|
||||
String[] resolveMessageCodes(String errorCode, String objectName, String field, Class<?> fieldType);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.springframework.util.Assert;
|
|||
* @see DefaultMessageCodesResolver
|
||||
* @since 10.03.2003
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ObjectError extends DefaultMessageSourceResolvable {
|
||||
|
||||
private final String objectName;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ import org.springframework.util.CollectionUtils;
|
|||
public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||
implements ValidatorFactory, ApplicationContextAware, InitializingBean {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Class providerClass;
|
||||
|
||||
private MessageInterpolator messageInterpolator;
|
||||
|
|
@ -85,6 +86,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
|||
* @see javax.validation.Validation#byProvider(Class)
|
||||
* @see javax.validation.Validation#byDefaultProvider()
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void setProviderClass(Class<? extends ValidationProvider> providerClass) {
|
||||
this.providerClass = providerClass;
|
||||
}
|
||||
|
|
@ -177,6 +179,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void afterPropertiesSet() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Configuration configuration = (this.providerClass != null ?
|
||||
Validation.byProvider(this.providerClass).configure() :
|
||||
Validation.byDefaultProvider().configure());
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
* (such as Hibernate Validator 4.0) into a Spring ApplicationContext
|
||||
* and in particular with Spring's data binding and validation APIs.
|
||||
*
|
||||
* <p>The central class is {@link LocalValidatorFactoryBean} which
|
||||
* defines a shared ValidatorFactory/Validator setup for availability
|
||||
* <p>The central class is {@link
|
||||
* org.springframework.validation.beanvalidation.LocalValidatorFactoryBean}
|
||||
* which defines a shared ValidatorFactory/Validator setup for availability
|
||||
* to other Spring components.
|
||||
*/
|
||||
package org.springframework.validation.beanvalidation;
|
||||
|
|
|
|||
Loading…
Reference in New Issue