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.util.LinkedHashMap;
20 import java.util.Map;
21
22 import org.objectweb.asm.Type;
23
24
25
26
27 public class AnnField {
28
29 private final AnnClass owner;
30 private final int access;
31 private final String name;
32 private final String desc;
33 private Map<String, Ann> anns = new LinkedHashMap<String, Ann>();
34
35 public AnnField(AnnClass owner, int access, String name, String desc) {
36 this.owner = owner;
37 this.access = access;
38 this.desc = desc;
39 this.name = name;
40 }
41
42 public int getAccess() {
43 return access;
44 }
45
46 public String getName() {
47 return name;
48 }
49
50 public String getDesc() {
51 return desc;
52 }
53
54 public Map<String, Ann> getAnns() {
55 return anns;
56 }
57
58 public String getType() {
59 return Type.getType(desc).getClassName();
60 }
61
62 public void addAnn(Ann ann) {
63 anns.put(ann.getDesc(), ann);
64 }
65
66 public <T> T getAnnotation(Class<T> c) {
67 Ann ann = anns.get(Type.getDescriptor(c));
68 return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader());
69 }
70 }