sonatype / modello

http://modello.codehaus.org/
7 stars 11 forks source link

Add static utility method(s) generation to create new model instances #12

Closed simonetripodi closed 11 years ago

simonetripodi commented 11 years ago

I often notice that Modello users use to develop their own utility static methods in order to create Modello generated models, I wonder if it would make sense adding support for generating that method.

I'd immagine something like:

<model>
[...]

  <classes>
    <class java.staticCreator="true">
      <name>Dependency</name>
      <version>1.0.0+<version>
      <fields>
        [...]

that generates

public class Dependency
{

    // fields, getters/setters

    public static Dependency newDependencyInstance(/*all fields here*/)
    {
        Dependency dependency = new Dependency();
        // set all values
        return dependency;
    }

    public static Dependency newDependencyInstance(/*only fields without default values*/)
    {
        return newDependencyInstance(/*required an default values*/);
    }

}