1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.codehaus.plexus.metadata.ann;
18
19 import java.lang.reflect.Proxy;
20 import java.util.LinkedHashMap;
21 import java.util.Map;
22
23 import org.objectweb.asm.Type;
24
25
26
27
28 public class Ann {
29
30 private String desc;
31 private Map<String, Object> params = new LinkedHashMap<String, Object>();
32
33 public Ann(String desc) {
34 this.desc = desc;
35 }
36
37 public void addParam(String name, Object value) {
38 params.put(name, value);
39 }
40
41 public String getDesc() {
42 return desc;
43 }
44
45 public String getType() {
46 return Type.getType(desc).getClassName();
47 }
48
49 public Map<String, Object> getParams() {
50 return params;
51 }
52
53 @SuppressWarnings("unchecked")
54 public <T> T getAnnotation(Class<T> c, ClassLoader cl) {
55 return (T) Proxy.newProxyInstance(
56 Ann.class.getClassLoader(),
57 new Class[] {c},
58 new AnnInvocationHandler(this, cl, c));
59 }
60 }