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

Add API support to move model class to another class or package

Open Tomas-Kraus opened this issue 11 years ago • 5 comments

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]

Tomas-Kraus avatar May 06 '13 14:05 Tomas-Kraus

  • Issue Imported From: https://github.com/javaee/jaxb-v2/issues/957
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @glassfishrobot

Tomas-Kraus avatar Sep 21 '18 16:09 Tomas-Kraus

@glassfishrobot Commented Reported by dma_k

Tomas-Kraus avatar May 06 '13 14:05 Tomas-Kraus

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus avatar May 06 '13 14:05 Tomas-Kraus

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-957

Tomas-Kraus avatar Apr 24 '17 12:04 Tomas-Kraus

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; }

dmak avatar Jan 18 '23 00:01 dmak