Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tomas-Kraus opened this issue May 6, 2013 · 5 comments
Open

Comments

@Tomas-Kraus
Copy link
Member

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
Copy link
Member Author

@glassfishrobot Commented
Reported by dma_k

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to yaroska

@Tomas-Kraus
Copy link
Member Author

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

@Tomas-Kraus
Copy link
Member Author

@dmak
Copy link

dmak commented Jan 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants