private void validateSingleToPrettyStringMethod(
      Set<ExecutableElement> annotatedMethods, Types types, Elements elements) {
    Set<TypeElement> enclosingTypes =
        annotatedMethods.stream()
            .map(Element::getEnclosingElement)
            .map(MoreElements::asType)
            .collect(toCollection(LinkedHashSet::new));
    for (TypeElement enclosingType : enclosingTypes) {
      ImmutableList<ExecutableElement> methods =
          toPrettyStringMethods(enclosingType, types, elements);
      if (methods.size() > 1) {
        processingEnv
            .getMessager()
            .printMessage(
                ERROR,
                String.format(
                    "%s has multiple @ToPrettyString methods:%s",
                    enclosingType.getQualifiedName(), formatMethodList(methods)),
                enclosingType);
      }
    }
  }
An annotation processor that validates {@link
com.google.auto.value.extension.toprettystring.ToPrettyString} usage.
value/src/main/java/com/google/auto/value/extension/toprettystring/processor/ToPrettyStringValidator.java