corda/classpath/avian/AnnotationInvocationHandler.java
Johannes Schindelin ff323d46a3 AnnotationInvocationHandler: avoid calling Method#getName too often
This is only a cosmetic change, but we should not call getName()
over and over again ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-26 15:27:48 -06:00

33 lines
909 B
Java

/* Copyright (c) 2008-2013, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package avian;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationHandler;
public class AnnotationInvocationHandler implements InvocationHandler {
private Object[] data;
public AnnotationInvocationHandler(Object[] data) {
this.data = data;
}
public Object invoke(Object proxy, Method method, Object[] arguments) {
String name = method.getName();
for (int i = 2; i < data.length; i += 2) {
if (name.equals(data[i])) {
return data[i + 1];
}
}
throw new IllegalArgumentException();
}
}