use of org.objectweb.asm.Type.getType in project felix by apache.
the class AnnotationPlayback method acceptArray.
private void acceptArray(final Map<String, Object> values, final AnnotationVisitor visitor) {
Map<String, Object> copy = new HashMap<String, Object>(values);
for (Map.Entry<String, Object> entry : copy.entrySet()) {
Class<?> type = entry.getValue().getClass();
if (type.isArray()) {
// Simple arrays have been visited using AnnotationVisitor.visit(String, Object)
AnnotationVisitor arrayVisitor = visitor.visitArray(entry.getKey());
if (arrayVisitor != null) {
Object[] array = (Object[]) entry.getValue();
Class<?> componentType = array.getClass().getComponentType();
Type asmType = Type.getType(componentType);
if (componentType.isEnum()) {
for (Object o : array) {
Enum eValue = (Enum) o;
arrayVisitor.visitEnum(null, asmType.getDescriptor(), eValue.name());
}
} else if (componentType.isAnnotation()) {
for (Object o : array) {
Annotation annotation = (Annotation) o;
AnnotationVisitor annotationVisitor = arrayVisitor.visitAnnotation(null, asmType.getDescriptor());
if (annotationVisitor != null) {
AnnotationPlayback playback = new AnnotationPlayback(annotation);
playback.accept(annotationVisitor);
}
}
} else {
for (Object o : array) {
arrayVisitor.visit(null, transform(o));
}
}
arrayVisitor.visitEnd();
}
values.remove(entry.getKey());
}
}
}
Aggregations