protected static boolean isPossibleCopyMethod(
        ValueAttribute valueAttribute,
        Element possibleCopyMethod,
        boolean onValueType) {
      if (possibleCopyMethod.getKind() == ElementKind.METHOD) {
        if (!valueAttribute.containingType.names().possibleAttributeBuilder(possibleCopyMethod.getSimpleName())) {
          return false;
        }

        ExecutableElement candidateCopyMethod = (ExecutableElement) possibleCopyMethod;

        Types typeUtils = valueAttribute.containingType.constitution.protoclass()
            .environment()
            .processing()
            .getTypeUtils();

        if (candidateCopyMethod.getParameters().size() == 1
            && typeUtils.isSameType(
                candidateCopyMethod.getParameters().get(0).asType(),
                valueAttribute.containedTypeElement.asType())) {

          TypeKind kind = candidateCopyMethod.getReturnType().getKind();
          return !kind.isPrimitive() && kind != TypeKind.ARRAY;
          // handle proto style toBuilder() copy method... lots of BuilderModels created because of this
        } else if (onValueType
            && candidateCopyMethod.getParameters().size() == 0
            && !candidateCopyMethod.getModifiers().contains(Modifier.STATIC)) {

          TypeKind kind = candidateCopyMethod.getReturnType().getKind();
          return !kind.isPrimitive() && kind != TypeKind.ARRAY;
        }
      } else if (!onValueType && possibleCopyMethod.getKind() == ElementKind.CONSTRUCTOR) {

        if (!valueAttribute.containingType.names().newTokenInAttributeBuilder()) {
          return false;
        }

        ExecutableElement candidateConstructor = (ExecutableElement) possibleCopyMethod;
        return candidateConstructor.getParameters().size() == 1
            && candidateConstructor.getParameters().get(0).asType().equals(valueAttribute.containedTypeElement.asType());
      }

      return false;
    }
Applies to both builder and value candidates.

@param valueAttribute the valueAttribute.
@param possibleCopyMethod candidate to check.
value-processor/src/org/immutables/value/processor/meta/AttributeBuilderReflection.java