1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
package org.apache.commons.classscan.bcel; |
15 | |
|
16 | |
import java.util.Set; |
17 | |
|
18 | |
import org.apache.bcel.classfile.ParameterAnnotationEntry; |
19 | |
import org.apache.bcel.generic.Type; |
20 | |
import org.apache.commons.classscan.model.MetaAnnotation; |
21 | |
import org.apache.commons.classscan.model.MetaType; |
22 | |
import org.apache.commons.classscan.spi.model.SpiMetaAnnotation; |
23 | |
import org.apache.commons.classscan.spi.model.SpiMetaClassLoader; |
24 | |
import org.apache.commons.classscan.spi.model.SpiMetaParameter; |
25 | |
import org.apache.commons.classscan.util.NameSet; |
26 | |
import org.slf4j.Logger; |
27 | |
import org.slf4j.LoggerFactory; |
28 | |
|
29 | |
public class BcelParameter implements SpiMetaParameter { |
30 | |
|
31 | 11 | private static final Logger logger = LoggerFactory.getLogger(BcelParameter.class); |
32 | |
|
33 | |
private MetaType type; |
34 | |
private String typeName; |
35 | |
private final NameSet<? extends SpiMetaAnnotation> annotations; |
36 | |
|
37 | 2098866 | public BcelParameter(Type argType, ParameterAnnotationEntry annotationEntry) { |
38 | 2098866 | typeName = argType.getSignature(); |
39 | 2098866 | annotations = AnnotationMap.createAnnotations(annotationEntry != null |
40 | |
?annotationEntry.getAnnotationEntries() :null); |
41 | 2098866 | } |
42 | |
|
43 | |
@Override |
44 | |
public boolean resolve(SpiMetaClassLoader classLoader) { |
45 | 2095918 | type = classLoader.resolveTypeForDescriptor(typeName); |
46 | 2095918 | if(type==null) { |
47 | 66 | logger.info("cannot resolve "+typeName+" as a parameter type"); |
48 | 66 | return false; |
49 | |
} |
50 | 2095852 | typeName= null; |
51 | 2095852 | return annotations.resolve(classLoader); |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public Set<? extends MetaAnnotation> getAnnotations() { |
56 | 11 | return annotations; |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public MetaAnnotation getAnnotation(String annotationName) { |
61 | 0 | return annotations.getValue(annotationName); |
62 | |
} |
63 | |
|
64 | |
@Override |
65 | |
public MetaType getType() { |
66 | 11 | return type; |
67 | |
} |
68 | |
} |