javaee / jaxb-codemodel

CodeModel is a Java library for code generators. This content is migrated into JAXB RI. This is for legacy viewing only
https://javaee.github.io/jaxb-codemodel/
Other
40 stars 20 forks source link

Generating a method that returns from super #29

Open mickog opened 5 years ago

mickog commented 5 years ago

Hi there,

I am using JCodeModel but cannot find how I can generate a method that returns a call from its super class.

Relevant parts of what I have ..

JDefinedClass jc = jp._class("NewPremiumDTO"); JMethod m = jc.method(JMod.PUBLIC, LP.class, "map"); m.body()._return(m.body().invoke("super"). arg(JExpr.ref("map")));`

This will generate 2 lines rather than 1 like this

`super(map);

return super(map);`

inside generated method but I want to generate this line

return super.map(map, this);

Would appreciate help or feedback Thanks

mickog commented 5 years ago

m.body()._return(JExpr.invoke("super").invoke("map"). arg(JExpr.ref("map")).arg(JExpr._this())); for anyone else looking