square / javapoet

A Java API for generating .java source files.
Apache License 2.0
10.83k stars 1.38k forks source link

feat: $V for inlined values in generated code #999

Open Christopher-Chianelli opened 9 months ago

Christopher-Chianelli commented 9 months ago

If you have an instance you want to put inside the generated code, and you trust it, you can use the new "$V" argument spec to tell JavaPoet to generate a Supplier lambda to construct the object and immediately call it.

Design questions:

Closes #968