Replies: 3 comments 1 reply
-
first step is to make the write field. It's the simplest one and won't require much time. Also I forgot to say, but those subclasses are stateless. All the state is still in the JCM. They can be marked as transient. |
Beta Was this translation helpful? Give feedback.
-
been working on a POC : Ignore changes before line 1090 I switched to a private field instead of public final so that they could be changed to have a strategy pattern. Actually they could still be final public, and assigned in the constructor. but with the var keyword it's easy to do something like
|
Beta Was this translation helpful? Give feedback.
-
pushed a commit on my branch to move the differences in a specific package (sugar) |
Beta Was this translation helpful? Give feedback.
-
The idea is to have everything needed for using a code model inside it.
Typically a code creation involves creation of the classes, generation of the expressions, and then writing somewhere.
I propose for each X in [create, link, exp, write] to have an internal class (non static) JCMX (eg JCMcreate) that proposes all the functions linked to this activity (here, creation of internal classes/resources/packages). The JCM would then have a final field (I would like public final but I guess it will be nope) X (so create) as well as a method (so create() )that returns that field.
eg :
The same with write, except write() will delegate all the calls. Typically write.toFile(File file) will create a new JCMWriter and call build on it with the file in parameter.
WHY ? Because when I use JCM I often spend time to find out how a thing is done. Typically, JExpr allows to make expressions, but if I want use wildcard or a ref to String, I still need to use JCM.
So I propose the following split :
toMemory() {return MemoryCodeWriter.from(this.JCodeModel).compite();}
Then several methods that are present in the JCM should be deprecated (with reason : use #link.#_ref() or use #create.#_class()) and scheduled for removal on future major version.
Beta Was this translation helpful? Give feedback.
All reactions