I have a class Parent
and a class Derived
like
class Parent {
SomeClass obj = new SomeClass();
}
Now below class i want to generate using CodeModel
class Derived extends Parent {
String s = obj.invoke();
}
I tried below but not working
tryBlock.body().decl(codeModel.ref(String.class), "s",
(codeModel.ref(Parent.class)).staticRef("obj").invoke("invoke"));
How can I invoke obj rather than creating a new object as I am doing in Parent
class?