Reputation: 1105
I am trying to generate java code using Jcodemodel.
How to generate required import statements using Jcodemodel?
How to automatically generate the implementation of interface methods when a class implements the interface?
eg:
interface Act {
void act();
}
using Jcodemodel, how to generate the interface method in implementation class? whether do I need to write method using JMethod? Is there any other way to auto generate the implementation methods?
How to generate required imports for a class?
Kindly,guide me
Upvotes: 2
Views: 1957
Reputation: 21
You should use the method
JClass importedClass= codeModel.ref("example.com.impl.MyClass");
And make sure example.com.impl.MyClass
is in your classpath.
In the generated java source, the import example.com.impl.MyClass
statement will be automatically added for you.
Upvotes: 2