phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

Construct JLambdaMethodRef with JInvocation #56

Closed heruan closed 6 years ago

heruan commented 6 years ago

I need to generate this field signature:

public final StringFilter<E> firstName = this.andThen(Person::getFirstName)::apply;

I can easily generate the this.andThen(Person::getFirstName) part with:

JLambdaMethodRef lambdaMethod = new JLambdaMethodRef(personType, getterName);
JInvocation jInvocation = JExpr._this().invoke("andThen").arg(lambdaMethod);

but I can't generate a lambda method reference from this JInvocation, since I can't construct a new JLambdaMethodRef(jInvocation, "apply") nor I can generate a lambda reference with any JInvocation method, e.g. jInvocation.ref("apply") generates .apply instead of ::apply.

phax commented 6 years ago

I will add a test and complete the API before the release. Will be today or tomorrow!