Polishing

This commit is contained in:
Juergen Hoeller 2013-12-11 23:56:39 +01:00
parent b085ec90b2
commit a3a43448d1
1 changed files with 6 additions and 13 deletions

View File

@ -57,7 +57,7 @@ public abstract class BeanUtils {
private static final Log logger = LogFactory.getLog(BeanUtils.class); private static final Log logger = LogFactory.getLog(BeanUtils.class);
// using WeakHashMap as a Set // Effectively using a WeakHashMap as a Set
private static final Map<Class<?>, Boolean> unknownEditorTypes = private static final Map<Class<?>, Boolean> unknownEditorTypes =
Collections.synchronizedMap(new WeakHashMap<Class<?>, Boolean>()); Collections.synchronizedMap(new WeakHashMap<Class<?>, Boolean>());
@ -127,7 +127,7 @@ public abstract class BeanUtils {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo) throws BeanInstantiationException { public static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo) throws BeanInstantiationException {
Assert.isAssignable(assignableTo, clazz); Assert.isAssignable(assignableTo, clazz);
return (T)instantiateClass(clazz); return (T) instantiateClass(clazz);
} }
/** /**
@ -281,7 +281,7 @@ public abstract class BeanUtils {
} }
else { else {
if (targetMethod.getParameterTypes().length == numParams) { if (targetMethod.getParameterTypes().length == numParams) {
// Additional candidate with same length. // Additional candidate with same length
numMethodsFoundWithCurrentMinimumArgs++; numMethodsFoundWithCurrentMinimumArgs++;
} }
} }
@ -317,10 +317,8 @@ public abstract class BeanUtils {
public static Method resolveSignature(String signature, Class<?> clazz) { public static Method resolveSignature(String signature, Class<?> clazz) {
Assert.hasText(signature, "'signature' must not be empty"); Assert.hasText(signature, "'signature' must not be empty");
Assert.notNull(clazz, "Class must not be null"); Assert.notNull(clazz, "Class must not be null");
int firstParen = signature.indexOf("("); int firstParen = signature.indexOf("(");
int lastParen = signature.indexOf(")"); int lastParen = signature.indexOf(")");
if (firstParen > -1 && lastParen == -1) { if (firstParen > -1 && lastParen == -1) {
throw new IllegalArgumentException("Invalid method signature '" + signature + throw new IllegalArgumentException("Invalid method signature '" + signature +
"': expected closing ')' for args list"); "': expected closing ')' for args list");
@ -475,8 +473,7 @@ public abstract class BeanUtils {
*/ */
public static MethodParameter getWriteMethodParameter(PropertyDescriptor pd) { public static MethodParameter getWriteMethodParameter(PropertyDescriptor pd) {
if (pd instanceof GenericTypeAwarePropertyDescriptor) { if (pd instanceof GenericTypeAwarePropertyDescriptor) {
return new MethodParameter( return new MethodParameter(((GenericTypeAwarePropertyDescriptor) pd).getWriteMethodParameter());
((GenericTypeAwarePropertyDescriptor) pd).getWriteMethodParameter());
} }
else { else {
return new MethodParameter(pd.getWriteMethod(), 0); return new MethodParameter(pd.getWriteMethod(), 0);
@ -545,9 +542,7 @@ public abstract class BeanUtils {
* @throws BeansException if the copying failed * @throws BeansException if the copying failed
* @see BeanWrapper * @see BeanWrapper
*/ */
public static void copyProperties(Object source, Object target, Class<?> editable) public static void copyProperties(Object source, Object target, Class<?> editable) throws BeansException {
throws BeansException {
copyProperties(source, target, editable, (String[]) null); copyProperties(source, target, editable, (String[]) null);
} }
@ -565,9 +560,7 @@ public abstract class BeanUtils {
* @throws BeansException if the copying failed * @throws BeansException if the copying failed
* @see BeanWrapper * @see BeanWrapper
*/ */
public static void copyProperties(Object source, Object target, String... ignoreProperties) public static void copyProperties(Object source, Object target, String... ignoreProperties) throws BeansException {
throws BeansException {
copyProperties(source, target, null, ignoreProperties); copyProperties(source, target, null, ignoreProperties);
} }