/** * Finds annotation in class info. Returns <code>null</code> if annotation doesn't exist. */ default AnnotationInfo getAnnotation(final Class<? extends Annotation> an) { AnnotationInfo[] anns = getAnnotations(); if (anns == null) { return null; } String anName = an.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return ann; } } return null; }
/** * Returns <code>true</code> if class is annotated with one of provided annotation. */ default boolean hasAnnotation(final Class<? extends Annotation>... an) { AnnotationInfo[] anns = getAnnotations(); if (anns == null) { return false; } for (Class<? extends Annotation> annotationClass : an) { String anName = annotationClass.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return true; } } } return false; }
/** * Visits replacement code for {@link ProxyTarget#targetClassAnnotation(String, String)}. */ public static void targetClassAnnotation(final MethodVisitor mv, final ClassInfo classInfo, final String[] args) { AnnotationInfo[] anns = classInfo.getAnnotations(); if (anns != null) { targetAnnotation(mv, anns, args); } else { mv.visitInsn(Opcodes.ACONST_NULL); } }
assertEquals("jodd/proxetta/fixtures/data/BigFatJoe", ci.getReference()); assertEquals("jodd/proxetta/fixtures/data/SmallSkinnyZoe", ci.getSuperName()); AnnotationInfo[] anns = ci.getAnnotations(); assertNotNull(anns); assertEquals(3, anns.length);
/** * Finds annotation in class info. Returns <code>null</code> if annotation doesn't exist. */ default AnnotationInfo getAnnotation(final Class<? extends Annotation> an) { AnnotationInfo[] anns = getAnnotations(); if (anns == null) { return null; } String anName = an.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return ann; } } return null; }
/** * Finds annotation in class info. Returns <code>null</code> if annotation doesn't exist. */ public AnnotationInfo getAnnotation(ClassInfo classInfo, Class<? extends Annotation> an) { AnnotationInfo[] anns = classInfo.getAnnotations(); if (anns == null) { return null; } String anName = an.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return ann; } } return null; }
/** * Returns <code>true</code> if class is annotated with one of provided annotation. */ public boolean hasAnnotation(ClassInfo classInfo, Class<? extends Annotation>... an) { AnnotationInfo[] anns = classInfo.getAnnotations(); if (anns == null) { return false; } for (Class<? extends Annotation> annotationClass : an) { String anName = annotationClass.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return true; } } } return false; }
/** * Returns <code>true</code> if class is annotated with one of provided annotation. */ default boolean hasAnnotation(final Class<? extends Annotation>... an) { AnnotationInfo[] anns = getAnnotations(); if (anns == null) { return false; } for (Class<? extends Annotation> annotationClass : an) { String anName = annotationClass.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return true; } } } return false; }
/** * Visits replacement code for {@link ProxyTarget#targetClassAnnotation(String, String)}. */ public static void targetClassAnnotation(final MethodVisitor mv, final ClassInfo classInfo, final String[] args) { AnnotationInfo[] anns = classInfo.getAnnotations(); if (anns != null) { targetAnnotation(mv, anns, args); } else { mv.visitInsn(Opcodes.ACONST_NULL); } }