private void fillBasic(BasicModel model, CtNamedElement namedElement) { String simpleName = namedElement.getSimpleName(); String docComment = namedElement.getDocComment(); model.setName(simpleName); model.setDocumentation(docComment); if (namedElement instanceof CtModifiable) { CtModifiable ctModifiable = (CtModifiable) namedElement; Set<ModifierKind> modifiers = ctModifiable.getModifiers(); for (ModifierKind mod : modifiers) { if (mod == ModifierKind.STATIC) { model.setStatic(true); } if (mod == ModifierKind.PUBLIC) { model.setPublic(true); } } } List<CtAnnotation<? extends Annotation>> annotations = namedElement.getAnnotations(); for (CtAnnotation<? extends Annotation> a : annotations) { IAnnotationModel annotationModel = processAnnotation(a); model.addAnnotation(annotationModel); } }
@Override public void process(CtElement candidate) { if (!isToBeProcessed(candidate)) return; CtModifiable cm = (CtModifiable) candidate; ModifierKind mk = cm.getVisibility(); do cm.setVisibility(kinds[r.nextInt(kinds.length)]); while (cm.getVisibility() == mk); infoWriter(candidate, mk.toString(), cm.getVisibility().toString(), mutatorName); }
@Override public boolean isToBeProcessed(CtElement candidate) { if (!(candidate instanceof CtModifiable)) return false; CtModifiable cm = (CtModifiable) candidate; if (!(cm instanceof CtVariable)) return false; ModifierKind mk = cm.getVisibility(); for (int i = kinds.length - 1; i >= 0; i--) if (mk == kinds[i]) return (r.nextInt(100) < CHANCE); // SELECTOR return false; }