private static ImmutableSet<FactoryMethodDescriptor> getDeduplicatedMethodDescriptors(
      ImmutableSet<FactoryMethodDescriptor> methodDescriptors,
      ImmutableBiMap<FactoryMethodDescriptor, ImplementationMethodDescriptor>
          duplicateMethodDescriptors) {

    ImmutableSet.Builder<FactoryMethodDescriptor> deduplicatedMethodDescriptors =
        ImmutableSet.builder();

    for (FactoryMethodDescriptor methodDescriptor : methodDescriptors) {
      ImplementationMethodDescriptor duplicateMethodDescriptor =
          duplicateMethodDescriptors.get(methodDescriptor);

      FactoryMethodDescriptor newMethodDescriptor =
          (duplicateMethodDescriptor != null)
              ? methodDescriptor.toBuilder()
                  .overridingMethod(true)
                  .publicMethod(duplicateMethodDescriptor.publicMethod())
                  .returnType(duplicateMethodDescriptor.returnType())
                  .exceptions(duplicateMethodDescriptor.exceptions())
                  .build()
              : methodDescriptor;
      deduplicatedMethodDescriptors.add(newMethodDescriptor);
    }

    return deduplicatedMethodDescriptors.build();
  }
Returns a set of deduplicated {@link FactoryMethodDescriptor}s from the set of original
descriptors and the bi-map of duplicate descriptors.

<p>Modifies the duplicate {@link FactoryMethodDescriptor}s such that they are overriding and
reflect properties from the {@link ImplementationMethodDescriptor} they are implementing.
factory/src/main/java/com/google/auto/factory/processor/FactoryDescriptor.java