@TechDebt(size = TechDebt.Size.SMALL, description = "We need to implement this class, or not", link = "https://github.com/novoda/spikes") public class TechDebtSample { }
@Override public boolean process(Set<? extends TypeElement> annotationElements, RoundEnvironment roundEnv) { for (TypeElement annotationElement : annotationElements) { final Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(annotationElement); for (Element annotadedElement : annotatedElements) { printWarning(annotadedElement); } } return true; }
private void printWarning(Element annotatedElement) { TechDebt techDebt = annotatedElement.getAnnotation(TechDebt.class); String message = String.format(Locale.UK, WARNING_TEMPLATE, techDebt.description(), techDebt.size(), techDebt.link()); processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, message, annotatedElement); } }