Menu

#4 Adding support for generics in generated sources

0.2.*
open
Pino
features (6)
3
2009-06-02
2009-06-02
No

Can we parametrize the templates to generate code supporting Java 5 generics in case the maven-compiler-plugin is configured to compile against java 1.5 or greater? Actually I saw a few methods in the Domain and Factory classes which can be improved with generalization.

Discussion

  • Pino

    Pino - 2009-06-07

    What do you mean for "improved with generalization" ??
    Smartweb as u know doesn't use generics , so if i try to parameterize a Domain method as findAll that return a Collection , also I must use a cast to add the object into a raw ArrayList cause BusinessObjectFactory.findBykey return an object and if you try to add an object into a Collection<yourBusinessObject> you must explicit a cast to avoid compile errors.

     
  • Roberto Lo Giacco

    What I mean is exactly what you are saying, generating code which "supports" generics, performing the casts wherever needed to avoid the user to cast manually and ensuring factories and other methods are used properly.

    We can add automagical selection for convertKey so if we have a String primary key we can convert to string, if we have a numeric primary key we can convert to number, we can override the methods and stuff like that.

    We can even propose to migrate the core framework to Java 5 if needed

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.