Skip to content

Commit

Permalink
cache getParameterTypes call
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Jan 27, 2014
1 parent 3c69f18 commit 07467ea
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public abstract class BaseApiProvider {

private static List<String> EXCLUDED_METHODS = Arrays.asList("setMetaClass", "getMetaClass");
private static List<String> EXCLUDED_METHODS = Arrays.asList("setMetaClass", "getMetaClass", "setProperties", "getProperties");

public static final String CONSTRUCTOR_METHOD = "initialize";
public static final String CTOR_GROOVY_METHOD = "<ctor>";
Expand Down Expand Up @@ -71,16 +71,22 @@ public void addApi(final Object apiInstance) {
}
else {
instanceMethods.add(new ReflectionMetaMethod(new CachedMethod(javaMethod)) {
{
CachedClass[] paramTypes = super.getParameterTypes();
if(paramTypes.length > 0) {
setParametersTypes((CachedClass[]) ArrayUtils.subarray(paramTypes, 1, paramTypes.length));
}
}

@Override
public String getName() {

String methodName = super.getName();
if (isConstructorCallMethod(javaMethod)) {
return CTOR_GROOVY_METHOD;
}
return methodName;
}

@Override
public Object invoke(Object object, Object[] arguments) {
if (arguments.length == 0) {
Expand All @@ -97,15 +103,6 @@ private Object[] checkForGStrings(Object[] arguments) {
}
return arguments;
}

@Override
public CachedClass[] getParameterTypes() {
final CachedClass[] paramTypes = method.getParameterTypes();
if (paramTypes.length > 0) {
return (CachedClass[]) ArrayUtils.subarray(paramTypes, 1, paramTypes.length);
}
return paramTypes;
}
});
}
}
Expand Down

0 comments on commit 07467ea

Please sign in to comment.