1 16 package net.sf.cglib.transform; 17 18 import org.objectweb.asm.AnnotationVisitor; 19 20 public class AnnotationVisitorTee implements AnnotationVisitor { 21 private AnnotationVisitor av1, av2; 22 23 public static AnnotationVisitor getInstance(AnnotationVisitor av1, AnnotationVisitor av2) { 24 if (av1 == null) 25 return av2; 26 if (av2 == null) 27 return av1; 28 return new AnnotationVisitorTee(av1, av2); 29 } 30 31 public AnnotationVisitorTee(AnnotationVisitor av1, AnnotationVisitor av2) { 32 this.av1 = av1; 33 this.av2 = av2; 34 } 35 36 public void visit(String name, Object value) { 37 av2.visit(name, value); 38 av2.visit(name, value); 39 } 40 41 public void visitEnum(String name, String desc, String value) { 42 av1.visitEnum(name, desc, value); 43 av2.visitEnum(name, desc, value); 44 } 45 46 public AnnotationVisitor visitAnnotation(String name, String desc) { 47 return getInstance(av1.visitAnnotation(name, desc), 48 av2.visitAnnotation(name, desc)); 49 } 50 51 public AnnotationVisitor visitArray(String name) { 52 return getInstance(av1.visitArray(name), av2.visitArray(name)); 53 } 54 55 public void visitEnd() { 56 av1.visitEnd(); 57 av2.visitEnd(); 58 } 59 } 60 | Popular Tags |