use of org.mvel2.asm.AnnotationVisitor in project drools by kiegroup.
the class DefaultBeanClassBuilder method buildClassAnnotations.
protected void buildClassAnnotations(ClassDefinition classDef, ClassVisitor cw) {
for (AnnotationDefinition ad : classDef.getAnnotations()) {
AnnotationVisitor av = cw.visitAnnotation("L" + BuildUtils.getInternalType(ad.getName()) + ";", true);
addAnnotationAttribute(ad, av);
av.visitEnd();
}
}
use of org.mvel2.asm.AnnotationVisitor in project drools by kiegroup.
the class DefaultBeanClassBuilder method addAnnotationAttribute.
public static void addAnnotationAttribute(AnnotationDefinition ad, AnnotationVisitor av) {
for (String key : ad.getValues().keySet()) {
AnnotationDefinition.AnnotationPropertyVal apv = ad.getValues().get(key);
switch(apv.getValType()) {
case STRINGARRAY:
AnnotationVisitor subAv = av.visitArray(apv.getProperty());
Object[] array = (Object[]) apv.getValue();
for (Object o : array) {
subAv.visit(null, o);
}
subAv.visitEnd();
break;
case PRIMARRAY:
av.visit(apv.getProperty(), apv.getValue());
break;
case ENUMARRAY:
AnnotationVisitor subEnav = av.visitArray(apv.getProperty());
Enum[] enArray = (Enum[]) apv.getValue();
String aenumType = "L" + BuildUtils.getInternalType(enArray[0].getClass().getName()) + ";";
for (Enum enumer : enArray) {
subEnav.visitEnum(null, aenumType, enumer.name());
}
subEnav.visitEnd();
break;
case CLASSARRAY:
AnnotationVisitor subKlav = av.visitArray(apv.getProperty());
Class[] klarray = (Class[]) apv.getValue();
for (Class klass : klarray) {
subKlav.visit(null, Type.getType("L" + BuildUtils.getInternalType(klass.getName()) + ";"));
}
subKlav.visitEnd();
break;
case ENUMERATION:
String enumType = "L" + BuildUtils.getInternalType(apv.getType().getName()) + ";";
av.visitEnum(apv.getProperty(), enumType, ((Enum) apv.getValue()).name());
break;
case KLASS:
String klassName = BuildUtils.getInternalType(((Class) apv.getValue()).getName());
av.visit(apv.getProperty(), Type.getType("L" + klassName + ";"));
break;
case PRIMITIVE:
av.visit(apv.getProperty(), apv.getValue());
break;
case STRING:
av.visit(apv.getProperty(), apv.getValue());
break;
}
}
}
use of org.mvel2.asm.AnnotationVisitor in project mvel by mvel.
the class TraceAnnotationVisitor method visitArray.
@Override
public AnnotationVisitor visitArray(final String name) {
Printer p = this.p.visitArray(name);
AnnotationVisitor av = this.av == null ? null : this.av.visitArray(name);
return new TraceAnnotationVisitor(av, p);
}
use of org.mvel2.asm.AnnotationVisitor in project mvel by mvel.
the class TraceAnnotationVisitor method visitAnnotation.
@Override
public AnnotationVisitor visitAnnotation(final String name, final String desc) {
Printer p = this.p.visitAnnotation(name, desc);
AnnotationVisitor av = this.av == null ? null : this.av.visitAnnotation(name, desc);
return new TraceAnnotationVisitor(av, p);
}
use of org.mvel2.asm.AnnotationVisitor in project mvel by mvel.
the class TraceFieldVisitor method visitTypeAnnotation.
@Override
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
Printer p = this.p.visitFieldTypeAnnotation(typeRef, typePath, desc, visible);
AnnotationVisitor av = fv == null ? null : fv.visitTypeAnnotation(typeRef, typePath, desc, visible);
return new TraceAnnotationVisitor(av, p);
}
Aggregations