DATACMNS-820 - Polishing.

Fixed indentation to use tabs instead of spaces. Tweaked structure of if-clauses in PropertyAccessingMethodInterceptor to reduce nesting. Made helper method static. 

Restructured test cases slightly and used ExpectedException rule to verify exceptions. Moved newly introduced test methods more to the end of the file (new tests last).

Added author and copyright year extensions where necessary.

Original pull request: #155.
This commit is contained in:
Oliver Gierke
2016-02-20 20:32:53 +01:00
parent e868577def
commit d3e6ad104c
4 changed files with 88 additions and 87 deletions

View File

@@ -67,20 +67,19 @@ class PropertyAccessingMethodInterceptor implements MethodInterceptor {
throw new IllegalStateException("Invoked method is not a property accessor!");
}
if (isSetterMethod(method, descriptor)) {
if (invocation.getArguments().length != 1) {
throw new IllegalStateException("Invoked setter method requires exactly one argument!");
}
if (!isSetterMethod(method, descriptor)) {
return target.getPropertyValue(descriptor.getName());
}
target.setPropertyValue(descriptor.getName(), invocation.getArguments()[0]);
return null;
}
if (invocation.getArguments().length != 1) {
throw new IllegalStateException("Invoked setter method requires exactly one argument!");
}
return target.getPropertyValue(descriptor.getName());
target.setPropertyValue(descriptor.getName(), invocation.getArguments()[0]);
return null;
}
private boolean isSetterMethod(Method method, PropertyDescriptor descriptor) {
private static boolean isSetterMethod(Method method, PropertyDescriptor descriptor) {
return method.equals(descriptor.getWriteMethod());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import org.springframework.util.ReflectionUtils;
*
* @author Oliver Gierke
* @author Thomas Darimont
* @author Mark Paluch
* @since 1.10
*/
public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory implements BeanFactoryAware {