private Optional<ExecutableElement> builderMaker(
      ImmutableSet<String> methodNamesToCheck,
      Map<String, ExecutableElement> methods,
      TypeElement barBuilderTypeElement,
      int argumentCount) {
    Optional<ExecutableElement> maybeMethod =
        methodNamesToCheck.stream()
            .map(methods::get)
            .filter(Objects::nonNull)
            .filter(method -> method.getModifiers().contains(Modifier.STATIC))
            .filter(
                method ->
                    typeUtils.isSameType(
                        typeUtils.erasure(method.getReturnType()),
                        typeUtils.erasure(barBuilderTypeElement.asType())))
            .findFirst();

    if (maybeMethod.isPresent()) {
      // TODO(emcmanus): check visibility. We don't want to require public for @AutoValue
      // builders. By not checking visibility we risk accepting something as a builder maker
      // and then failing when the generated code tries to call Bar.builder(). But the risk
      // seems small.
      return maybeMethod;
    }

    return ElementFilter.constructorsIn(barBuilderTypeElement.getEnclosedElements()).stream()
        .filter(c -> c.getParameters().size() == argumentCount)
        .filter(c -> c.getModifiers().contains(Modifier.PUBLIC))
        .findFirst();
  }
The method to copy another collection into this builder. It is {@code addAll} for
one-dimensional collections like {@code ImmutableList} and {@code ImmutableSet}, and it is
{@code putAll} for two-dimensional collections like {@code ImmutableMap} and {@code
ImmutableTable}.
value/src/main/java/com/google/auto/value/processor/PropertyBuilderClassifier.java