private static void addCheckNotNullMethod(
      TypeSpec.Builder factory, FactoryDescriptor descriptor) {
    if (shouldGenerateCheckNotNull(descriptor)) {
      TypeVariableName typeVariable = TypeVariableName.get("T");
      factory.addMethod(
          methodBuilder("checkNotNull")
              .addModifiers(PRIVATE, STATIC)
              .addTypeVariable(typeVariable)
              .returns(typeVariable)
              .addParameter(typeVariable, "reference")
              .addParameter(TypeName.INT, "argumentNumber")
              .addParameter(TypeName.INT, "argumentCount")
              .beginControlFlow("if (reference == null)")
              .addStatement(
                  "throw new $T($S + argumentNumber + $S + argumentCount)",
                  NullPointerException.class,
                  "@AutoFactory method argument is null but is not marked @Nullable. Argument ",
                  " of ")
              .endControlFlow()
              .addStatement("return reference")
              .build());
    }
  }
{@link ParameterSpec}s to match {@code parameters}. Note that the type of the {@link
ParameterSpec}s match {@link Parameter#type()} and not {@link Key#type()}.
factory/src/main/java/com/google/auto/factory/processor/FactoryWriter.java