[forge-issues] [JBoss JIRA] (FORGE-1634) Make it simpler to add bean properties

Shane Bryzak (JIRA) issues at jboss.org
Tue Mar 4 18:41:33 EST 2014


Shane Bryzak created FORGE-1634:
-----------------------------------

             Summary: Make it simpler to add bean properties
                 Key: FORGE-1634
                 URL: https://issues.jboss.org/browse/FORGE-1634
             Project: Forge
          Issue Type: Feature Request
          Components: Parsers / File Manipulation
    Affects Versions: 2.1.1.Final
            Reporter: Shane Bryzak


Currently, to add a property to a java class you need to do this:

        Field<JavaClass> f = javaClass.addField("private String id = null;");
        f.addAnnotation(Id.class);
        f.addAnnotation(Identifier.class);

        javaClass.addMethod("public String getId() {" + lineSeparator +
                "  return id;" + lineSeparator +
                "}");

        javaClass.addMethod("public void setId(String id) {" + lineSeparator +
                "  this.id = id;" + lineSeparator + 
                "}");

It would be much nicer if you could just do this:

Property<JavaClass> p = javaClass.addProperty(Long.class, "id");
p.getField().addAnnotation(Id.class);
p.getField().addAnnotation(GeneratedValue.class);

I believe this would be simple to implement with the Property class acting as a simple wrapper around a Field (getField() ) and two Methods (getGetterMethod() / getSetterMethod() ).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the forge-issues mailing list