jaxb-codemodel icon indicating copy to clipboard operation
jaxb-codemodel copied to clipboard

Generating a method that returns from super

Open mickog opened this issue 6 years ago • 1 comments

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 avatar Jan 08 '19 16:01 mickog

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

mickog avatar Jan 08 '19 16:01 mickog