Extract the TypeVariableName you create into the variable so you can reuse its value
TypeVariableName typeVariableName = TypeVariableName.get("T", MyClass.class);
Then add a parameter of this type
MethodSpec spec = MethodSpec.methodBuilder("doSomething") .addModifiers(Modifier.PUBLIC) .addTypeVariable(typeVariableName) .addParameter(typeVariableName, "t")
source share