Bar.class reference in JavaPoet

34 Views Asked by At

I have a method that takes a class, e.g. public foo(Class<?> barClass). Using JavaPoet I want to pass construct an invocation of this method. Currently I'm using this form:


ClassName barClassName = ClassName.get("com.example", "Bar");

…
  .addStatement("foo($T.class)", barClassName)
…

That works well enough, but I'm wondering if JavaPoet has some facility to construct the Bar.class form, such as barClassName.literalReference() or some such.

0

There are 0 best solutions below