You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/10/27 21:30:33 UTC
svn commit: r1536193 - in /commons/proper/beanutils/branches/java5/src:
main/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java
Author: oheger
Date: Sun Oct 27 20:30:33 2013
New Revision: 1536193
URL: http://svn.apache.org/r1536193
Log:
Fixed warnings, mainly related to raw types.
Modified:
commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java
Modified: commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java?rev=1536193&r1=1536192&r2=1536193&view=diff
==============================================================================
--- commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java (original)
+++ commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java Sun Oct 27 20:30:33 2013
@@ -50,7 +50,7 @@ public class MappedPropertyDescriptor ex
/**
* The underlying data type of the property we are describing.
*/
- private Reference mappedPropertyTypeRef;
+ private Reference<Class<?>> mappedPropertyTypeRef;
/**
* The reader method for this property (if any).
@@ -65,7 +65,7 @@ public class MappedPropertyDescriptor ex
/**
* The parameter types array for the reader method signature.
*/
- private static final Class[] STRING_CLASS_PARAMETER = new Class[]{String.class};
+ private static final Class<?>[] STRING_CLASS_PARAMETER = new Class[]{String.class};
// ----------------------------------------------------------- Constructors
@@ -85,7 +85,7 @@ public class MappedPropertyDescriptor ex
* @exception IntrospectionException if an exception occurs during
* introspection.
*/
- public MappedPropertyDescriptor(String propertyName, Class beanClass)
+ public MappedPropertyDescriptor(String propertyName, Class<?> beanClass)
throws IntrospectionException {
super(propertyName, null, null);
@@ -109,7 +109,7 @@ public class MappedPropertyDescriptor ex
mappedReadMethod = getMethod(beanClass, "is" + base,
STRING_CLASS_PARAMETER);
}
- Class[] params = { String.class, mappedReadMethod.getReturnType() };
+ Class<?>[] params = { String.class, mappedReadMethod.getReturnType() };
mappedWriteMethod = getMethod(beanClass, "set" + base, params);
} catch (IntrospectionException e) {
/* Swallow IntrospectionException
@@ -151,7 +151,7 @@ public class MappedPropertyDescriptor ex
* @exception IntrospectionException if an exception occurs during
* introspection.
*/
- public MappedPropertyDescriptor(String propertyName, Class beanClass,
+ public MappedPropertyDescriptor(String propertyName, Class<?> beanClass,
String mappedGetterName, String mappedSetterName)
throws IntrospectionException {
@@ -170,7 +170,7 @@ public class MappedPropertyDescriptor ex
getMethod(beanClass, mappedGetterName, STRING_CLASS_PARAMETER);
if (mappedReadMethod != null) {
- Class[] params = { String.class, mappedReadMethod.getReturnType() };
+ Class<?>[] params = { String.class, mappedReadMethod.getReturnType() };
mappedWriteMethod =
getMethod(beanClass, mappedSetterName, params);
} else {
@@ -226,8 +226,8 @@ public class MappedPropertyDescriptor ex
* <p>
* This is the type that will be returned by the mappedReadMethod.
*/
- public Class getMappedPropertyType() {
- return (Class)mappedPropertyTypeRef.get();
+ public Class<?> getMappedPropertyType() {
+ return mappedPropertyTypeRef.get();
}
/**
@@ -286,7 +286,7 @@ public class MappedPropertyDescriptor ex
try {
Method mappedReadMethod = getMappedReadMethod();
Method mappedWriteMethod = getMappedWriteMethod();
- Class mappedPropertyType = null;
+ Class<?> mappedPropertyType = null;
if (mappedReadMethod != null) {
if (mappedReadMethod.getParameterTypes().length != 1) {
throw new IntrospectionException
@@ -301,7 +301,7 @@ public class MappedPropertyDescriptor ex
}
if (mappedWriteMethod != null) {
- Class[] params = mappedWriteMethod.getParameterTypes();
+ Class<?>[] params = mappedWriteMethod.getParameterTypes();
if (params.length != 2) {
throw new IntrospectionException
("bad mapped write method arg count");
@@ -313,7 +313,7 @@ public class MappedPropertyDescriptor ex
}
mappedPropertyType = params[1];
}
- mappedPropertyTypeRef = new SoftReference(mappedPropertyType);
+ mappedPropertyTypeRef = new SoftReference<Class<?>>(mappedPropertyType);
} catch (IntrospectionException ex) {
throw ex;
}
@@ -338,11 +338,11 @@ public class MappedPropertyDescriptor ex
/**
* Find a method on a class with a specified number of parameters.
*/
- private static Method internalGetMethod(Class initial, String methodName,
+ private static Method internalGetMethod(Class<?> initial, String methodName,
int parameterCount) {
// For overridden methods we need to find the most derived version.
// So we start with the given class and walk up the superclass chain.
- for (Class clazz = initial; clazz != null; clazz = clazz.getSuperclass()) {
+ for (Class<?> clazz = initial; clazz != null; clazz = clazz.getSuperclass()) {
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
@@ -365,7 +365,7 @@ public class MappedPropertyDescriptor ex
// Now check any inherited interfaces. This is necessary both when
// the argument class is itself an interface, and when the argument
// class is an abstract class.
- Class[] interfaces = initial.getInterfaces();
+ Class<?>[] interfaces = initial.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
Method method = internalGetMethod(interfaces[i], methodName, parameterCount);
if (method != null) {
@@ -379,7 +379,7 @@ public class MappedPropertyDescriptor ex
/**
* Find a method on a class with a specified number of parameters.
*/
- private static Method getMethod(Class clazz, String methodName, int parameterCount)
+ private static Method getMethod(Class<?> clazz, String methodName, int parameterCount)
throws IntrospectionException {
if (methodName == null) {
return null;
@@ -398,7 +398,7 @@ public class MappedPropertyDescriptor ex
/**
* Find a method on a class with a specified parameter list.
*/
- private static Method getMethod(Class clazz, String methodName, Class[] parameterTypes)
+ private static Method getMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes)
throws IntrospectionException {
if (methodName == null) {
return null;
@@ -427,21 +427,21 @@ public class MappedPropertyDescriptor ex
private static class MappedMethodReference {
private String className;
private String methodName;
- private Reference methodRef;
- private Reference classRef;
- private Reference writeParamTypeRef0;
- private Reference writeParamTypeRef1;
+ private Reference<Method> methodRef;
+ private Reference<Class<?>> classRef;
+ private Reference<Class<?>> writeParamTypeRef0;
+ private Reference<Class<?>> writeParamTypeRef1;
private String[] writeParamClassNames;
MappedMethodReference(Method m) {
if (m != null) {
className = m.getDeclaringClass().getName();
methodName = m.getName();
- methodRef = new SoftReference(m);
- classRef = new WeakReference(m.getDeclaringClass());
- Class[] types = m.getParameterTypes();
+ methodRef = new SoftReference<Method>(m);
+ classRef = new WeakReference<Class<?>>(m.getDeclaringClass());
+ Class<?>[] types = m.getParameterTypes();
if (types.length == 2) {
- writeParamTypeRef0 = new WeakReference(types[0]);
- writeParamTypeRef1 = new WeakReference(types[1]);
+ writeParamTypeRef0 = new WeakReference<Class<?>>(types[0]);
+ writeParamTypeRef1 = new WeakReference<Class<?>>(types[1]);
writeParamClassNames = new String[2];
writeParamClassNames[0] = types[0].getName();
writeParamClassNames[1] = types[1].getName();
@@ -452,34 +452,34 @@ public class MappedPropertyDescriptor ex
if (methodRef == null) {
return null;
}
- Method m = (Method)methodRef.get();
+ Method m = methodRef.get();
if (m == null) {
- Class clazz = (Class)classRef.get();
+ Class<?> clazz = classRef.get();
if (clazz == null) {
clazz = reLoadClass();
if (clazz != null) {
- classRef = new WeakReference(clazz);
+ classRef = new WeakReference<Class<?>>(clazz);
}
}
if (clazz == null) {
throw new RuntimeException("Method " + methodName + " for " +
className + " could not be reconstructed - class reference has gone");
}
- Class[] paramTypes = null;
+ Class<?>[] paramTypes = null;
if (writeParamClassNames != null) {
paramTypes = new Class[2];
- paramTypes[0] = (Class)writeParamTypeRef0.get();
+ paramTypes[0] = writeParamTypeRef0.get();
if (paramTypes[0] == null) {
paramTypes[0] = reLoadClass(writeParamClassNames[0]);
if (paramTypes[0] != null) {
- writeParamTypeRef0 = new WeakReference(paramTypes[0]);
+ writeParamTypeRef0 = new WeakReference<Class<?>>(paramTypes[0]);
}
}
- paramTypes[1] = (Class)writeParamTypeRef1.get();
+ paramTypes[1] = writeParamTypeRef1.get();
if (paramTypes[1] == null) {
paramTypes[1] = reLoadClass(writeParamClassNames[1]);
if (paramTypes[1] != null) {
- writeParamTypeRef1 = new WeakReference(paramTypes[1]);
+ writeParamTypeRef1 = new WeakReference<Class<?>>(paramTypes[1]);
}
}
} else {
@@ -493,7 +493,7 @@ public class MappedPropertyDescriptor ex
throw new RuntimeException("Method " + methodName + " for " +
className + " could not be reconstructed - method not found");
}
- methodRef = new SoftReference(m);
+ methodRef = new SoftReference<Method>(m);
}
return m;
}
@@ -501,14 +501,14 @@ public class MappedPropertyDescriptor ex
/**
* Try to re-load the class
*/
- private Class reLoadClass() {
+ private Class<?> reLoadClass() {
return reLoadClass(className);
}
/**
* Try to re-load the class
*/
- private Class reLoadClass(String name) {
+ private Class<?> reLoadClass(String name) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Modified: commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java?rev=1536193&r1=1536192&r2=1536193&view=diff
==============================================================================
--- commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java (original)
+++ commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/MappedPropertyTestCase.java Sun Oct 27 20:30:33 2013
@@ -16,11 +16,9 @@
*/
package org.apache.commons.beanutils;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* <p>Test Case for the <code>MappedPropertyDescriptor</code>.</p>
@@ -29,9 +27,6 @@ import org.apache.commons.logging.LogFac
*/
public class MappedPropertyTestCase extends TestCase {
- private static final Log log = LogFactory.getLog(MappedPropertyTestCase.class);
-
-
// ---------------------------------------------------------- Constructors
/**
@@ -80,7 +75,7 @@ public class MappedPropertyTestCase exte
*/
public void testFound() {
String property = "mapproperty";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -96,7 +91,7 @@ public class MappedPropertyTestCase exte
*/
public void testBooleanMapped() {
String property = "mappedBoolean";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -112,10 +107,9 @@ public class MappedPropertyTestCase exte
*/
public void testNotFound() {
String property = "xxxxxxx";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
// expected result
@@ -127,7 +121,7 @@ public class MappedPropertyTestCase exte
*/
public void testMappedGetterOnly() {
String property = "mappedGetterOnly";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -143,7 +137,7 @@ public class MappedPropertyTestCase exte
*/
public void testMappedSetterOnly() {
String property = "mappedSetterOnly";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -159,7 +153,7 @@ public class MappedPropertyTestCase exte
*/
public void testInvalidSetter() {
String property = "invalidSetter";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -175,7 +169,7 @@ public class MappedPropertyTestCase exte
*/
public void testInvalidGetter() {
String property = "invalidGetter";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -195,7 +189,7 @@ public class MappedPropertyTestCase exte
*/
public void testDifferentTypes() {
String property = "differentTypes";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -207,12 +201,10 @@ public class MappedPropertyTestCase exte
}
/**
- * Test Mpa getter
+ * Test Map getter
*/
public void testMapGetter() {
MappedPropertyTestBean bean = new MappedPropertyTestBean();
- Class clazz = MappedPropertyTestBean.class;
- String property = "myMap";
try {
String testValue = "test value";
String testKey = "testKey";
@@ -229,7 +221,7 @@ public class MappedPropertyTestCase exte
*/
public void testAnyArgsProperty() {
String property = "anyMapped";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -241,11 +233,11 @@ public class MappedPropertyTestCase exte
}
/**
- * Test property with two primitve args
+ * Test property with two primitive args
*/
public void testPrimitiveArgsProperty() {
String property = "mappedPrimitive";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -261,10 +253,9 @@ public class MappedPropertyTestCase exte
*/
public void testProtected() {
String property = "protectedProperty";
- Class clazz = MappedPropertyTestBean.class;
+ Class<?> clazz = MappedPropertyTestBean.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
// expected result
@@ -277,7 +268,7 @@ public class MappedPropertyTestCase exte
*/
public void testPublicParentMethod() {
String property = "mapproperty";
- Class clazz = MappedPropertyChildBean.class;
+ Class<?> clazz = MappedPropertyChildBean.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -293,10 +284,9 @@ public class MappedPropertyTestCase exte
*/
public void testProtectedParentMethod() {
String property = "protectedMapped";
- Class clazz = MappedPropertyChildBean.class;
+ Class<?> clazz = MappedPropertyChildBean.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
}
@@ -308,7 +298,7 @@ public class MappedPropertyTestCase exte
*/
public void testInterfaceMapped() {
String property = "mapproperty";
- Class clazz = MappedPropertyTestInterface.class;
+ Class<?> clazz = MappedPropertyTestInterface.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);
@@ -324,10 +314,9 @@ public class MappedPropertyTestCase exte
*/
public void testInterfaceNotFound() {
String property = "XXXXXX";
- Class clazz = MappedPropertyTestInterface.class;
+ Class<?> clazz = MappedPropertyTestInterface.class;
try {
- MappedPropertyDescriptor desc
- = new MappedPropertyDescriptor(property, clazz);
+ new MappedPropertyDescriptor(property, clazz);
fail("Property '" + property + "' found in " + clazz.getName());
} catch (Exception ex) {
}
@@ -338,7 +327,7 @@ public class MappedPropertyTestCase exte
*/
public void testChildInterfaceMapped() {
String property = "mapproperty";
- Class clazz = MappedPropertyChildInterface.class;
+ Class<?> clazz = MappedPropertyChildInterface.class;
try {
MappedPropertyDescriptor desc
= new MappedPropertyDescriptor(property, clazz);