/** * Visits replacement code for {@link ProxyTarget#targetMethodAnnotation(String, String)}. */ public static void targetMethodAnnotation(final MethodVisitor mv, final MethodInfo methodInfo, final String[] args) { AnnotationInfo[] anns = methodInfo.getAnnotations(); if (anns != null) { targetAnnotation(mv, anns, args); } }
/** * Returns <code>true</code> if method is annotated with provided annotation. */ 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 method 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; }
@Test void testMethodSignature10() throws IOException { MethodInfo msv = getMethodSignatureForSingleMethod(M10.class); assertEquals(2, msv.getArgumentsCount()); assertEquals(0, msv.getArgument(1).getAnnotations().length); assertEquals(1, msv.getArgument(2).getAnnotations().length); assertEquals("jodd.proxetta.fixtures.data.FooAnn", msv.getArgument(2).getAnnotations()[0].getAnnotationClassname()); assertEquals("macka", msv.getMethodName()); assertEquals(1, msv.getAnnotations().length); assertEquals("jodd.proxetta.fixtures.data.FooAnn", msv.getAnnotations()[0].getAnnotationClassname()); }
AnnotationInfo[] anns = mi.getAnnotations(); assertNotNull(anns); assertEquals(3, anns.length); AnnotationInfo[] anns = mi.getAnnotations(); assertNotNull(anns); assertEquals(3, anns.length);
/** * Visits replacement code for {@link ProxyTarget#targetMethodAnnotation(String, String)}. */ public static void targetMethodAnnotation(final MethodVisitor mv, final MethodInfo methodInfo, final String[] args) { AnnotationInfo[] anns = methodInfo.getAnnotations(); if (anns != null) { targetAnnotation(mv, anns, args); } }
/** * Returns <code>true</code> if method is annotated with provided annotation. */ public AnnotationInfo getAnnotation(MethodInfo methodInfo, Class<? extends Annotation> mi) { AnnotationInfo[] anns = methodInfo.getAnnotations(); if (anns == null) { return null; } String anName = mi.getName(); for (AnnotationInfo ann : anns) { if (ann.getAnnotationClassname().equals(anName)) { return ann; } } return null; }
/** * Returns <code>true</code> if method is annotated with provided annotation. */ 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 method 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; }
/** * Returns <code>true</code> if method is annotated with one of provided annotation. */ public boolean hasAnnotation(MethodInfo methodInfo, Class<? extends Annotation>... an) { AnnotationInfo[] anns = methodInfo.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; }