1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.callbackparams.internal.template;
18
19 import java.lang.reflect.Field;
20 import java.lang.reflect.Method;
21 import org.callbackparams.support.ClassWrapper;
22 import org.callbackparams.support.JdkVersion;
23
24
25
26
27 public abstract class AnnotationSpecifiedCallbacks {
28
29 public static final class DummyJdk14Impl
30 extends AnnotationSpecifiedCallbacks {
31
32
33 public DummyJdk14Impl(Method m, int i) {}
34 public DummyJdk14Impl(Field f) {}
35
36
37
38
39
40 protected Object asCallback(Object callbackValue) { return null; }
41 }
42
43 private final static ClassWrapper implementationClass =
44 JdkVersion.supportsAnnotations() ? JdkVersion
45 .compatibleImplementationOf(AnnotationSpecifiedCallbacks.class)
46 : new ClassWrapper(DummyJdk14Impl.class);
47
48 static AnnotationSpecifiedCallbacks forCallbackRef(Method m, int paramIndex) {
49 return (AnnotationSpecifiedCallbacks) implementationClass
50 .newInstance(new Object[] {m, new Integer(paramIndex)});
51 }
52
53 static AnnotationSpecifiedCallbacks forCallbackRef(Field f) {
54 return (AnnotationSpecifiedCallbacks)
55 implementationClass.newInstance(f);
56 }
57
58 abstract protected Object asCallback(Object callbackValue);
59 }