private void validateMethod(ExecutableElement method, Elements elements) {
    ErrorReporter errorReporter = new ErrorReporter(method, processingEnv.getMessager());
    if (method.getModifiers().contains(STATIC)) {
      errorReporter.reportError("@ToPrettyString methods must be instance methods");
    }

    TypeMirror stringType = elements.getTypeElement("java.lang.String").asType();
    if (!MoreTypes.equivalence().equivalent(method.getReturnType(), stringType)) {
      errorReporter.reportError("@ToPrettyString methods must return String");
    }

    if (!method.getParameters().isEmpty()) {
      errorReporter.reportError("@ToPrettyString methods cannot have parameters");
    }
  }
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