jaxb-ri
jaxb-ri copied to clipboard
Add API support to move model class to another class or package
Currently it is not possible to manipulate with Code Model in a way that JDefinedClass is moved to another class or package. For that:
- JDefinedClass and JPackage should implement method _class(JClass anotherClass), i.e. opportunity to add existing class.
- The owner of anotherClass should be set to new container, thus there is a need for JDefinedClass#setOuter(JClassContainer newOuter)
- If class is moved to package, its static modifier should be reset, thus there is a need for JMod#setStatic(boolean newValue).
Affected Versions
[2.2.6]
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/957
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by dma_k
@glassfishrobot Commented Was assigned to yaroska
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-957
Would be great to reconsider this issue, namely allow JAXB plugins to add/remove classes to/from package and to/from class. For that the appropriate methods could be added to com.sun.codemodel.JPackage
and com.sun.codemodel.JDefinedClass
(probably should implement the same interface):
JDefinedClass getClass(String name) { return classes.put(name); }
boolean removeClass(String name) { return classes.remove(name); }
void addClass(String name, JDefinedClass clazz) { classes.put(name, clazz); }
Additionally:
JDefinedClass.setContainer(JClassContainer container) { this.outer = container; }
JDefinedClass.setName(String name) { this.name = name; }