Fix remaining compiler warnings

Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
This commit is contained in:
Phillip Webb
2013-11-21 18:15:09 -08:00
parent 4de3291dc7
commit 59002f2456
540 changed files with 1943 additions and 1843 deletions

View File

@@ -112,7 +112,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl
// Redefined with public visibility.
@Override
public Class getPropertyType(String propertyPath) {
public Class<?> getPropertyType(String propertyPath) {
return null;
}

View File

@@ -26,7 +26,7 @@ package org.springframework.beans;
@SuppressWarnings("serial")
public class BeanInstantiationException extends FatalBeanException {
private Class beanClass;
private Class<?> beanClass;
/**
@@ -34,7 +34,7 @@ public class BeanInstantiationException extends FatalBeanException {
* @param beanClass the offending bean class
* @param msg the detail message
*/
public BeanInstantiationException(Class beanClass, String msg) {
public BeanInstantiationException(Class<?> beanClass, String msg) {
this(beanClass, msg, null);
}
@@ -44,7 +44,7 @@ public class BeanInstantiationException extends FatalBeanException {
* @param msg the detail message
* @param cause the root cause
*/
public BeanInstantiationException(Class beanClass, String msg, Throwable cause) {
public BeanInstantiationException(Class<?> beanClass, String msg, Throwable cause) {
super("Could not instantiate bean class [" + beanClass.getName() + "]: " + msg, cause);
this.beanClass = beanClass;
}
@@ -52,7 +52,7 @@ public class BeanInstantiationException extends FatalBeanException {
/**
* Return the offending bean class.
*/
public Class getBeanClass() {
public Class<?> getBeanClass() {
return beanClass;
}

View File

@@ -336,7 +336,7 @@ public abstract class BeanUtils {
String methodName = signature.substring(0, firstParen);
String[] parameterTypeNames =
StringUtils.commaDelimitedListToStringArray(signature.substring(firstParen + 1, lastParen));
Class<?>[] parameterTypes = new Class[parameterTypeNames.length];
Class<?>[] parameterTypes = new Class<?>[parameterTypeNames.length];
for (int i = 0; i < parameterTypeNames.length; i++) {
String parameterTypeName = parameterTypeNames[i].trim();
try {

View File

@@ -59,7 +59,7 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
* @return the type of the wrapped bean instance,
* or {@code null} if no wrapped object has been set
*/
Class getWrappedClass();
Class<?> getWrappedClass();
/**
* Obtain the PropertyDescriptors for the wrapped object

View File

@@ -37,7 +37,6 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.CollectionFactory;
import org.springframework.core.GenericCollectionTypeResolver;
import org.springframework.core.convert.ConversionException;
@@ -225,7 +224,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
@Override
public final Class getWrappedClass() {
public final Class<?> getWrappedClass() {
return (this.object != null ? this.object.getClass() : null);
}
@@ -248,7 +247,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
* Return the class of the root object at the top of the path of this BeanWrapper.
* @see #getNestedPath
*/
public final Class getRootClass() {
public final Class<?> getRootClass() {
return (this.rootObject != null ? this.rootObject.getClass() : null);
}
@@ -310,7 +309,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
* Needs to be called when the target object changes.
* @param clazz the class to introspect
*/
protected void setIntrospectionClass(Class clazz) {
protected void setIntrospectionClass(Class<?> clazz) {
if (this.cachedIntrospectionResults != null &&
!clazz.equals(this.cachedIntrospectionResults.getBeanClass())) {
this.cachedIntrospectionResults = null;
@@ -360,7 +359,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
@Override
public Class getPropertyType(String propertyName) throws BeansException {
public Class<?> getPropertyType(String propertyName) throws BeansException {
try {
PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);
if (pd != null) {
@@ -374,7 +373,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
// Check to see if there is a custom editor,
// which might give an indication on the desired target type.
Class editorType = guessPropertyTypeFromEditors(propertyName);
Class<?> editorType = guessPropertyTypeFromEditors(propertyName);
if (editorType != null) {
return editorType;
}
@@ -710,7 +709,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
return nestedBw.getPropertyValue(tokens);
}
private Object getPropertyValue(PropertyTokenHolder tokens) throws BeansException {
@SuppressWarnings("unchecked")
private Object getPropertyValue(PropertyTokenHolder tokens) throws BeansException {
String propertyName = tokens.canonicalName;
String actualName = tokens.actualName;
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
@@ -779,20 +779,20 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
else if (value instanceof List) {
int index = Integer.parseInt(key);
List list = (List) value;
List<Object> list = (List<Object>) value;
growCollectionIfNecessary(list, index, indexedPropertyName, pd, i + 1);
value = list.get(index);
}
else if (value instanceof Set) {
// Apply index to Iterator in case of a Set.
Set set = (Set) value;
Set<Object> set = (Set<Object>) value;
int index = Integer.parseInt(key);
if (index < 0 || index >= set.size()) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Cannot get element with index " + index + " from Set of size " +
set.size() + ", accessed using property path '" + propertyName + "'");
}
Iterator it = set.iterator();
Iterator<Object> it = set.iterator();
for (int j = 0; it.hasNext(); j++) {
Object elem = it.next();
if (j == index) {
@@ -802,7 +802,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
}
else if (value instanceof Map) {
Map map = (Map) value;
Map<Object, Object> map = (Map<Object, Object>) value;
Class<?> mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(pd.getReadMethod(), i + 1);
// IMPORTANT: Do not pass full property name in here - property editors
// must not kick in for map keys but rather only for map values.
@@ -863,16 +863,14 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
}
@SuppressWarnings("unchecked")
private void growCollectionIfNecessary(
Collection collection, int index, String name, PropertyDescriptor pd, int nestingLevel) {
private void growCollectionIfNecessary(Collection<Object> collection, int index,
String name, PropertyDescriptor pd, int nestingLevel) {
if (!this.autoGrowNestedPaths) {
return;
}
int size = collection.size();
if (index >= size && index < this.autoGrowCollectionLimit) {
Class elementType = GenericCollectionTypeResolver.getCollectionReturnType(pd.getReadMethod(), nestingLevel);
Class<?> elementType = GenericCollectionTypeResolver.getCollectionReturnType(pd.getReadMethod(), nestingLevel);
if (elementType != null) {
for (int i = collection.size(); i < index + 1; i++) {
collection.add(newValue(elementType, name));
@@ -958,7 +956,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
if (propValue.getClass().isArray()) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class requiredType = propValue.getClass().getComponentType();
Class<?> requiredType = propValue.getClass().getComponentType();
int arrayIndex = Integer.parseInt(key);
Object oldValue = null;
try {
@@ -976,9 +974,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
else if (propValue instanceof List) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class requiredType = GenericCollectionTypeResolver.getCollectionReturnType(
Class<?> requiredType = GenericCollectionTypeResolver.getCollectionReturnType(
pd.getReadMethod(), tokens.keys.length);
List list = (List) propValue;
List<Object> list = (List<Object>) propValue;
int index = Integer.parseInt(key);
Object oldValue = null;
if (isExtractOldValueForEditor() && index < list.size()) {
@@ -1013,11 +1011,11 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
}
else if (propValue instanceof Map) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(
Class<?> mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(
pd.getReadMethod(), tokens.keys.length);
Class mapValueType = GenericCollectionTypeResolver.getMapValueReturnType(
Class<?> mapValueType = GenericCollectionTypeResolver.getMapValueReturnType(
pd.getReadMethod(), tokens.keys.length);
Map map = (Map) propValue;
Map<Object, Object> map = (Map<Object, Object>) propValue;
// IMPORTANT: Do not pass full property name in here - property editors
// must not kick in for map keys but rather only for map values.
TypeDescriptor typeDescriptor = (mapKeyType != null ?

View File

@@ -32,7 +32,6 @@ import java.util.WeakHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -76,7 +75,7 @@ public class CachedIntrospectionResults {
* Needs to be a WeakHashMap with WeakReferences as values to allow
* for proper garbage collection in case of multiple class loaders.
*/
static final Map<Class, Object> classCache = new WeakHashMap<Class, Object>();
static final Map<Class<?>, Object> classCache = new WeakHashMap<Class<?>, Object>();
/**
@@ -107,7 +106,7 @@ public class CachedIntrospectionResults {
*/
public static void clearClassLoader(ClassLoader classLoader) {
synchronized (classCache) {
for (Iterator<Class> it = classCache.keySet().iterator(); it.hasNext();) {
for (Iterator<Class<?>> it = classCache.keySet().iterator(); it.hasNext();) {
Class<?> beanClass = it.next();
if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) {
it.remove();
@@ -130,6 +129,7 @@ public class CachedIntrospectionResults {
* @return the corresponding CachedIntrospectionResults
* @throws BeansException in case of introspection failure
*/
@SuppressWarnings("unchecked")
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
CachedIntrospectionResults results;
Object value;
@@ -137,8 +137,8 @@ public class CachedIntrospectionResults {
value = classCache.get(beanClass);
}
if (value instanceof Reference) {
Reference ref = (Reference) value;
results = (CachedIntrospectionResults) ref.get();
Reference<CachedIntrospectionResults> ref = (Reference<CachedIntrospectionResults>) value;
results = ref.get();
}
else {
results = (CachedIntrospectionResults) value;

View File

@@ -34,7 +34,8 @@ public class ConversionNotSupportedException extends TypeMismatchException {
* @param requiredType the required target type (or {@code null} if not known)
* @param cause the root cause (may be {@code null})
*/
public ConversionNotSupportedException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable cause) {
public ConversionNotSupportedException(PropertyChangeEvent propertyChangeEvent,
Class<?> requiredType, Throwable cause) {
super(propertyChangeEvent, requiredType, cause);
}
@@ -44,7 +45,7 @@ public class ConversionNotSupportedException extends TypeMismatchException {
* @param requiredType the required target type (or {@code null} if not known)
* @param cause the root cause (may be {@code null})
*/
public ConversionNotSupportedException(Object value, Class requiredType, Throwable cause) {
public ConversionNotSupportedException(Object value, Class<?> requiredType, Throwable cause) {
super(value, requiredType, cause);
}

View File

@@ -26,7 +26,7 @@ package org.springframework.beans;
@SuppressWarnings("serial")
public class InvalidPropertyException extends FatalBeanException {
private Class beanClass;
private Class<?> beanClass;
private String propertyName;
@@ -37,7 +37,7 @@ public class InvalidPropertyException extends FatalBeanException {
* @param propertyName the offending property
* @param msg the detail message
*/
public InvalidPropertyException(Class beanClass, String propertyName, String msg) {
public InvalidPropertyException(Class<?> beanClass, String propertyName, String msg) {
this(beanClass, propertyName, msg, null);
}
@@ -48,7 +48,7 @@ public class InvalidPropertyException extends FatalBeanException {
* @param msg the detail message
* @param cause the root cause
*/
public InvalidPropertyException(Class beanClass, String propertyName, String msg, Throwable cause) {
public InvalidPropertyException(Class<?> beanClass, String propertyName, String msg, Throwable cause) {
super("Invalid property '" + propertyName + "' of bean class [" + beanClass.getName() + "]: " + msg, cause);
this.beanClass = beanClass;
this.propertyName = propertyName;
@@ -57,7 +57,7 @@ public class InvalidPropertyException extends FatalBeanException {
/**
* Return the offending bean class.
*/
public Class getBeanClass() {
public Class<?> getBeanClass() {
return beanClass;
}

View File

@@ -86,7 +86,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
// There is no replacement of existing property values.
if (original != null) {
this.propertyValueList = new ArrayList<PropertyValue>(original.size());
for (Map.Entry entry : original.entrySet()) {
for (Map.Entry<?, ?> entry : original.entrySet()) {
this.propertyValueList.add(new PropertyValue(entry.getKey().toString(), entry.getValue()));
}
}

View File

@@ -31,7 +31,7 @@ public class NotReadablePropertyException extends InvalidPropertyException {
* @param beanClass the offending bean class
* @param propertyName the offending property
*/
public NotReadablePropertyException(Class beanClass, String propertyName) {
public NotReadablePropertyException(Class<?> beanClass, String propertyName) {
super(beanClass, propertyName,
"Bean property '" + propertyName + "' is not readable or has an invalid getter method: " +
"Does the return type of the getter match the parameter type of the setter?");
@@ -43,7 +43,7 @@ public class NotReadablePropertyException extends InvalidPropertyException {
* @param propertyName the offending property
* @param msg the detail message
*/
public NotReadablePropertyException(Class beanClass, String propertyName, String msg) {
public NotReadablePropertyException(Class<?> beanClass, String propertyName, String msg) {
super(beanClass, propertyName, msg);
}

View File

@@ -35,7 +35,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
* @param beanClass the offending bean class
* @param propertyName the offending property name
*/
public NotWritablePropertyException(Class beanClass, String propertyName) {
public NotWritablePropertyException(Class<?> beanClass, String propertyName) {
super(beanClass, propertyName,
"Bean property '" + propertyName + "' is not writable or has an invalid setter method: " +
"Does the return type of the getter match the parameter type of the setter?");
@@ -47,7 +47,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
* @param propertyName the offending property name
* @param msg the detail message
*/
public NotWritablePropertyException(Class beanClass, String propertyName, String msg) {
public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg) {
super(beanClass, propertyName, msg);
}
@@ -58,7 +58,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
* @param msg the detail message
* @param cause the root cause
*/
public NotWritablePropertyException(Class beanClass, String propertyName, String msg, Throwable cause) {
public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg, Throwable cause) {
super(beanClass, propertyName, msg, cause);
}
@@ -70,7 +70,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
* @param possibleMatches suggestions for actual bean property names
* that closely match the invalid property name
*/
public NotWritablePropertyException(Class beanClass, String propertyName, String msg, String[] possibleMatches) {
public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg, String[] possibleMatches) {
super(beanClass, propertyName, msg);
this.possibleMatches = possibleMatches;
}

View File

@@ -33,7 +33,7 @@ public class NullValueInNestedPathException extends InvalidPropertyException {
* @param beanClass the offending bean class
* @param propertyName the offending property
*/
public NullValueInNestedPathException(Class beanClass, String propertyName) {
public NullValueInNestedPathException(Class<?> beanClass, String propertyName) {
super(beanClass, propertyName, "Value of nested property '" + propertyName + "' is null");
}
@@ -43,7 +43,7 @@ public class NullValueInNestedPathException extends InvalidPropertyException {
* @param propertyName the offending property
* @param msg the detail message
*/
public NullValueInNestedPathException(Class beanClass, String propertyName, String msg) {
public NullValueInNestedPathException(Class<?> beanClass, String propertyName, String msg) {
super(beanClass, propertyName, msg);
}

View File

@@ -86,7 +86,7 @@ public interface PropertyAccessor {
* @throws PropertyAccessException if the property was valid but the
* accessor method failed
*/
Class getPropertyType(String propertyName) throws BeansException;
Class<?> getPropertyType(String propertyName) throws BeansException;
/**
* Return a type descriptor for the specified property:

View File

@@ -130,7 +130,7 @@ public class PropertyBatchUpdateException extends BeansException {
}
@Override
public boolean contains(Class exType) {
public boolean contains(Class<?> exType) {
if (exType == null) {
return false;
}

View File

@@ -49,7 +49,7 @@ final class PropertyMatches {
* @param propertyName the name of the property to find possible matches for
* @param beanClass the bean class to search for matches
*/
public static PropertyMatches forProperty(String propertyName, Class beanClass) {
public static PropertyMatches forProperty(String propertyName, Class<?> beanClass) {
return forProperty(propertyName, beanClass, DEFAULT_MAX_DISTANCE);
}
@@ -59,7 +59,7 @@ final class PropertyMatches {
* @param beanClass the bean class to search for matches
* @param maxDistance the maximum property distance allowed for matches
*/
public static PropertyMatches forProperty(String propertyName, Class beanClass, int maxDistance) {
public static PropertyMatches forProperty(String propertyName, Class<?> beanClass, int maxDistance) {
return new PropertyMatches(propertyName, beanClass, maxDistance);
}
@@ -76,7 +76,7 @@ final class PropertyMatches {
/**
* Create a new PropertyMatches instance for the given property.
*/
private PropertyMatches(String propertyName, Class beanClass, int maxDistance) {
private PropertyMatches(String propertyName, Class<?> beanClass, int maxDistance) {
this.propertyName = propertyName;
this.possibleMatches = calculateMatches(BeanUtils.getPropertyDescriptors(beanClass), maxDistance);
}

View File

@@ -200,13 +200,13 @@ class TypeConverterDelegate {
else if (convertedValue instanceof Collection) {
// Convert elements to target type, if determined.
convertedValue = convertToTypedCollection(
(Collection) convertedValue, propertyName, requiredType, typeDescriptor);
(Collection<?>) convertedValue, propertyName, requiredType, typeDescriptor);
standardConversion = true;
}
else if (convertedValue instanceof Map) {
// Convert keys and values to respective target type, if determined.
convertedValue = convertToTypedMap(
(Map) convertedValue, propertyName, requiredType, typeDescriptor);
(Map<?, ?>) convertedValue, propertyName, requiredType, typeDescriptor);
standardConversion = true;
}
if (convertedValue.getClass().isArray() && Array.getLength(convertedValue) == 1) {
@@ -220,8 +220,8 @@ class TypeConverterDelegate {
else if (convertedValue instanceof String && !requiredType.isInstance(convertedValue)) {
if (firstAttemptEx == null && !requiredType.isInterface() && !requiredType.isEnum()) {
try {
Constructor strCtor = requiredType.getConstructor(String.class);
return (T) BeanUtils.instantiateClass(strCtor, convertedValue);
Constructor<T> strCtor = requiredType.getConstructor(String.class);
return BeanUtils.instantiateClass(strCtor, convertedValue);
}
catch (NoSuchMethodException ex) {
// proceed with field lookup
@@ -331,7 +331,7 @@ class TypeConverterDelegate {
* @param requiredType the type to find an editor for
* @return the corresponding editor, or {@code null} if none
*/
private PropertyEditor findDefaultEditor(Class requiredType) {
private PropertyEditor findDefaultEditor(Class<?> requiredType) {
PropertyEditor editor = null;
if (requiredType != null) {
// No custom editor -> check BeanWrapperImpl's default editors.
@@ -434,10 +434,10 @@ class TypeConverterDelegate {
private Object convertToTypedArray(Object input, String propertyName, Class<?> componentType) {
if (input instanceof Collection) {
// Convert Collection elements to array elements.
Collection coll = (Collection) input;
Collection<?> coll = (Collection<?>) input;
Object result = Array.newInstance(componentType, coll.size());
int i = 0;
for (Iterator it = coll.iterator(); it.hasNext(); i++) {
for (Iterator<?> it = coll.iterator(); it.hasNext(); i++) {
Object value = convertIfNecessary(
buildIndexedPropertyName(propertyName, i), null, it.next(), componentType);
Array.set(result, i, value);
@@ -470,8 +470,8 @@ class TypeConverterDelegate {
}
@SuppressWarnings("unchecked")
private Collection convertToTypedCollection(
Collection original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) {
private Collection<?> convertToTypedCollection(
Collection<?> original, String propertyName, Class<?> requiredType, TypeDescriptor typeDescriptor) {
if (!Collection.class.isAssignableFrom(requiredType)) {
return original;
@@ -494,7 +494,7 @@ class TypeConverterDelegate {
return original;
}
Iterator it;
Iterator<?> it;
try {
it = original.iterator();
if (it == null) {
@@ -513,13 +513,13 @@ class TypeConverterDelegate {
return original;
}
Collection convertedCopy;
Collection<Object> convertedCopy;
try {
if (approximable) {
convertedCopy = CollectionFactory.createApproximateCollection(original, original.size());
}
else {
convertedCopy = (Collection) requiredType.newInstance();
convertedCopy = (Collection<Object>) requiredType.newInstance();
}
}
catch (Throwable ex) {
@@ -552,8 +552,8 @@ class TypeConverterDelegate {
}
@SuppressWarnings("unchecked")
private Map convertToTypedMap(
Map original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) {
private Map<?, ?> convertToTypedMap(
Map<?, ?> original, String propertyName, Class<?> requiredType, TypeDescriptor typeDescriptor) {
if (!Map.class.isAssignableFrom(requiredType)) {
return original;
@@ -577,7 +577,7 @@ class TypeConverterDelegate {
return original;
}
Iterator it;
Iterator<?> it;
try {
it = original.entrySet().iterator();
if (it == null) {
@@ -596,13 +596,13 @@ class TypeConverterDelegate {
return original;
}
Map convertedCopy;
Map<Object, Object> convertedCopy;
try {
if (approximable) {
convertedCopy = CollectionFactory.createApproximateMap(original, original.size());
}
else {
convertedCopy = (Map) requiredType.newInstance();
convertedCopy = (Map<Object, Object>) requiredType.newInstance();
}
}
catch (Throwable ex) {
@@ -614,7 +614,7 @@ class TypeConverterDelegate {
}
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
String keyedPropertyName = buildKeyedPropertyName(propertyName, key);
@@ -649,7 +649,7 @@ class TypeConverterDelegate {
null);
}
private boolean canCreateCopy(Class requiredType) {
private boolean canCreateCopy(Class<?> requiredType) {
return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) &&
Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType));
}

View File

@@ -37,7 +37,7 @@ public class TypeMismatchException extends PropertyAccessException {
private transient Object value;
private Class requiredType;
private Class<?> requiredType;
/**
@@ -45,7 +45,7 @@ public class TypeMismatchException extends PropertyAccessException {
* @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem
* @param requiredType the required target type
*/
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType) {
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType) {
this(propertyChangeEvent, requiredType, null);
}
@@ -55,7 +55,7 @@ public class TypeMismatchException extends PropertyAccessException {
* @param requiredType the required target type (or {@code null} if not known)
* @param cause the root cause (may be {@code null})
*/
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable cause) {
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause) {
super(propertyChangeEvent,
"Failed to convert property value of type '" +
ClassUtils.getDescriptiveType(propertyChangeEvent.getNewValue()) + "'" +
@@ -73,7 +73,7 @@ public class TypeMismatchException extends PropertyAccessException {
* @param value the offending value that couldn't be converted (may be {@code null})
* @param requiredType the required target type (or {@code null} if not known)
*/
public TypeMismatchException(Object value, Class requiredType) {
public TypeMismatchException(Object value, Class<?> requiredType) {
this(value, requiredType, null);
}
@@ -83,7 +83,7 @@ public class TypeMismatchException extends PropertyAccessException {
* @param requiredType the required target type (or {@code null} if not known)
* @param cause the root cause (may be {@code null})
*/
public TypeMismatchException(Object value, Class requiredType, Throwable cause) {
public TypeMismatchException(Object value, Class<?> requiredType, Throwable cause) {
super("Failed to convert value of type '" + ClassUtils.getDescriptiveType(value) + "'" +
(requiredType != null ? " to required type '" + ClassUtils.getQualifiedName(requiredType) + "'" : ""),
cause);
@@ -103,7 +103,7 @@ public class TypeMismatchException extends PropertyAccessException {
/**
* Return the required target type, if any.
*/
public Class getRequiredType() {
public Class<?> getRequiredType() {
return this.requiredType;
}

View File

@@ -185,7 +185,7 @@ public class BeanCreationException extends FatalBeanException {
}
@Override
public boolean contains(Class exClass) {
public boolean contains(Class<?> exClass) {
if (super.contains(exClass)) {
return true;
}

View File

@@ -34,7 +34,7 @@ public class BeanIsNotAFactoryException extends BeanNotOfRequiredTypeException {
* @param actualType the actual type returned, which did not match
* the expected type
*/
public BeanIsNotAFactoryException(String name, Class actualType) {
public BeanIsNotAFactoryException(String name, Class<?> actualType) {
super(name, FactoryBean.class, actualType);
}

View File

@@ -31,10 +31,10 @@ public class BeanNotOfRequiredTypeException extends BeansException {
private String beanName;
/** The required type */
private Class requiredType;
private Class<?> requiredType;
/** The offending type */
private Class actualType;
private Class<?> actualType;
/**
@@ -44,7 +44,7 @@ public class BeanNotOfRequiredTypeException extends BeansException {
* @param actualType the actual type returned, which did not match
* the expected type
*/
public BeanNotOfRequiredTypeException(String beanName, Class requiredType, Class actualType) {
public BeanNotOfRequiredTypeException(String beanName, Class<?> requiredType, Class<?> actualType) {
super("Bean named '" + beanName + "' must be of type [" + requiredType.getName() +
"], but was actually of type [" + actualType.getName() + "]");
this.beanName = beanName;
@@ -63,14 +63,14 @@ public class BeanNotOfRequiredTypeException extends BeansException {
/**
* Return the expected type for the bean.
*/
public Class getRequiredType() {
public Class<?> getRequiredType() {
return this.requiredType;
}
/**
* Return the actual type of the instance found.
*/
public Class getActualType() {
public Class<?> getActualType() {
return this.actualType;
}

View File

@@ -69,7 +69,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* @param msg the detail message
*/
public UnsatisfiedDependencyException(
String resourceDescription, String beanName, int ctorArgIndex, Class ctorArgType, String msg) {
String resourceDescription, String beanName, int ctorArgIndex, Class<?> ctorArgType, String msg) {
super(resourceDescription, beanName,
"Unsatisfied dependency expressed through constructor argument with index " +
@@ -86,7 +86,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
* @param ex the bean creation exception that indicated the unsatisfied dependency
*/
public UnsatisfiedDependencyException(
String resourceDescription, String beanName, int ctorArgIndex, Class ctorArgType, BeansException ex) {
String resourceDescription, String beanName, int ctorArgIndex, Class<?> ctorArgType, BeansException ex) {
this(resourceDescription, beanName, ctorArgIndex, ctorArgType, (ex != null ? ": " + ex.getMessage() : ""));
initCause(ex);

View File

@@ -268,10 +268,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
if (requiredConstructor == null && defaultConstructor != null) {
candidates.add(defaultConstructor);
}
candidateConstructors = candidates.toArray(new Constructor[candidates.size()]);
candidateConstructors = candidates.toArray(new Constructor<?>[candidates.size()]);
}
else {
candidateConstructors = new Constructor[0];
candidateConstructors = new Constructor<?>[0];
}
this.candidateConstructorsCache.put(beanClass, candidateConstructors);
}

View File

@@ -50,7 +50,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
private Set customQualifierTypes;
private Set<?> customQualifierTypes;
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
@@ -79,7 +79,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
* does not require explicit registration.
* @param customQualifierTypes the custom types to register
*/
public void setCustomQualifierTypes(Set customQualifierTypes) {
public void setCustomQualifierTypes(Set<?> customQualifierTypes) {
this.customQualifierTypes = customQualifierTypes;
}
@@ -99,13 +99,13 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
QualifierAnnotationAutowireCandidateResolver resolver =
(QualifierAnnotationAutowireCandidateResolver) dlbf.getAutowireCandidateResolver();
for (Object value : this.customQualifierTypes) {
Class customType = null;
Class<? extends Annotation> customType = null;
if (value instanceof Class) {
customType = (Class) value;
customType = (Class<? extends Annotation>) value;
}
else if (value instanceof String) {
String className = (String) value;
customType = ClassUtils.resolveClassName(className, this.beanClassLoader);
customType = (Class<? extends Annotation>) ClassUtils.resolveClassName(className, this.beanClassLoader);
}
else {
throw new IllegalArgumentException(

View File

@@ -243,7 +243,7 @@ public class InitDestroyAnnotationBeanPostProcessor
*/
private class LifecycleMetadata {
private final Class targetClass;
private final Class<?> targetClass;
private final Collection<LifecycleElement> initMethods;

View File

@@ -158,7 +158,7 @@ public abstract class AbstractFactoryBean<T>
*/
@SuppressWarnings("unchecked")
private T getEarlySingletonInstance() throws Exception {
Class[] ifcs = getEarlySingletonInterfaces();
Class<?>[] ifcs = getEarlySingletonInterfaces();
if (ifcs == null) {
throw new FactoryBeanNotInitializedException(
getClass().getName() + " does not support circular references");
@@ -225,9 +225,9 @@ public abstract class AbstractFactoryBean<T>
* or {@code null} to indicate a FactoryBeanNotInitializedException
* @see org.springframework.beans.factory.FactoryBeanNotInitializedException
*/
protected Class[] getEarlySingletonInterfaces() {
Class type = getObjectType();
return (type != null && type.isInterface() ? new Class[] {type} : null);
protected Class<?>[] getEarlySingletonInterfaces() {
Class<?> type = getObjectType();
return (type != null && type.isInterface() ? new Class<?>[] {type} : null);
}
/**

View File

@@ -46,7 +46,7 @@ import org.springframework.beans.factory.SmartFactoryBean;
* (which support placeholder parsing since Spring 2.5)
*/
@Deprecated
public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAware {
public class BeanReferenceFactoryBean implements SmartFactoryBean<Object>, BeanFactoryAware {
private String targetBeanName;
@@ -86,7 +86,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw
}
@Override
public Class getObjectType() {
public Class<?> getObjectType() {
if (this.beanFactory == null) {
return null;
}

View File

@@ -140,7 +140,6 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered
@Override
@SuppressWarnings("unchecked")
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (this.propertyEditorRegistrars != null) {
for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
@@ -149,7 +148,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered
}
if (this.customEditors != null) {
for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
Class requiredType = entry.getKey();
Class<?> requiredType = entry.getKey();
Class<? extends PropertyEditor> propertyEditorClass = entry.getValue();
beanFactory.registerCustomEditor(requiredType, propertyEditorClass);
}

View File

@@ -77,7 +77,6 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
@Override
@SuppressWarnings("unchecked")
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (this.scopes != null) {
for (Map.Entry<String, Object> entry : this.scopes.entrySet()) {
@@ -87,12 +86,12 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
beanFactory.registerScope(scopeKey, (Scope) value);
}
else if (value instanceof Class) {
Class scopeClass = (Class) value;
Class<?> scopeClass = (Class<?>) value;
Assert.isAssignable(Scope.class, scopeClass);
beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass));
}
else if (value instanceof String) {
Class scopeClass = ClassUtils.resolveClassName((String) value, this.beanClassLoader);
Class<?> scopeClass = ClassUtils.resolveClassName((String) value, this.beanClassLoader);
Assert.isAssignable(Scope.class, scopeClass);
beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass));
}

View File

@@ -52,7 +52,7 @@ public class DependencyDescriptor implements Serializable {
private String methodName;
private Class[] parameterTypes;
private Class<?>[] parameterTypes;
private int parameterIndex;
@@ -267,12 +267,12 @@ public class DependencyDescriptor implements Serializable {
Type[] args = ((ParameterizedType) type).getActualTypeArguments();
Type arg = args[args.length - 1];
if (arg instanceof Class) {
return (Class) arg;
return (Class<?>) arg;
}
else if (arg instanceof ParameterizedType) {
arg = ((ParameterizedType) arg).getRawType();
if (arg instanceof Class) {
return (Class) arg;
return (Class<?>) arg;
}
}
}

View File

@@ -55,7 +55,7 @@ import org.springframework.util.StringUtils;
public class FieldRetrievingFactoryBean
implements FactoryBean<Object>, BeanNameAware, BeanClassLoaderAware, InitializingBean {
private Class targetClass;
private Class<?> targetClass;
private Object targetObject;
@@ -78,14 +78,14 @@ public class FieldRetrievingFactoryBean
* @see #setTargetObject
* @see #setTargetField
*/
public void setTargetClass(Class targetClass) {
public void setTargetClass(Class<?> targetClass) {
this.targetClass = targetClass;
}
/**
* Return the target class on which the field is defined.
*/
public Class getTargetClass() {
public Class<?> getTargetClass() {
return targetClass;
}
@@ -189,7 +189,7 @@ public class FieldRetrievingFactoryBean
}
// Try to get the exact method first.
Class targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass;
Class<?> targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass;
this.fieldObject = targetClass.getField(this.targetField);
}

View File

@@ -32,17 +32,18 @@ import org.springframework.core.GenericCollectionTypeResolver;
* @see SetFactoryBean
* @see MapFactoryBean
*/
public class ListFactoryBean extends AbstractFactoryBean<List> {
public class ListFactoryBean extends AbstractFactoryBean<List<Object>> {
private List sourceList;
private List<?> sourceList;
private Class targetListClass;
@SuppressWarnings("rawtypes")
private Class<? extends List> targetListClass;
/**
* Set the source List, typically populated via XML "list" elements.
*/
public void setSourceList(List sourceList) {
public void setSourceList(List<?> sourceList) {
this.sourceList = sourceList;
}
@@ -52,7 +53,8 @@ public class ListFactoryBean extends AbstractFactoryBean<List> {
* <p>Default is a {@code java.util.ArrayList}.
* @see java.util.ArrayList
*/
public void setTargetListClass(Class targetListClass) {
@SuppressWarnings("rawtypes")
public void setTargetListClass(Class<? extends List> targetListClass) {
if (targetListClass == null) {
throw new IllegalArgumentException("'targetListClass' must not be null");
}
@@ -64,24 +66,25 @@ public class ListFactoryBean extends AbstractFactoryBean<List> {
@Override
@SuppressWarnings("rawtypes")
public Class<List> getObjectType() {
return List.class;
}
@Override
@SuppressWarnings("unchecked")
protected List createInstance() {
protected List<Object> createInstance() {
if (this.sourceList == null) {
throw new IllegalArgumentException("'sourceList' is required");
}
List result = null;
List<Object> result = null;
if (this.targetListClass != null) {
result = (List) BeanUtils.instantiateClass(this.targetListClass);
result = BeanUtils.instantiateClass(this.targetListClass);
}
else {
result = new ArrayList(this.sourceList.size());
result = new ArrayList<Object>(this.sourceList.size());
}
Class valueType = null;
Class<?> valueType = null;
if (this.targetListClass != null) {
valueType = GenericCollectionTypeResolver.getCollectionType(this.targetListClass);
}

View File

@@ -32,17 +32,18 @@ import org.springframework.core.GenericCollectionTypeResolver;
* @see SetFactoryBean
* @see ListFactoryBean
*/
public class MapFactoryBean extends AbstractFactoryBean<Map> {
public class MapFactoryBean extends AbstractFactoryBean<Map<Object, Object>> {
private Map<?, ?> sourceMap;
private Class targetMapClass;
@SuppressWarnings("rawtypes")
private Class<? extends Map> targetMapClass;
/**
* Set the source Map, typically populated via XML "map" elements.
*/
public void setSourceMap(Map sourceMap) {
public void setSourceMap(Map<?, ?> sourceMap) {
this.sourceMap = sourceMap;
}
@@ -52,7 +53,8 @@ public class MapFactoryBean extends AbstractFactoryBean<Map> {
* <p>Default is a linked HashMap, keeping the registration order.
* @see java.util.LinkedHashMap
*/
public void setTargetMapClass(Class targetMapClass) {
@SuppressWarnings("rawtypes")
public void setTargetMapClass(Class<? extends Map> targetMapClass) {
if (targetMapClass == null) {
throw new IllegalArgumentException("'targetMapClass' must not be null");
}
@@ -64,32 +66,33 @@ public class MapFactoryBean extends AbstractFactoryBean<Map> {
@Override
@SuppressWarnings("rawtypes")
public Class<Map> getObjectType() {
return Map.class;
}
@Override
@SuppressWarnings("unchecked")
protected Map createInstance() {
protected Map<Object, Object> createInstance() {
if (this.sourceMap == null) {
throw new IllegalArgumentException("'sourceMap' is required");
}
Map result = null;
Map<Object, Object> result = null;
if (this.targetMapClass != null) {
result = (Map) BeanUtils.instantiateClass(this.targetMapClass);
result = BeanUtils.instantiateClass(this.targetMapClass);
}
else {
result = new LinkedHashMap(this.sourceMap.size());
result = new LinkedHashMap<Object, Object>(this.sourceMap.size());
}
Class keyType = null;
Class valueType = null;
Class<?> keyType = null;
Class<?> valueType = null;
if (this.targetMapClass != null) {
keyType = GenericCollectionTypeResolver.getMapKeyType(this.targetMapClass);
valueType = GenericCollectionTypeResolver.getMapValueType(this.targetMapClass);
}
if (keyType != null || valueType != null) {
TypeConverter converter = getBeanTypeConverter();
for (Map.Entry entry : this.sourceMap.entrySet()) {
for (Map.Entry<?, ?> entry : this.sourceMap.entrySet()) {
Object convertedKey = converter.convertIfNecessary(entry.getKey(), keyType);
Object convertedValue = converter.convertIfNecessary(entry.getValue(), valueType);
result.put(convertedKey, convertedValue);

View File

@@ -121,7 +121,7 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker
}
@Override
protected Class resolveClassName(String className) throws ClassNotFoundException {
protected Class<?> resolveClassName(String className) throws ClassNotFoundException {
return ClassUtils.forName(className, this.beanClassLoader);
}

View File

@@ -94,7 +94,7 @@ import org.springframework.util.Assert;
* @see org.springframework.beans.factory.ObjectFactory
* @see ServiceLocatorFactoryBean
*/
public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBean<ObjectFactory> {
public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBean<ObjectFactory<Object>> {
private String targetBeanName;
@@ -118,12 +118,12 @@ public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBean<Object
@Override
public Class getObjectType() {
public Class<?> getObjectType() {
return ObjectFactory.class;
}
@Override
protected ObjectFactory createInstance() {
protected ObjectFactory<Object> createInstance() {
return new TargetBeanObjectFactory(getBeanFactory(), this.targetBeanName);
}
@@ -132,7 +132,7 @@ public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBean<Object
* Independent inner class - for serialization purposes.
*/
@SuppressWarnings("serial")
private static class TargetBeanObjectFactory implements ObjectFactory, Serializable {
private static class TargetBeanObjectFactory implements ObjectFactory<Object>, Serializable {
private final BeanFactory beanFactory;

View File

@@ -100,7 +100,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
throws BeansException {
for (Enumeration names = props.propertyNames(); names.hasMoreElements();) {
for (Enumeration<?> names = props.propertyNames(); names.hasMoreElements();) {
String key = (String) names.nextElement();
try {
processKey(beanFactory, key, props.getProperty(key));

View File

@@ -91,7 +91,7 @@ public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAwa
private String propertyPath;
private Class resultType;
private Class<?> resultType;
private String beanName;
@@ -137,7 +137,7 @@ public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAwa
* provided that you need matching by type (for example, for autowiring).
* @param resultType the result type, for example "java.lang.Integer"
*/
public void setResultType(Class resultType) {
public void setResultType(Class<?> resultType) {
this.resultType = resultType;
}

View File

@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
* @see javax.inject.Provider
* @see ObjectFactoryCreatingFactoryBean
*/
public class ProviderCreatingFactoryBean extends AbstractFactoryBean<Provider> {
public class ProviderCreatingFactoryBean extends AbstractFactoryBean<Provider<Object>> {
private String targetBeanName;
@@ -63,12 +63,12 @@ public class ProviderCreatingFactoryBean extends AbstractFactoryBean<Provider> {
@Override
public Class getObjectType() {
public Class<?> getObjectType() {
return Provider.class;
}
@Override
protected Provider createInstance() {
protected Provider<Object> createInstance() {
return new TargetBeanProvider(getBeanFactory(), this.targetBeanName);
}
@@ -77,7 +77,7 @@ public class ProviderCreatingFactoryBean extends AbstractFactoryBean<Provider> {
* Independent inner class - for serialization purposes.
*/
@SuppressWarnings("serial")
private static class TargetBeanProvider implements Provider, Serializable {
private static class TargetBeanProvider implements Provider<Object>, Serializable {
private final BeanFactory beanFactory;

View File

@@ -188,9 +188,9 @@ import org.springframework.util.StringUtils;
*/
public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFactoryAware, InitializingBean {
private Class serviceLocatorInterface;
private Class<?> serviceLocatorInterface;
private Constructor serviceLocatorExceptionConstructor;
private Constructor<Exception> serviceLocatorExceptionConstructor;
private Properties serviceMappings;
@@ -206,7 +206,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
* See the {@link ServiceLocatorFactoryBean class-level Javadoc} for
* information on the semantics of such methods.
*/
public void setServiceLocatorInterface(Class interfaceType) {
public void setServiceLocatorInterface(Class<?> interfaceType) {
this.serviceLocatorInterface = interfaceType;
}
@@ -222,7 +222,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
* @see #determineServiceLocatorExceptionConstructor
* @see #createServiceLocatorException
*/
public void setServiceLocatorExceptionClass(Class serviceLocatorExceptionClass) {
public void setServiceLocatorExceptionClass(Class<? extends Exception> serviceLocatorExceptionClass) {
if (serviceLocatorExceptionClass != null && !Exception.class.isAssignableFrom(serviceLocatorExceptionClass)) {
throw new IllegalArgumentException(
"serviceLocatorException [" + serviceLocatorExceptionClass.getName() + "] is not a subclass of Exception");
@@ -263,7 +263,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
// Create service locator proxy.
this.proxy = Proxy.newProxyInstance(
this.serviceLocatorInterface.getClassLoader(),
new Class[] {this.serviceLocatorInterface},
new Class<?>[] {this.serviceLocatorInterface},
new ServiceLocatorInvocationHandler());
}
@@ -278,17 +278,18 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
* @return the constructor to use
* @see #setServiceLocatorExceptionClass
*/
protected Constructor determineServiceLocatorExceptionConstructor(Class exceptionClass) {
@SuppressWarnings("unchecked")
protected Constructor<Exception> determineServiceLocatorExceptionConstructor(Class<? extends Exception> exceptionClass) {
try {
return exceptionClass.getConstructor(new Class[] {String.class, Throwable.class});
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class, Throwable.class});
}
catch (NoSuchMethodException ex) {
try {
return exceptionClass.getConstructor(new Class[] {Throwable.class});
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {Throwable.class});
}
catch (NoSuchMethodException ex2) {
try {
return exceptionClass.getConstructor(new Class[] {String.class});
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class});
}
catch (NoSuchMethodException ex3) {
throw new IllegalArgumentException(
@@ -309,8 +310,8 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
* @return the service locator exception to throw
* @see #setServiceLocatorExceptionClass
*/
protected Exception createServiceLocatorException(Constructor exceptionConstructor, BeansException cause) {
Class[] paramTypes = exceptionConstructor.getParameterTypes();
protected Exception createServiceLocatorException(Constructor<Exception> exceptionConstructor, BeansException cause) {
Class<?>[] paramTypes = exceptionConstructor.getParameterTypes();
Object[] args = new Object[paramTypes.length];
for (int i = 0; i < paramTypes.length; i++) {
if (paramTypes[i].equals(String.class)) {
@@ -320,7 +321,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
args[i] = cause;
}
}
return (Exception) BeanUtils.instantiateClass(exceptionConstructor, args);
return BeanUtils.instantiateClass(exceptionConstructor, args);
}
@@ -363,9 +364,8 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
}
}
@SuppressWarnings("unchecked")
private Object invokeServiceLocatorMethod(Method method, Object[] args) throws Exception {
Class serviceLocatorMethodReturnType = getServiceLocatorMethodReturnType(method);
Class<?> serviceLocatorMethodReturnType = getServiceLocatorMethodReturnType(method);
try {
String beanName = tryGetBeanName(args);
if (StringUtils.hasLength(beanName)) {
@@ -403,10 +403,10 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
return beanName;
}
private Class getServiceLocatorMethodReturnType(Method method) throws NoSuchMethodException {
Class[] paramTypes = method.getParameterTypes();
private Class<?> getServiceLocatorMethodReturnType(Method method) throws NoSuchMethodException {
Class<?>[] paramTypes = method.getParameterTypes();
Method interfaceMethod = serviceLocatorInterface.getMethod(method.getName(), paramTypes);
Class serviceLocatorReturnType = interfaceMethod.getReturnType();
Class<?> serviceLocatorReturnType = interfaceMethod.getReturnType();
// Check whether the method is a valid service locator.
if (paramTypes.length > 1 || void.class.equals(serviceLocatorReturnType)) {

View File

@@ -32,17 +32,18 @@ import org.springframework.core.GenericCollectionTypeResolver;
* @see ListFactoryBean
* @see MapFactoryBean
*/
public class SetFactoryBean extends AbstractFactoryBean<Set> {
public class SetFactoryBean extends AbstractFactoryBean<Set<Object>> {
private Set sourceSet;
private Set<?> sourceSet;
private Class targetSetClass;
@SuppressWarnings("rawtypes")
private Class<? extends Set> targetSetClass;
/**
* Set the source Set, typically populated via XML "set" elements.
*/
public void setSourceSet(Set sourceSet) {
public void setSourceSet(Set<?> sourceSet) {
this.sourceSet = sourceSet;
}
@@ -52,7 +53,8 @@ public class SetFactoryBean extends AbstractFactoryBean<Set> {
* <p>Default is a linked HashSet, keeping the registration order.
* @see java.util.LinkedHashSet
*/
public void setTargetSetClass(Class targetSetClass) {
@SuppressWarnings("rawtypes")
public void setTargetSetClass(Class<? extends Set> targetSetClass) {
if (targetSetClass == null) {
throw new IllegalArgumentException("'targetSetClass' must not be null");
}
@@ -64,24 +66,25 @@ public class SetFactoryBean extends AbstractFactoryBean<Set> {
@Override
@SuppressWarnings("rawtypes")
public Class<Set> getObjectType() {
return Set.class;
}
@Override
@SuppressWarnings("unchecked")
protected Set createInstance() {
protected Set<Object> createInstance() {
if (this.sourceSet == null) {
throw new IllegalArgumentException("'sourceSet' is required");
}
Set result = null;
Set<Object> result = null;
if (this.targetSetClass != null) {
result = (Set) BeanUtils.instantiateClass(this.targetSetClass);
result = BeanUtils.instantiateClass(this.targetSetClass);
}
else {
result = new LinkedHashSet(this.sourceSet.size());
result = new LinkedHashSet<Object>(this.sourceSet.size());
}
Class valueType = null;
Class<?> valueType = null;
if (this.targetSetClass != null) {
valueType = GenericCollectionTypeResolver.getCollectionType(this.targetSetClass);
}

View File

@@ -114,7 +114,7 @@ public class TypedStringValue implements BeanMetadataElement {
if (!(targetTypeValue instanceof Class)) {
throw new IllegalStateException("Typed String value does not carry a resolved target type");
}
return (Class) targetTypeValue;
return (Class<?>) targetTypeValue;
}
/**
@@ -131,7 +131,7 @@ public class TypedStringValue implements BeanMetadataElement {
public String getTargetTypeName() {
Object targetTypeValue = this.targetType;
if (targetTypeValue instanceof Class) {
return ((Class) targetTypeValue).getName();
return ((Class<?>) targetTypeValue).getName();
}
else {
return (String) targetTypeValue;

View File

@@ -40,22 +40,23 @@ public final class ParseState {
/**
* Internal {@link Stack} storage.
*/
private final Stack state;
private final Stack<Entry> state;
/**
* Create a new {@code ParseState} with an empty {@link Stack}.
*/
public ParseState() {
this.state = new Stack();
this.state = new Stack<Entry>();
}
/**
* Create a new {@code ParseState} whose {@link Stack} is a {@link Object#clone clone}
* of that of the passed in {@code ParseState}.
*/
@SuppressWarnings("unchecked")
private ParseState(ParseState other) {
this.state = (Stack) other.state.clone();
this.state = (Stack<Entry>) other.state.clone();
}
@@ -78,7 +79,7 @@ public final class ParseState {
* {@code null} if the {@link Stack} is empty.
*/
public Entry peek() {
return (Entry) (this.state.empty() ? null : this.state.peek());
return this.state.empty() ? null : this.state.peek();
}
/**

View File

@@ -31,10 +31,10 @@ import org.springframework.util.ClassUtils;
* @since 2.5
* @see java.util.ServiceLoader
*/
public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFactoryBean
public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFactoryBean<Object>
implements BeanClassLoaderAware {
private Class serviceType;
private Class<?> serviceType;
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
@@ -42,14 +42,14 @@ public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFact
/**
* Specify the desired service type (typically the service's public API).
*/
public void setServiceType(Class serviceType) {
public void setServiceType(Class<?> serviceType) {
this.serviceType = serviceType;
}
/**
* Return the desired service type.
*/
public Class getServiceType() {
public Class<?> getServiceType() {
return this.serviceType;
}
@@ -75,6 +75,6 @@ public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFact
* @param serviceLoader the ServiceLoader for the configured service class
* @return the object to expose
*/
protected abstract Object getObjectToExpose(ServiceLoader serviceLoader);
protected abstract Object getObjectToExpose(ServiceLoader<?> serviceLoader);
}

View File

@@ -33,8 +33,8 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
public class ServiceFactoryBean extends AbstractServiceLoaderBasedFactoryBean implements BeanClassLoaderAware {
@Override
protected Object getObjectToExpose(ServiceLoader serviceLoader) {
Iterator it = serviceLoader.iterator();
protected Object getObjectToExpose(ServiceLoader<?> serviceLoader) {
Iterator<?> it = serviceLoader.iterator();
if (!it.hasNext()) {
throw new IllegalStateException(
"ServiceLoader could not find service for type [" + getServiceType() + "]");
@@ -43,7 +43,7 @@ public class ServiceFactoryBean extends AbstractServiceLoaderBasedFactoryBean im
}
@Override
public Class getObjectType() {
public Class<?> getObjectType() {
return getServiceType();
}

View File

@@ -34,7 +34,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
public class ServiceListFactoryBean extends AbstractServiceLoaderBasedFactoryBean implements BeanClassLoaderAware {
@Override
protected Object getObjectToExpose(ServiceLoader serviceLoader) {
protected Object getObjectToExpose(ServiceLoader<?> serviceLoader) {
List<Object> result = new LinkedList<Object>();
for (Object loaderObject : serviceLoader) {
result.add(loaderObject);
@@ -43,7 +43,7 @@ public class ServiceListFactoryBean extends AbstractServiceLoaderBasedFactoryBea
}
@Override
public Class getObjectType() {
public Class<?> getObjectType() {
return List.class;
}

View File

@@ -31,12 +31,12 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
public class ServiceLoaderFactoryBean extends AbstractServiceLoaderBasedFactoryBean implements BeanClassLoaderAware {
@Override
protected Object getObjectToExpose(ServiceLoader serviceLoader) {
protected Object getObjectToExpose(ServiceLoader<?> serviceLoader) {
return serviceLoader;
}
@Override
public Class getObjectType() {
public Class<?> getObjectType() {
return ServiceLoader.class;
}

View File

@@ -135,21 +135,21 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* Dependency types to ignore on dependency check and autowire, as Set of
* Class objects: for example, String. Default is none.
*/
private final Set<Class> ignoredDependencyTypes = new HashSet<Class>();
private final Set<Class<?>> ignoredDependencyTypes = new HashSet<Class<?>>();
/**
* Dependency interfaces to ignore on dependency check and autowire, as Set of
* Class objects. By default, only the BeanFactory interface is ignored.
*/
private final Set<Class> ignoredDependencyInterfaces = new HashSet<Class>();
private final Set<Class<?>> ignoredDependencyInterfaces = new HashSet<Class<?>>();
/** Cache of unfinished FactoryBean instances: FactoryBean name --> BeanWrapper */
private final Map<String, BeanWrapper> factoryBeanInstanceCache =
new ConcurrentHashMap<String, BeanWrapper>(16);
/** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */
private final Map<Class, PropertyDescriptor[]> filteredPropertyDescriptorsCache =
new ConcurrentHashMap<Class, PropertyDescriptor[]>(64);
private final Map<Class<?>, PropertyDescriptor[]> filteredPropertyDescriptorsCache =
new ConcurrentHashMap<Class<?>, PropertyDescriptor[]>(64);
/**
@@ -523,7 +523,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
logger.debug("Eagerly caching bean '" + beanName +
"' to allow for resolving potential circular references");
}
addSingletonFactory(beanName, new ObjectFactory() {
addSingletonFactory(beanName, new ObjectFactory<Object>() {
@Override
public Object getObject() throws BeansException {
return getEarlyBeanReference(beanName, mbd, bean);
@@ -821,11 +821,12 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the FactoryBean instance, or {@code null} to indicate
* that we couldn't obtain a shortcut FactoryBean instance
*/
private FactoryBean getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
@SuppressWarnings("unchecked")
private FactoryBean<Object> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
synchronized (getSingletonMutex()) {
BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName);
if (bw != null) {
return (FactoryBean) bw.getWrappedInstance();
return (FactoryBean<Object>) bw.getWrappedInstance();
}
if (isSingletonCurrentlyInCreation(beanName)) {
return null;
@@ -845,7 +846,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Finished partial creation of this bean.
afterSingletonCreation(beanName);
}
FactoryBean fb = getFactoryBean(beanName, instance);
FactoryBean<Object> fb = getFactoryBean(beanName, instance);
if (bw != null) {
this.factoryBeanInstanceCache.put(beanName, bw);
}
@@ -862,7 +863,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the FactoryBean instance, or {@code null} to indicate
* that we couldn't obtain a shortcut FactoryBean instance
*/
private FactoryBean getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
private FactoryBean<Object> getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
if (isPrototypeCurrentlyInCreation(beanName)) {
return null;
}
@@ -1005,7 +1006,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
// Need to determine the constructor...
Constructor[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
Constructor<?>[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
if (ctors != null ||
mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR ||
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
@@ -1025,14 +1026,14 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor#determineCandidateConstructors
*/
protected Constructor[] determineConstructorsFromBeanPostProcessors(Class<?> beanClass, String beanName)
protected Constructor<?>[] determineConstructorsFromBeanPostProcessors(Class<?> beanClass, String beanName)
throws BeansException {
if (beanClass != null && hasInstantiationAwareBeanPostProcessors()) {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof SmartInstantiationAwareBeanPostProcessor) {
SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp;
Constructor[] ctors = ibp.determineCandidateConstructors(beanClass, beanName);
Constructor<?>[] ctors = ibp.determineCandidateConstructors(beanClass, beanName);
if (ctors != null) {
return ctors;
}
@@ -1104,7 +1105,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return BeanWrapper for the new instance
*/
protected BeanWrapper autowireConstructor(
String beanName, RootBeanDefinition mbd, Constructor[] ctors, Object[] explicitArgs) {
String beanName, RootBeanDefinition mbd, Constructor<?>[] ctors, Object[] explicitArgs) {
return new ConstructorResolver(this).autowireConstructor(beanName, mbd, ctors, explicitArgs);
}

View File

@@ -357,7 +357,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
throw new IllegalStateException(
"Bean class name [" + beanClassObject + "] has not been resolved into an actual Class");
}
return (Class) beanClassObject;
return (Class<?>) beanClassObject;
}
@Override
@@ -369,7 +369,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
public String getBeanClassName() {
Object beanClassObject = this.beanClass;
if (beanClassObject instanceof Class) {
return ((Class) beanClassObject).getName();
return ((Class<?>) beanClassObject).getName();
}
else {
return (String) beanClassObject;
@@ -384,12 +384,12 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* @return the resolved bean class
* @throws ClassNotFoundException if the class name could be resolved
*/
public Class resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException {
public Class<?> resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException {
String className = getBeanClassName();
if (className == null) {
return null;
}
Class resolvedClass = ClassUtils.forName(className, classLoader);
Class<?> resolvedClass = ClassUtils.forName(className, classLoader);
this.beanClass = resolvedClass;
return resolvedClass;
}
@@ -512,8 +512,8 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
// Work out whether to apply setter autowiring or constructor autowiring.
// If it has a no-arg constructor it's deemed to be setter autowiring,
// otherwise we'll try constructor autowiring.
Constructor[] constructors = getBeanClass().getConstructors();
for (Constructor constructor : constructors) {
Constructor<?>[] constructors = getBeanClass().getConstructors();
for (Constructor<?> constructor : constructors) {
if (constructor.getParameterTypes().length == 0) {
return AUTOWIRE_BY_TYPE;
}

View File

@@ -513,8 +513,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
// Retrieve corresponding bean definition.
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
Class[] typesToMatch = (FactoryBean.class.equals(typeToMatch) ?
new Class[] {typeToMatch} : new Class[] {FactoryBean.class, typeToMatch});
Class<?>[] typesToMatch = (FactoryBean.class.equals(typeToMatch) ?
new Class<?>[] {typeToMatch} : new Class<?>[] {FactoryBean.class, typeToMatch});
// Check decorated bean definition, if any: We assume it'll be easier
// to determine the decorated bean's type than the proxy's type.

View File

@@ -42,7 +42,7 @@ public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor {
* given type.
* @param type the annotation type
*/
public AutowireCandidateQualifier(Class type) {
public AutowireCandidateQualifier(Class<?> type) {
this(type.getName());
}
@@ -65,7 +65,7 @@ public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor {
* @param type the annotation type
* @param value the annotation value to match
*/
public AutowireCandidateQualifier(Class type, Object value) {
public AutowireCandidateQualifier(Class<?> type, Object value) {
this(type.getName(), value);
}

View File

@@ -56,10 +56,10 @@ abstract class AutowireUtils {
* decreasing number of arguments.
* @param constructors the constructor array to sort
*/
public static void sortConstructors(Constructor[] constructors) {
Arrays.sort(constructors, new Comparator<Constructor>() {
public static void sortConstructors(Constructor<?>[] constructors) {
Arrays.sort(constructors, new Comparator<Constructor<?>>() {
@Override
public int compare(Constructor c1, Constructor c2) {
public int compare(Constructor<?> c1, Constructor<?> c2) {
boolean p1 = Modifier.isPublic(c1.getModifiers());
boolean p2 = Modifier.isPublic(c2.getModifiers());
if (p1 != p2) {
@@ -112,7 +112,7 @@ abstract class AutowireUtils {
}
// It was declared by CGLIB, but we might still want to autowire it
// if it was actually declared by the superclass.
Class superclass = wm.getDeclaringClass().getSuperclass();
Class<?> superclass = wm.getDeclaringClass().getSuperclass();
return !ClassUtils.hasMethod(superclass, wm.getName(), wm.getParameterTypes());
}
@@ -123,7 +123,7 @@ abstract class AutowireUtils {
* @param interfaces the Set of interfaces (Class objects)
* @return whether the setter method is defined by an interface
*/
public static boolean isSetterDefinedInInterface(PropertyDescriptor pd, Set<Class> interfaces) {
public static boolean isSetterDefinedInInterface(PropertyDescriptor pd, Set<Class<?>> interfaces) {
Method setter = pd.getWriteMethod();
if (setter != null) {
Class<?> targetClass = setter.getDeclaringClass();
@@ -146,10 +146,10 @@ abstract class AutowireUtils {
*/
public static Object resolveAutowiringValue(Object autowiringValue, Class<?> requiredType) {
if (autowiringValue instanceof ObjectFactory && !requiredType.isInstance(autowiringValue)) {
ObjectFactory factory = (ObjectFactory) autowiringValue;
ObjectFactory<?> factory = (ObjectFactory<?>) autowiringValue;
if (autowiringValue instanceof Serializable && requiredType.isInterface()) {
autowiringValue = Proxy.newProxyInstance(requiredType.getClassLoader(),
new Class[] {requiredType}, new ObjectFactoryDelegatingInvocationHandler(factory));
new Class<?>[] {requiredType}, new ObjectFactoryDelegatingInvocationHandler(factory));
}
else {
return factory.getObject();
@@ -283,9 +283,9 @@ abstract class AutowireUtils {
@SuppressWarnings("serial")
private static class ObjectFactoryDelegatingInvocationHandler implements InvocationHandler, Serializable {
private final ObjectFactory objectFactory;
private final ObjectFactory<?> objectFactory;
public ObjectFactoryDelegatingInvocationHandler(ObjectFactory objectFactory) {
public ObjectFactoryDelegatingInvocationHandler(ObjectFactory<?> objectFactory) {
this.objectFactory = objectFactory;
}

View File

@@ -45,7 +45,7 @@ public class BeanDefinitionBuilder {
* Create a new {@code BeanDefinitionBuilder} used to construct a {@link GenericBeanDefinition}.
* @param beanClass the {@code Class} of the bean that the definition is being created for
*/
public static BeanDefinitionBuilder genericBeanDefinition(Class beanClass) {
public static BeanDefinitionBuilder genericBeanDefinition(Class<?> beanClass) {
BeanDefinitionBuilder builder = new BeanDefinitionBuilder();
builder.beanDefinition = new GenericBeanDefinition();
builder.beanDefinition.setBeanClass(beanClass);
@@ -67,7 +67,7 @@ public class BeanDefinitionBuilder {
* Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}.
* @param beanClass the {@code Class} of the bean that the definition is being created for
*/
public static BeanDefinitionBuilder rootBeanDefinition(Class beanClass) {
public static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass) {
return rootBeanDefinition(beanClass, null);
}
@@ -76,7 +76,7 @@ public class BeanDefinitionBuilder {
* @param beanClass the {@code Class} of the bean that the definition is being created for
* @param factoryMethodName the name of the method to use to construct the bean instance
*/
public static BeanDefinitionBuilder rootBeanDefinition(Class beanClass, String factoryMethodName) {
public static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass, String factoryMethodName) {
BeanDefinitionBuilder builder = new BeanDefinitionBuilder();
builder.beanDefinition = new RootBeanDefinition();
builder.beanDefinition.setBeanClass(beanClass);

View File

@@ -164,7 +164,7 @@ class BeanDefinitionValueResolver {
else if (value instanceof ManagedProperties) {
Properties original = (Properties) value;
Properties copy = new Properties();
for (Map.Entry propEntry : original.entrySet()) {
for (Map.Entry<Object, Object> propEntry : original.entrySet()) {
Object propKey = propEntry.getKey();
Object propValue = propEntry.getValue();
if (propKey instanceof TypedStringValue) {
@@ -272,7 +272,7 @@ class BeanDefinitionValueResolver {
this.beanFactory.registerContainedBean(actualInnerBeanName, this.beanName);
if (innerBean instanceof FactoryBean) {
boolean synthetic = mbd.isSynthetic();
return this.beanFactory.getObjectFromFactoryBean((FactoryBean) innerBean, actualInnerBeanName, !synthetic);
return this.beanFactory.getObjectFromFactoryBean((FactoryBean<?>) innerBean, actualInnerBeanName, !synthetic);
}
else {
return innerBean;
@@ -347,7 +347,7 @@ class BeanDefinitionValueResolver {
/**
* For each element in the managed list, resolve reference if necessary.
*/
private List resolveManagedList(Object argName, List<?> ml) {
private List<?> resolveManagedList(Object argName, List<?> ml) {
List<Object> resolved = new ArrayList<Object>(ml.size());
for (int i = 0; i < ml.size(); i++) {
resolved.add(
@@ -359,7 +359,7 @@ class BeanDefinitionValueResolver {
/**
* For each element in the managed set, resolve reference if necessary.
*/
private Set resolveManagedSet(Object argName, Set<?> ms) {
private Set<?> resolveManagedSet(Object argName, Set<?> ms) {
Set<Object> resolved = new LinkedHashSet<Object>(ms.size());
int i = 0;
for (Object m : ms) {
@@ -372,9 +372,9 @@ class BeanDefinitionValueResolver {
/**
* For each element in the managed map, resolve reference if necessary.
*/
private Map resolveManagedMap(Object argName, Map<?, ?> mm) {
private Map<?, ?> resolveManagedMap(Object argName, Map<?, ?> mm) {
Map<Object, Object> resolved = new LinkedHashMap<Object, Object>(mm.size());
for (Map.Entry entry : mm.entrySet()) {
for (Map.Entry<?, ?> entry : mm.entrySet()) {
Object resolvedKey = resolveValueIfNecessary(argName, entry.getKey());
Object resolvedValue = resolveValueIfNecessary(
new KeyedArgName(argName, entry.getKey()), entry.getValue());

View File

@@ -72,7 +72,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
@Override
protected Object instantiateWithMethodInjection(
RootBeanDefinition beanDefinition, String beanName, BeanFactory owner,
Constructor ctor, Object[] args) {
Constructor<?> ctor, Object[] args) {
return new CglibSubclassCreator(beanDefinition, owner).instantiate(ctor, args);
}
@@ -104,7 +104,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
* Ignored if the ctor parameter is {@code null}.
* @return new instance of the dynamically generated class
*/
public Object instantiate(Constructor ctor, Object[] args) {
public Object instantiate(Constructor<?> ctor, Object[] args) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(this.beanDefinition.getBeanClass());
enhancer.setCallbackFilter(new CallbackFilterImpl());

View File

@@ -103,12 +103,12 @@ class ConstructorResolver {
* @return a BeanWrapper for the new instance
*/
public BeanWrapper autowireConstructor(
final String beanName, final RootBeanDefinition mbd, Constructor[] chosenCtors, final Object[] explicitArgs) {
final String beanName, final RootBeanDefinition mbd, Constructor<?>[] chosenCtors, final Object[] explicitArgs) {
BeanWrapperImpl bw = new BeanWrapperImpl();
this.beanFactory.initBeanWrapper(bw);
Constructor constructorToUse = null;
Constructor<?> constructorToUse = null;
ArgumentsHolder argsHolderToUse = null;
Object[] argsToUse = null;
@@ -118,7 +118,7 @@ class ConstructorResolver {
else {
Object[] argsToResolve = null;
synchronized (mbd.constructorArgumentLock) {
constructorToUse = (Constructor) mbd.resolvedConstructorOrFactoryMethod;
constructorToUse = (Constructor<?>) mbd.resolvedConstructorOrFactoryMethod;
if (constructorToUse != null && mbd.constructorArgumentsResolved) {
// Found a cached constructor...
argsToUse = mbd.resolvedConstructorArguments;
@@ -149,7 +149,7 @@ class ConstructorResolver {
}
// Take specified constructors, if any.
Constructor[] candidates = chosenCtors;
Constructor<?>[] candidates = chosenCtors;
if (candidates == null) {
Class<?> beanClass = mbd.getBeanClass();
try {
@@ -164,7 +164,7 @@ class ConstructorResolver {
}
AutowireUtils.sortConstructors(candidates);
int minTypeDiffWeight = Integer.MAX_VALUE;
Set<Constructor> ambiguousConstructors = null;
Set<Constructor<?>> ambiguousConstructors = null;
List<Exception> causes = null;
for (int i = 0; i < candidates.length; i++) {
@@ -239,7 +239,7 @@ class ConstructorResolver {
}
else if (constructorToUse != null && typeDiffWeight == minTypeDiffWeight) {
if (ambiguousConstructors == null) {
ambiguousConstructors = new LinkedHashSet<Constructor>();
ambiguousConstructors = new LinkedHashSet<Constructor<?>>();
ambiguousConstructors.add(constructorToUse);
}
ambiguousConstructors.add(candidate);
@@ -267,7 +267,7 @@ class ConstructorResolver {
Object beanInstance;
if (System.getSecurityManager() != null) {
final Constructor ctorToUse = constructorToUse;
final Constructor<?> ctorToUse = constructorToUse;
final Object[] argumentsToUse = argsToUse;
beanInstance = AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
@@ -296,7 +296,7 @@ class ConstructorResolver {
* @param mbd the bean definition to check
*/
public void resolveFactoryMethodIfPossible(RootBeanDefinition mbd) {
Class factoryClass;
Class<?> factoryClass;
if (mbd.getFactoryBeanName() != null) {
factoryClass = this.beanFactory.getType(mbd.getFactoryBeanName());
}
@@ -762,7 +762,7 @@ class ConstructorResolver {
String beanName, RootBeanDefinition mbd, BeanWrapper bw, Member methodOrCtor, Object[] argsToResolve) {
Class<?>[] paramTypes = (methodOrCtor instanceof Method ?
((Method) methodOrCtor).getParameterTypes() : ((Constructor) methodOrCtor).getParameterTypes());
((Method) methodOrCtor).getParameterTypes() : ((Constructor<?>) methodOrCtor).getParameterTypes());
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
this.beanFactory.getCustomTypeConverter() : bw);
BeanDefinitionValueResolver valueResolver =

View File

@@ -128,7 +128,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
private boolean allowEagerClassLoading = true;
/** Optional OrderComparator for dependency Lists and arrays */
private Comparator dependencyComparator;
private Comparator<Object> dependencyComparator;
/** Resolver to use for checking if a bean definition is an autowire candidate */
private AutowireCandidateResolver autowireCandidateResolver = new SimpleAutowireCandidateResolver();
@@ -215,14 +215,14 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
* @see org.springframework.core.OrderComparator
* @see org.springframework.core.annotation.AnnotationAwareOrderComparator
*/
public void setDependencyComparator(Comparator dependencyComparator) {
public void setDependencyComparator(Comparator<Object> dependencyComparator) {
this.dependencyComparator = dependencyComparator;
}
/**
* Return the dependency comparator for this BeanFactory (may be {@code null}.
*/
public Comparator getDependencyComparator() {
public Comparator<Object> getDependencyComparator() {
return this.dependencyComparator;
}
@@ -898,7 +898,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
Object result = converter.convertIfNecessary(matchingBeans.values(), type);
if (this.dependencyComparator != null && result instanceof List) {
Collections.sort((List) result, this.dependencyComparator);
Collections.sort((List<?>) result, this.dependencyComparator);
}
return result;
}

View File

@@ -85,7 +85,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
private final Map<String, Object> singletonObjects = new ConcurrentHashMap<String, Object>(64);
/** Cache of singleton factories: bean name --> ObjectFactory */
private final Map<String, ObjectFactory> singletonFactories = new HashMap<String, ObjectFactory>(16);
private final Map<String, ObjectFactory<?>> singletonFactories = new HashMap<String, ObjectFactory<?>>(16);
/** Cache of early singleton objects: bean name --> bean instance */
private final Map<String, Object> earlySingletonObjects = new HashMap<String, Object>(16);
@@ -156,7 +156,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
* @param beanName the name of the bean
* @param singletonFactory the factory for the singleton object
*/
protected void addSingletonFactory(String beanName, ObjectFactory singletonFactory) {
protected void addSingletonFactory(String beanName, ObjectFactory<?> singletonFactory) {
Assert.notNull(singletonFactory, "Singleton factory must not be null");
synchronized (this.singletonObjects) {
if (!this.singletonObjects.containsKey(beanName)) {
@@ -186,7 +186,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
synchronized (this.singletonObjects) {
singletonObject = this.earlySingletonObjects.get(beanName);
if (singletonObject == null && allowEarlyReference) {
ObjectFactory singletonFactory = this.singletonFactories.get(beanName);
ObjectFactory<?> singletonFactory = this.singletonFactories.get(beanName);
if (singletonFactory != null) {
singletonObject = singletonFactory.getObject();
this.earlySingletonObjects.put(beanName, singletonObject);
@@ -206,7 +206,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
* with, if necessary
* @return the registered singleton object
*/
public Object getSingleton(String beanName, ObjectFactory singletonFactory) {
public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
Assert.notNull(beanName, "'beanName' must not be null");
synchronized (this.singletonObjects) {
Object singletonObject = this.singletonObjects.get(beanName);

View File

@@ -65,7 +65,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
private static final Log logger = LogFactory.getLog(DisposableBeanAdapter.class);
private static Class closeableInterface;
private static Class<?> closeableInterface;
static {
try {

View File

@@ -52,12 +52,12 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
* @return the FactoryBean's object type,
* or {@code null} if the type cannot be determined yet
*/
protected Class getTypeForFactoryBean(final FactoryBean factoryBean) {
protected Class<?> getTypeForFactoryBean(final FactoryBean<?> factoryBean) {
try {
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged(new PrivilegedAction<Class>() {
return AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
@Override
public Class run() {
public Class<?> run() {
return factoryBean.getObjectType();
}
}, getAccessControlContext());
@@ -95,7 +95,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
* @throws BeanCreationException if FactoryBean object creation failed
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
protected Object getObjectFromFactoryBean(FactoryBean factory, String beanName, boolean shouldPostProcess) {
protected Object getObjectFromFactoryBean(FactoryBean<?> factory, String beanName, boolean shouldPostProcess) {
if (factory.isSingleton() && containsSingleton(beanName)) {
synchronized (getSingletonMutex()) {
Object object = this.factoryBeanObjectCache.get(beanName);
@@ -121,7 +121,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
private Object doGetObjectFromFactoryBean(
final FactoryBean factory, final String beanName, final boolean shouldPostProcess)
final FactoryBean<?> factory, final String beanName, final boolean shouldPostProcess)
throws BeanCreationException {
Object object;
@@ -192,12 +192,13 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
* @return the bean instance as FactoryBean
* @throws BeansException if the given bean cannot be exposed as a FactoryBean
*/
protected FactoryBean getFactoryBean(String beanName, Object beanInstance) throws BeansException {
@SuppressWarnings("unchecked")
protected FactoryBean<Object> getFactoryBean(String beanName, Object beanInstance) throws BeansException {
if (!(beanInstance instanceof FactoryBean)) {
throw new BeanCreationException(beanName,
"Bean instance of type [" + beanInstance.getClass() + "] is not a FactoryBean");
}
return (FactoryBean) beanInstance;
return (FactoryBean<Object>) beanInstance;
}
/**

View File

@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
public class ManagedArray extends ManagedList<Object> {
/** Resolved element type for runtime creation of the target array */
volatile Class resolvedElementType;
volatile Class<?> resolvedElementType;
/**

View File

@@ -102,7 +102,7 @@ public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetad
throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]");
}
List<E> merged = new ManagedList<E>();
merged.addAll((List) parent);
merged.addAll((List<E>) parent);
merged.addAll(this);
return merged;
}

View File

@@ -117,7 +117,7 @@ public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable,
throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]");
}
Map<K, V> merged = new ManagedMap<K, V>();
merged.putAll((Map) parent);
merged.putAll((Map<K, V>) parent);
merged.putAll(this);
return merged;
}

View File

@@ -101,7 +101,7 @@ public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMe
throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]");
}
Set<E> merged = new ManagedSet<E>();
merged.addAll((Set) parent);
merged.addAll((Set<E>) parent);
merged.addAll(this);
return merged;
}

View File

@@ -290,9 +290,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
public int registerBeanDefinitions(ResourceBundle rb, String prefix) throws BeanDefinitionStoreException {
// Simply create a map and call overloaded method.
Map<String, Object> map = new HashMap<String, Object>();
Enumeration keys = rb.getKeys();
Enumeration<String> keys = rb.getKeys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String key = keys.nextElement();
map.put(key, rb.getObject(key));
}
return registerBeanDefinitions(map, prefix);
@@ -309,7 +309,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
* @throws BeansException in case of loading or parsing errors
* @see #registerBeanDefinitions(java.util.Map, String, String)
*/
public int registerBeanDefinitions(Map map) throws BeansException {
public int registerBeanDefinitions(Map<?, ?> map) throws BeansException {
return registerBeanDefinitions(map, null);
}
@@ -324,7 +324,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
* @return the number of bean definitions found
* @throws BeansException in case of loading or parsing errors
*/
public int registerBeanDefinitions(Map map, String prefix) throws BeansException {
public int registerBeanDefinitions(Map<?, ?> map, String prefix) throws BeansException {
return registerBeanDefinitions(map, prefix, "Map " + map);
}
@@ -342,7 +342,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
* @throws BeansException in case of loading or parsing errors
* @see #registerBeanDefinitions(Map, String)
*/
public int registerBeanDefinitions(Map map, String prefix, String resourceDescription)
public int registerBeanDefinitions(Map<?, ?> map, String prefix, String resourceDescription)
throws BeansException {
if (prefix == null) {
@@ -413,7 +413,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
ConstructorArgumentValues cas = new ConstructorArgumentValues();
MutablePropertyValues pvs = new MutablePropertyValues();
for (Map.Entry entry : map.entrySet()) {
for (Map.Entry<?, ?> entry : map.entrySet()) {
String key = StringUtils.trimWhitespace((String) entry.getKey());
if (key.startsWith(prefix + SEPARATOR)) {
String property = key.substring(prefix.length() + SEPARATOR.length());
@@ -502,7 +502,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
* Reads the value of the entry. Correctly interprets bean references for
* values that are prefixed with an asterisk.
*/
private Object readValue(Map.Entry entry) {
private Object readValue(Map.Entry<? ,?> entry) {
Object val = entry.getValue();
if (val instanceof String) {
String strVal = (String) val;

View File

@@ -63,15 +63,15 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
synchronized (beanDefinition.constructorArgumentLock) {
constructorToUse = (Constructor<?>) beanDefinition.resolvedConstructorOrFactoryMethod;
if (constructorToUse == null) {
final Class clazz = beanDefinition.getBeanClass();
final Class<?> clazz = beanDefinition.getBeanClass();
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, "Specified class is an interface");
}
try {
if (System.getSecurityManager() != null) {
constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor>() {
constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() {
@Override
public Constructor run() throws Exception {
public Constructor<?> run() throws Exception {
return clazz.getDeclaredConstructor((Class[]) null);
}
});
@@ -136,7 +136,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
* Instantiation should use the given constructor and parameters.
*/
protected Object instantiateWithMethodInjection(RootBeanDefinition beanDefinition,
String beanName, BeanFactory owner, Constructor ctor, Object[] args) {
String beanName, BeanFactory owner, Constructor<?> ctor, Object[] args) {
throw new UnsupportedOperationException(
"Method Injection not supported in SimpleInstantiationStrategy");

View File

@@ -94,7 +94,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
try {
return ((FactoryBean) bean).getObject();
return ((FactoryBean<?>) bean).getObject();
}
catch (Exception ex) {
throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex);
@@ -147,20 +147,20 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
Object bean = getBean(name);
// In case of FactoryBean, return singleton status of created object.
return (bean instanceof FactoryBean && ((FactoryBean) bean).isSingleton());
return (bean instanceof FactoryBean && ((FactoryBean<?>) bean).isSingleton());
}
@Override
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
Object bean = getBean(name);
// In case of FactoryBean, return prototype status of created object.
return ((bean instanceof SmartFactoryBean && ((SmartFactoryBean) bean).isPrototype()) ||
(bean instanceof FactoryBean && !((FactoryBean) bean).isSingleton()));
return ((bean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) bean).isPrototype()) ||
(bean instanceof FactoryBean && !((FactoryBean<?>) bean).isSingleton()));
}
@Override
public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
Class type = getType(name);
public boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException {
Class<?> type = getType(name);
return (targetType == null || (type != null && targetType.isAssignableFrom(type)));
}
@@ -176,7 +176,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
// If it's a FactoryBean, we want to look at what it creates, not the factory class.
return ((FactoryBean) bean).getObjectType();
return ((FactoryBean<?>) bean).getObjectType();
}
return bean.getClass();
}
@@ -207,19 +207,19 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
}
@Override
public String[] getBeanNamesForType(Class type) {
public String[] getBeanNamesForType(Class<?> type) {
return getBeanNamesForType(type, true, true);
}
@Override
public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean includeFactoryBeans) {
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean includeFactoryBeans) {
boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type));
List<String> matches = new ArrayList<String>();
for (String name : this.beans.keySet()) {
Object beanInstance = this.beans.get(name);
if (beanInstance instanceof FactoryBean && !isFactoryType) {
if (includeFactoryBeans) {
Class objectType = ((FactoryBean) beanInstance).getObjectType();
Class<?> objectType = ((FactoryBean<?>) beanInstance).getObjectType();
if (objectType != null && (type == null || type.isAssignableFrom(objectType))) {
matches.add(name);
}
@@ -254,8 +254,8 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
if (beanInstance instanceof FactoryBean && !isFactoryType) {
if (includeFactoryBeans) {
// Match object created by FactoryBean.
FactoryBean factory = (FactoryBean) beanInstance;
Class objectType = factory.getObjectType();
FactoryBean<?> factory = (FactoryBean<?>) beanInstance;
Class<?> objectType = factory.getObjectType();
if ((includeNonSingletons || factory.isSingleton()) &&
objectType != null && (type == null || type.isAssignableFrom(objectType))) {
matches.put(beanName, getBean(beanName, type));

View File

@@ -519,7 +519,7 @@ public class BeanDefinitionParserDelegate {
foundName = beanName;
}
if (foundName == null) {
foundName = (String) CollectionUtils.findFirstMatch(this.usedNames, aliases);
foundName = CollectionUtils.findFirstMatch(this.usedNames, aliases);
}
if (foundName != null) {
error("Bean name '" + foundName + "' is already used in this <beans> element", beanElement);
@@ -1181,7 +1181,7 @@ public class BeanDefinitionParserDelegate {
/**
* Parse a list element.
*/
public List parseListElement(Element collectionEle, BeanDefinition bd) {
public List<Object> parseListElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedList<Object> target = new ManagedList<Object>(nl.getLength());
@@ -1195,7 +1195,7 @@ public class BeanDefinitionParserDelegate {
/**
* Parse a set element.
*/
public Set parseSetElement(Element collectionEle, BeanDefinition bd) {
public Set<Object> parseSetElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedSet<Object> target = new ManagedSet<Object>(nl.getLength());
@@ -1220,7 +1220,7 @@ public class BeanDefinitionParserDelegate {
/**
* Parse a map element.
*/
public Map parseMapElement(Element mapEle, BeanDefinition bd) {
public Map<Object, Object> parseMapElement(Element mapEle, BeanDefinition bd) {
String defaultKeyType = mapEle.getAttribute(KEY_TYPE_ATTRIBUTE);
String defaultValueType = mapEle.getAttribute(VALUE_TYPE_ATTRIBUTE);

View File

@@ -75,7 +75,7 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
if (source == null && systemId != null) {
String resourcePath = null;
try {
String decodedSystemId = URLDecoder.decode(systemId);
String decodedSystemId = URLDecoder.decode(systemId, "UTF-8");
String givenUrl = new URL(decodedSystemId).toString();
String systemRootUrl = new File("").toURI().toURL().toString();
// Try relative to resource base if currently in system root.

View File

@@ -59,7 +59,7 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport {
private static class ConstantBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected Class getBeanClass(Element element) {
protected Class<?> getBeanClass(Element element) {
return FieldRetrievingFactoryBean.class;
}
@@ -77,7 +77,7 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport {
private static class PropertyPathBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected Class getBeanClass(Element element) {
protected Class<?> getBeanClass(Element element) {
return PropertyPathFactoryBean.class;
}
@@ -114,14 +114,14 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport {
private static class ListBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected Class getBeanClass(Element element) {
protected Class<?> getBeanClass(Element element) {
return ListFactoryBean.class;
}
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
String listClass = element.getAttribute("list-class");
List parsedList = parserContext.getDelegate().parseListElement(element, builder.getRawBeanDefinition());
List<Object> parsedList = parserContext.getDelegate().parseListElement(element, builder.getRawBeanDefinition());
builder.addPropertyValue("sourceList", parsedList);
if (StringUtils.hasText(listClass)) {
builder.addPropertyValue("targetListClass", listClass);
@@ -137,14 +137,14 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport {
private static class SetBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected Class getBeanClass(Element element) {
protected Class<?> getBeanClass(Element element) {
return SetFactoryBean.class;
}
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
String setClass = element.getAttribute("set-class");
Set parsedSet = parserContext.getDelegate().parseSetElement(element, builder.getRawBeanDefinition());
Set<Object> parsedSet = parserContext.getDelegate().parseSetElement(element, builder.getRawBeanDefinition());
builder.addPropertyValue("sourceSet", parsedSet);
if (StringUtils.hasText(setClass)) {
builder.addPropertyValue("targetSetClass", setClass);
@@ -160,14 +160,14 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport {
private static class MapBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected Class getBeanClass(Element element) {
protected Class<?> getBeanClass(Element element) {
return MapFactoryBean.class;
}
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
String mapClass = element.getAttribute("map-class");
Map parsedMap = parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition());
Map<Object, Object> parsedMap = parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition());
builder.addPropertyValue("sourceMap", parsedMap);
if (StringUtils.hasText(mapClass)) {
builder.addPropertyValue("targetMapClass", mapClass);
@@ -183,7 +183,7 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport {
private static class PropertiesBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected Class getBeanClass(Element element) {
protected Class<?> getBeanClass(Element element) {
return PropertiesFactoryBean.class;
}

View File

@@ -62,7 +62,7 @@ public class ClassArrayEditor extends PropertyEditorSupport {
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
String[] classNames = StringUtils.commaDelimitedListToStringArray(text);
Class[] classes = new Class[classNames.length];
Class<?>[] classes = new Class<?>[classNames.length];
for (int i = 0; i < classNames.length; i++) {
String className = classNames[i].trim();
classes[i] = ClassUtils.resolveClassName(className, this.classLoader);
@@ -76,7 +76,7 @@ public class ClassArrayEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
Class[] classes = (Class[]) getValue();
Class<?>[] classes = (Class[]) getValue();
if (ObjectUtils.isEmpty(classes)) {
return "";
}

View File

@@ -69,7 +69,7 @@ public class ClassEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
Class clazz = (Class) getValue();
Class<?> clazz = (Class<?>) getValue();
if (clazz != null) {
return ClassUtils.getQualifiedName(clazz);
}

View File

@@ -42,7 +42,8 @@ import java.util.TreeSet;
*/
public class CustomCollectionEditor extends PropertyEditorSupport {
private final Class collectionType;
@SuppressWarnings("rawtypes")
private final Class<? extends Collection> collectionType;
private final boolean nullAsEmptyCollection;
@@ -57,7 +58,8 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
* @see java.util.TreeSet
* @see java.util.LinkedHashSet
*/
public CustomCollectionEditor(Class collectionType) {
@SuppressWarnings("rawtypes")
public CustomCollectionEditor(Class<? extends Collection> collectionType) {
this(collectionType, false);
}
@@ -79,7 +81,8 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
* @see java.util.TreeSet
* @see java.util.LinkedHashSet
*/
public CustomCollectionEditor(Class collectionType, boolean nullAsEmptyCollection) {
@SuppressWarnings("rawtypes")
public CustomCollectionEditor(Class<? extends Collection> collectionType, boolean nullAsEmptyCollection) {
if (collectionType == null) {
throw new IllegalArgumentException("Collection type is required");
}
@@ -104,7 +107,6 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
* Convert the given value to a Collection of the target type.
*/
@Override
@SuppressWarnings("unchecked")
public void setValue(Object value) {
if (value == null && this.nullAsEmptyCollection) {
super.setValue(createCollection(this.collectionType, 0));
@@ -115,8 +117,8 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
}
else if (value instanceof Collection) {
// Convert Collection elements.
Collection source = (Collection) value;
Collection target = createCollection(this.collectionType, source.size());
Collection<?> source = (Collection<?>) value;
Collection<Object> target = createCollection(this.collectionType, source.size());
for (Object elem : source) {
target.add(convertElement(elem));
}
@@ -125,7 +127,7 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
else if (value.getClass().isArray()) {
// Convert array elements to Collection elements.
int length = Array.getLength(value);
Collection target = createCollection(this.collectionType, length);
Collection<Object> target = createCollection(this.collectionType, length);
for (int i = 0; i < length; i++) {
target.add(convertElement(Array.get(value, i)));
}
@@ -133,7 +135,7 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
}
else {
// A plain value: convert it to a Collection with a single element.
Collection target = createCollection(this.collectionType, 1);
Collection<Object> target = createCollection(this.collectionType, 1);
target.add(convertElement(value));
super.setValue(target);
}
@@ -146,10 +148,11 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
* @param initialCapacity the initial capacity
* @return the new Collection instance
*/
protected Collection createCollection(Class collectionType, int initialCapacity) {
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Collection<Object> createCollection(Class<? extends Collection> collectionType, int initialCapacity) {
if (!collectionType.isInterface()) {
try {
return (Collection) collectionType.newInstance();
return collectionType.newInstance();
}
catch (Exception ex) {
throw new IllegalArgumentException(
@@ -157,13 +160,13 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
}
}
else if (List.class.equals(collectionType)) {
return new ArrayList(initialCapacity);
return new ArrayList<Object>(initialCapacity);
}
else if (SortedSet.class.equals(collectionType)) {
return new TreeSet();
return new TreeSet<Object>();
}
else {
return new LinkedHashSet(initialCapacity);
return new LinkedHashSet<Object>(initialCapacity);
}
}

View File

@@ -33,7 +33,8 @@ import java.util.TreeMap;
*/
public class CustomMapEditor extends PropertyEditorSupport {
private final Class mapType;
@SuppressWarnings("rawtypes")
private final Class<? extends Map> mapType;
private final boolean nullAsEmptyMap;
@@ -48,7 +49,8 @@ public class CustomMapEditor extends PropertyEditorSupport {
* @see java.util.TreeMap
* @see java.util.LinkedHashMap
*/
public CustomMapEditor(Class mapType) {
@SuppressWarnings("rawtypes")
public CustomMapEditor(Class<? extends Map> mapType) {
this(mapType, false);
}
@@ -69,7 +71,8 @@ public class CustomMapEditor extends PropertyEditorSupport {
* @see java.util.TreeMap
* @see java.util.LinkedHashMap
*/
public CustomMapEditor(Class mapType, boolean nullAsEmptyMap) {
@SuppressWarnings("rawtypes")
public CustomMapEditor(Class<? extends Map> mapType, boolean nullAsEmptyMap) {
if (mapType == null) {
throw new IllegalArgumentException("Map type is required");
}
@@ -104,9 +107,9 @@ public class CustomMapEditor extends PropertyEditorSupport {
}
else if (value instanceof Map) {
// Convert Map elements.
Map<?, ?> source = (Map) value;
Map target = createMap(this.mapType, source.size());
for (Map.Entry entry : source.entrySet()) {
Map<?, ?> source = (Map<?, ?>) value;
Map<Object, Object> target = createMap(this.mapType, source.size());
for (Map.Entry<?, ?> entry : source.entrySet()) {
target.put(convertKey(entry.getKey()), convertValue(entry.getValue()));
}
super.setValue(target);
@@ -123,10 +126,11 @@ public class CustomMapEditor extends PropertyEditorSupport {
* @param initialCapacity the initial capacity
* @return the new Map instance
*/
protected Map createMap(Class mapType, int initialCapacity) {
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Map<Object, Object> createMap(Class<? extends Map> mapType, int initialCapacity) {
if (!mapType.isInterface()) {
try {
return (Map) mapType.newInstance();
return mapType.newInstance();
}
catch (Exception ex) {
throw new IllegalArgumentException(
@@ -134,10 +138,10 @@ public class CustomMapEditor extends PropertyEditorSupport {
}
}
else if (SortedMap.class.equals(mapType)) {
return new TreeMap();
return new TreeMap<Object, Object>();
}
else {
return new LinkedHashMap(initialCapacity);
return new LinkedHashMap<Object, Object>(initialCapacity);
}
}

View File

@@ -67,7 +67,7 @@ public class PropertiesEditor extends PropertyEditorSupport {
public void setValue(Object value) {
if (!(value instanceof Properties) && value instanceof Map) {
Properties props = new Properties();
props.putAll((Map) value);
props.putAll((Map<?, ?>) value);
super.setValue(props);
}
else {

View File

@@ -92,7 +92,7 @@ public class ArgumentConvertingMethodInvoker extends MethodInvoker {
* @see #setTypeConverter
* @see org.springframework.beans.PropertyEditorRegistry#registerCustomEditor
*/
public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) {
public void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor) {
TypeConverter converter = getTypeConverter();
if (!(converter instanceof PropertyEditorRegistry)) {
throw new IllegalStateException(
@@ -139,7 +139,7 @@ public class ArgumentConvertingMethodInvoker extends MethodInvoker {
for (Method candidate : candidates) {
if (candidate.getName().equals(targetMethod)) {
// Check if the inspected method has the correct number of parameters.
Class[] paramTypes = candidate.getParameterTypes();
Class<?>[] paramTypes = candidate.getParameterTypes();
if (paramTypes.length == argCount) {
Object[] convertedArguments = new Object[argCount];
boolean match = true;

View File

@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
import org.springframework.util.StringUtils;
@@ -37,7 +36,7 @@ import org.springframework.util.StringUtils;
* @since 19.05.2003
* @see org.springframework.beans.BeanWrapper
*/
public class PropertyComparator implements Comparator {
public class PropertyComparator<T> implements Comparator<T> {
protected final Log logger = LogFactory.getLog(getClass());
@@ -73,7 +72,8 @@ public class PropertyComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
@SuppressWarnings("unchecked")
public int compare(T o1, T o2) {
Object v1 = getPropertyValue(o1);
Object v2 = getPropertyValue(o2);
if (this.sortDefinition.isIgnoreCase() && (v1 instanceof String) && (v2 instanceof String)) {
@@ -86,7 +86,7 @@ public class PropertyComparator implements Comparator {
// Put an object with null property at the end of the sort result.
try {
if (v1 != null) {
result = (v2 != null ? ((Comparable) v1).compareTo(v2) : -1);
result = (v2 != null ? ((Comparable<Object>) v1).compareTo(v2) : -1);
}
else {
result = (v2 != null ? 1 : 0);
@@ -130,9 +130,9 @@ public class PropertyComparator implements Comparator {
* @param sortDefinition the parameters to sort by
* @throws java.lang.IllegalArgumentException in case of a missing propertyName
*/
public static void sort(List source, SortDefinition sortDefinition) throws BeansException {
public static void sort(List<?> source, SortDefinition sortDefinition) throws BeansException {
if (StringUtils.hasText(sortDefinition.getProperty())) {
Collections.sort(source, new PropertyComparator(sortDefinition));
Collections.sort(source, new PropertyComparator<Object>(sortDefinition));
}
}
@@ -146,7 +146,7 @@ public class PropertyComparator implements Comparator {
*/
public static void sort(Object[] source, SortDefinition sortDefinition) throws BeansException {
if (StringUtils.hasText(sortDefinition.getProperty())) {
Arrays.sort(source, new PropertyComparator(sortDefinition));
Arrays.sort(source, new PropertyComparator<Object>(sortDefinition));
}
}