final boolean oneWay = m.hasAnnotation(OneWay.class);
if (method.hasAnnotation(NonCopied.class)) { logger.debug(String.format("Not adding method [%s]", method.getName())); } else {
protected boolean hasTestAnnotation(CtMethod m) throws Exception { return m.hasAnnotation(Test.class); }
protected static boolean isAnnotated( @Nonnull CtMethod method, @Nonnull Class<? extends Annotation> annotationType ) throws ClassNotFoundException { return method.hasAnnotation(annotationType); }
@Override public boolean visit(String t) { try { CtClass c = pool.get(t); for (CtMethod m : c.getMethods()) { if (m.hasAnnotation(SequenceDiagram.class)) { classnames.add(t); System.out.println("Generating diagram for "+t); break; } } } catch (NotFoundException e) { } return true; } });
ClassPool pool = ClassPool.getDefault(); CtClass sp = pool.get("SomeProcess"); for (CtMethod m : sp.getDeclaredMethods()) { if (m.hasAnnotation(ToBeTransformed.class)) { String body = // create new body m.setBody(body); } }
public static List<CtMethod> getMethodsAnnotatedWith( CtClass type, Class<? extends Annotation> annotation, boolean withSuperClass) throws NotFoundException { final List<CtMethod> methods = new LinkedList<>(); CtClass klass = type; do { for (CtMethod method : klass.getDeclaredMethods()) { if (method.hasAnnotation(annotation)) { methods.add(method); } } klass = klass.getSuperclass(); } while (klass != null && withSuperClass); return methods; }
protected boolean isInner(CtMethod m) throws Exception { Class<?> implAnnotation = loadClas(m.getDeclaringClass(), "com.google.appengine.datanucleus.Inner"); return m.hasAnnotation(implAnnotation); }
for (CtClass patchClass : patchClasses) { for (CtMethod ctMethod : patchClass.getDeclaredMethods()) { if (ctMethod.hasAnnotation(PatchMethod.class)) { if (!Modifier.isStatic(ctMethod.getModifiers())) { throw new GwtTestPatchException("@" + PatchMethod.class.getName()
for (CtClass patchClass : patchClasses) { for (CtMethod ctMethod : patchClass.getDeclaredMethods()) { if (ctMethod.hasAnnotation(PatchMethod.class)) { if (!Modifier.isStatic(ctMethod.getModifiers())) { throw new GwtTestPatchException("@" + PatchMethod.class.getName()
private void removeTestAnnotationsForTestMethodsThatRunOnOtherClassLoader(CtClass clazz) throws Exception { for (CtMethod m : clazz.getDeclaredMethods()) { if (m.hasAnnotation(getTestMethodAnnotationType()) && mustHaveTestAnnotationRemoved(m)) { removeTestMethodAnnotationFrom(m); } } }
public static boolean modify(String className, boolean mapUnderscoreToCamelCase) { synchronized (className.intern()) { if (modifiedClassNames.contains(className)) return true; try { boolean modified = false; CtClass ctClass = ClassPool.getDefault().get(className); for (CtMethod ctMethod : ctClass.getDeclaredMethods()) { if (ctMethod.hasAnnotation(Mapper.class)) { MethodNameParser parser = new MethodNameParser(ctMethod.getName(), "#t", mapUnderscoreToCamelCase); addQueryAnnotation(ctMethod, parser.toSql()); addRowBoundsParameter(ctMethod, parser.toRowBounds()); modified = true; } } if (modified) { ctClass.toClass(MapperInstrument.class.getClassLoader(), MapperInstrument.class.getProtectionDomain()); modifiedClassNames.add(className); } for (CtClass i : ctClass.getInterfaces()) { modified |= modify(i.getName(), mapUnderscoreToCamelCase); } return modified; } catch (CannotCompileException | NotFoundException e) { throw new RuntimeException(e); } } }
String label = null; try { if (m.hasAnnotation(Caption.class)) { if (m.hasAnnotation(FileName.class)) { fileName = ((FileName) m.getAnnotation(FileName.class)).value(); } else { if (m.hasAnnotation(OutputDirectory.class)) { outDir = ((OutputDirectory) m .getAnnotation(OutputDirectory.class)).value(); if (m.hasAnnotation(Label.class)) { label = ((Label) m.getAnnotation(Label.class)).value();
@Override public void onLoad(ClassPool pool, String classname) throws NotFoundException, CannotCompileException { CtClass ct = pool.getCtClass(classname); for (CtMethod m : ct.getMethods()) { if(m.hasAnnotation(SequenceDiagram.class)){ injector.entryMethod(m); } } if(injector.isDiagramClass(ct)){ injector.diagramClass(ct); } }
private CtMethod getInitMethod(Set<CtClass> patchClasses) { List<CtMethod> initMethods = new ArrayList<>(); for (CtClass patchClass : patchClasses) { for (CtMethod ctMethod : patchClass.getDeclaredMethods()) { if (ctMethod.hasAnnotation(InitMethod.class)) { if (!Modifier.isStatic(ctMethod.getModifiers())) { throw new GwtTestPatchException("@" + InitMethod.class.getSimpleName() + " has to be static : '" + ctMethod.getLongName() + "'"); } try { if (ctMethod.getParameterTypes().length != 1 || ctMethod.getParameterTypes()[0] != GwtClassPool.getCtClass(CtClass.class)) { throw new GwtTestPatchException("@" + InitMethod.class.getName() + " method must have one and only one parameter of type '" + CtClass.class.getName() + "'"); } } catch (NotFoundException e) { // should never happen throw new GwtTestPatchException(e); } initMethods.add(ctMethod); } } } CtMethod initMethod = getMethodToUse(initMethods, InitMethod.class); if (initMethod != null) { initMethod.setModifiers(Modifier.PUBLIC + Modifier.STATIC); } return initMethod; }
private CtMethod getInitMethod(Set<CtClass> patchClasses) { List<CtMethod> initMethods = new ArrayList<>(); for (CtClass patchClass : patchClasses) { for (CtMethod ctMethod : patchClass.getDeclaredMethods()) { if (ctMethod.hasAnnotation(InitMethod.class)) { if (!Modifier.isStatic(ctMethod.getModifiers())) { throw new GwtTestPatchException("@" + InitMethod.class.getSimpleName() + " has to be static : '" + ctMethod.getLongName() + "'"); } try { if (ctMethod.getParameterTypes().length != 1 || ctMethod.getParameterTypes()[0] != GwtClassPool.getCtClass(CtClass.class)) { throw new GwtTestPatchException("@" + InitMethod.class.getName() + " method must have one and only one parameter of type '" + CtClass.class.getName() + "'"); } } catch (NotFoundException e) { // should never happen throw new GwtTestPatchException(e); } initMethods.add(ctMethod); } } } CtMethod initMethod = getMethodToUse(initMethods, InitMethod.class); if (initMethod != null) { initMethod.setModifiers(Modifier.PUBLIC + Modifier.STATIC); } return initMethod; }