views:

68

answers:

1

I'm trying to generate top-level abstract class with JCodeModel library, but I can't find any way to change class modifiers.
It's possible for nested classes (JDefinedClass API provides methods that get modifiers as parameters). But for creation of top level classes I found only JCodeModel API methods that get fully qualified name with or without ClassType (class/interface/annotation/enum) as parameters.

Does anybody can suggest me how to change modifiers of JDefinedClass to make it abstract?

+1  A: 

You need to create JPackage first and then create class ther.

Something like that.

JPackage package = cm._package("test");
JDefinedClass class = package._class(JMod.ABSTRACT,"AbstractTest");

Hope it helps.

Alexey Ogarkov
It's definitely what I need. Works great. Thanks, Alexey!
Yury Khrol
Was happy to help
Alexey Ogarkov