@Override
    public Optional<ExecutableElement> buildMethod() {
      Types typeUtils = processingEnv.getTypeUtils();
      DeclaredType builderTypeMirror = MoreTypes.asDeclared(builderTypeElement.asType());
      return MoreElements.getLocalAndInheritedMethods(
              builderTypeElement, typeUtils, processingEnv.getElementUtils())
          .stream()
          .filter(
              m ->
                  m.getSimpleName().contentEquals("build")
                      && !m.getModifiers().contains(Modifier.PRIVATE)
                      && !m.getModifiers().contains(Modifier.STATIC)
                      && m.getParameters().isEmpty())
          .filter(
              m -> {
                ExecutableType methodMirror =
                    MoreTypes.asExecutable(typeUtils.asMemberOf(builderTypeMirror, m));
                return erasedTypeIs(methodMirror.getReturnType(), autoValueClass);
              })
          .findFirst();
    }
Representation of an {@code AutoValue.Builder} class or interface.
value/src/main/java/com/google/auto/value/processor/BuilderSpec.java