1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.boretti.drools.integration.drools5; |
20 | |
|
21 | |
import org.apache.maven.plugin.logging.Log; |
22 | |
import org.boretti.drools.integration.drools5.annotations.DroolsGenerated; |
23 | |
import org.boretti.drools.integration.drools5.annotations.DroolsIgnored; |
24 | |
import org.objectweb.asm.AnnotationVisitor; |
25 | |
import org.objectweb.asm.FieldVisitor; |
26 | |
import org.objectweb.asm.Type; |
27 | |
import org.objectweb.asm.util.CheckFieldAdapter; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
class DroolsCheckFieldVisitor extends CheckFieldAdapter { |
34 | |
|
35 | |
private DroolsClassVisitor visitor; |
36 | |
|
37 | |
private Log logger; |
38 | |
|
39 | |
private String fieldName; |
40 | |
|
41 | |
public DroolsCheckFieldVisitor(Log logger,FieldVisitor parent,DroolsClassVisitor visitor,String fieldName) { |
42 | 0 | super(parent); |
43 | 0 | this.visitor=visitor; |
44 | 0 | this.logger=logger; |
45 | 0 | this.fieldName=fieldName; |
46 | 0 | } |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
@Override |
52 | |
public AnnotationVisitor visitAnnotation(String name, boolean arg1) { |
53 | 0 | if (Type.getType(name).getClassName().equals(Type.getType(DroolsGenerated.class).getClassName())) { |
54 | 0 | visitor.getFieldType().put(fieldName.toUpperCase(), (byte)0); |
55 | 0 | } else if (Type.getType(name).getClassName().equals(Type.getType(DroolsIgnored.class).getClassName())) { |
56 | 0 | visitor.getFieldType().put(fieldName.toUpperCase(), (byte)1); |
57 | |
} |
58 | 0 | return super.visitAnnotation(name, arg1); |
59 | |
} |
60 | |
|
61 | |
} |