public static boolean hasAnnotationWithPrefix(CtClass ctClass, String annotationPrefix) throws ClassNotFoundException { for (Object object : ctClass.getAvailableAnnotations()) { Annotation ann = (Annotation) object; if (ann.annotationType().getName().startsWith(annotationPrefix)) { return true; } } return false; }
public static boolean hasAnnotation(CtClass ctClass, String annotation) throws ClassNotFoundException { for (Object object : ctClass.getAvailableAnnotations()) { Annotation ann = (Annotation) object; if (ann.annotationType().getName().equals(annotation)) { return true; } } return false; }
protected <T> T getAnnotation(CtClass ctClass, String annotation) throws ClassNotFoundException { for (Object object : ctClass.getAvailableAnnotations()) { java.lang.annotation.Annotation ann = (java.lang.annotation.Annotation) object; if (ann.annotationType().getName().equals(annotation)) { return (T)ann; } } return null; }
/** * Test if a class has the provided annotation * * @param ctClass * the javassist class representation * @param annotation * fully qualified name of the annotation class eg."javax.persistence.Entity" * @return true if class has the annotation * @throws java.lang.ClassNotFoundException * if class not found */ protected boolean hasAnnotation(CtClass ctClass, String annotation) throws ClassNotFoundException { for (Object object : ctClass.getAvailableAnnotations()) { Annotation ann = (Annotation) object; if (ann.annotationType().getName().equals(annotation)) { return true; } } return false; }
static Object[] getAnnotationsInternal(Class clazz) { return getCtClass(clazz).getAvailableAnnotations(); }
static Object[] getDeclaredAnnotationsInternal(Class clazz) { return getCtClass(clazz).getAvailableAnnotations(); }
/** * <p>Getter for the field <code>annotations</code>.</p> * * @return an array of {@link java.lang.Object} objects. */ public Object[] getAnnotations() { if (annotations == null) { try { annotations = getCtClass().getAvailableAnnotations(); } catch (Exception | Error e) { return new Object[0]; } } return annotations; }
private String getRemoveServiceRelativePath(Class<?> clazz) { CtClass ctClass = GwtClassPool.getCtClass((clazz)); Object[] annotations = ctClass.getAvailableAnnotations(); for (Object o : annotations) { if (Proxy.isProxyClass(o.getClass())) { AnnotationImpl annotation = (AnnotationImpl) Proxy.getInvocationHandler(o); if (annotation.getTypeName().equals(RemoteServiceRelativePath.class.getName())) { return ((StringMemberValue) annotation.getAnnotation().getMemberValue("value")).getValue(); } } } throw new GwtTestRpcException("Cannot find the '@" + RemoteServiceRelativePath.class.getSimpleName() + "' annotation on RemoteService interface '" + clazz.getName() + "'"); }
private String getRemoveServiceRelativePath(Class<?> clazz) { CtClass ctClass = GwtClassPool.getCtClass((clazz)); Object[] annotations = ctClass.getAvailableAnnotations(); for (Object o : annotations) { if (Proxy.isProxyClass(o.getClass())) { AnnotationImpl annotation = (AnnotationImpl) Proxy.getInvocationHandler(o); if (annotation.getTypeName().equals(RemoteServiceRelativePath.class.getName())) { return ((StringMemberValue) annotation.getAnnotation().getMemberValue("value")).getValue(); } } } throw new GwtTestRpcException("Cannot find the '@" + RemoteServiceRelativePath.class.getSimpleName() + "' annotation on RemoteService interface '" + clazz.getName() + "'"); }
annotations = ((CtClass)obj).getAvailableAnnotations();
annotations = ((CtClass)obj).getAvailableAnnotations();
classProcessor.processUsing(clazz.getAvailableAnnotations(), new Block2<Object, ClassAnnotationHandler>() { protected void softExec(Object annotation, ClassAnnotationHandler handler) throws Exception { handler.preProcessAnnotatedClass((Annotation) annotation, context); instrumentConstructor(constructor); classProcessor.processUsing(clazz.getAvailableAnnotations(), new Block2<Object, ClassAnnotationHandler>() { protected void softExec(Object annotation, ClassAnnotationHandler handler) throws Exception { handler.postProcessAnnotatedClass((Annotation) annotation, context);