private void checkAnnotationsToApply(Element annotation) {
    if (!annotation.getKind().equals(ANNOTATION_TYPE)) {
      // Should not be possible because of @Target.
      messager.printMessage(
          Kind.ERROR,
          "@"
              + AnnotationsToApply.class.getSimpleName()
              + " must be applied to an annotation type declaration.",
          annotation);
    }
    Set<TypeElement> seenAnnotations = new HashSet<>();
    for (ExecutableElement annotationMember : methodsIn(annotation.getEnclosedElements())) {
      TypeMirror memberType = annotationMember.getReturnType();
      boolean isAnnotation =
          memberType.getKind().equals(DECLARED)
              && asElement(memberType).getKind().equals(ANNOTATION_TYPE);
      if (!isAnnotation && !memberType.getKind().equals(ERROR)) {
        messager.printMessage(
            Kind.ERROR,
            "Members of an @"
                + AnnotationsToApply.class.getSimpleName()
                + " annotation must themselves be annotations; "
                + annotationMember.getSimpleName()
                + " has type "
                + memberType,
            annotationMember);
      } else {
        TypeElement annotationElement = asTypeElement(memberType);
        if (!seenAnnotations.add(annotationElement)) {
          messager.printMessage(
              Kind.ERROR, "More than one @" + annotationElement + " in " + annotation, annotation);
        }
      }
    }
  }
Checks that {@link AnnotationsToApply} is used correctly.
factory/src/main/java/com/google/auto/factory/processor/AutoFactoryProcessor.java