FactoryMethodDescriptor generateDescriptorForConstructor(
      final AutoFactoryDeclaration declaration, ExecutableElement constructor) {
    checkNotNull(constructor);
    checkArgument(constructor.getKind() == ElementKind.CONSTRUCTOR);
    TypeElement classElement = MoreElements.asType(constructor.getEnclosingElement());
    Map<Boolean, List<VariableElement>> parameterMap =
        constructor.getParameters().stream()
            .collect(partitioningBy(parameter -> isAnnotationPresent(parameter, Provided.class)));
    // The map returned by partitioningBy always has entries for both key values but our
    // null-checker isn't yet smart enough to know that.
    ImmutableSet<Parameter> providedParameters =
        Parameter.forParameterList(requireNonNull(parameterMap.get(true)), types, injectApi);
    ImmutableSet<Parameter> passedParameters =
        Parameter.forParameterList(requireNonNull(parameterMap.get(false)), types, injectApi);
    return FactoryMethodDescriptor.builder(declaration)
        .name("create")
        .returnType(classElement.asType())
        .publicMethod(classElement.getModifiers().contains(PUBLIC))
        .providedParameters(providedParameters)
        .passedParameters(passedParameters)
        .creationParameters(
            Parameter.forParameterList(constructor.getParameters(), types, injectApi))
        .isVarArgs(constructor.isVarArgs())
        .exceptions(constructor.getThrownTypes())
        .overridingMethod(false)
        .build();
  }
A service that traverses an element and returns the set of factory methods defined therein.

@author Gregory Kick
factory/src/main/java/com/google/auto/factory/processor/FactoryDescriptorGenerator.java