简体   繁体   中英

prewritten code with JCodeModel

So I'm in a situation where I need to generate code using JCodeModel, but a fair ammount of the code I need to generate would not need to be changed between the classes (I'd say only 10-20% needs to actually be generated at runtime)

How would I go about creating a class that is only partially generated? Or do I just have to convert the entire thing into the JCodeModel format because of how it compiles.

Also, if perhaps there is another code generation format that might be better suited for my needs i'd also be very interested in hearing about it.

You could create an abstract class (without even JCodeModel generator) and make all you code to inherit from it.

public abstract class Base {
    // all your common stuff
}

and in code model use:

<your generated class>._extends(Base.class)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM