aboutsummaryrefslogtreecommitdiff
path: root/src/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-27 03:10:04 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-27 03:10:04 +0200
commit157bbba3acd78aaff2ba0946ddb60a981186c7db (patch)
tree50c98bdaf274e084da7fda2198cdaac92f9beb9e /src/lombok
parent47bd3e3c06379d8c52f572cf466e6388b0b91ce1 (diff)
downloadlombok-157bbba3acd78aaff2ba0946ddb60a981186c7db.tar.gz
lombok-157bbba3acd78aaff2ba0946ddb60a981186c7db.tar.bz2
lombok-157bbba3acd78aaff2ba0946ddb60a981186c7db.zip
Added a caching mechanism to AnnotationValues, for instantiating the annotation.
Diffstat (limited to 'src/lombok')
-rw-r--r--src/lombok/core/AnnotationValues.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lombok/core/AnnotationValues.java b/src/lombok/core/AnnotationValues.java
index 8c69ffc4..515079e6 100644
--- a/src/lombok/core/AnnotationValues.java
+++ b/src/lombok/core/AnnotationValues.java
@@ -77,8 +77,11 @@ public class AnnotationValues<A extends Annotation> {
"No value supplied but " + method.getName() + " has no default either.", -1);
}
+ private A cachedInstance = null;
+
@SuppressWarnings("unchecked")
public A getInstance() throws AnnotationValueDecodeFail {
+ if ( cachedInstance != null ) return cachedInstance;
InvocationHandler invocations = new InvocationHandler() {
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
AnnotationValue v = values.get(method.getName());
@@ -134,7 +137,7 @@ public class AnnotationValues<A extends Annotation> {
}
};
- return (A) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, invocations);
+ return cachedInstance = (A) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, invocations);
}
private Object guessToType(Object guess, Class<?> expected, AnnotationValue v, int pos) {