Hi.

For all you code generators, there's a new open source project CodeModel available on dev.java.net:

https://codemodel.dev.java.net

The CodeModel allows you generate lexically correct Java code as Java objects which can be afterwords written to disk as Java or resource files.

The CodeModel was the part of JAXB RI, but now it's moved to the standalone project (thanks to Kohsuke Kawaguchi of Sun and Gregory Kick

Here's a usage example:

final JMethod objectEquals = theClass.method(JMod.PUBLIC, theClass.owner().BOOLEAN, "equals");
    {
      final JVar object = objectEquals.param(Object.class, "object");
      final JBlock body = objectEquals.body();

      
body._if(JOp.not(object._instanceof(theClass)))._then()._return(JExpr.FALSE);
      body._if(JExpr._this().eq(object))._then()._return(JExpr.TRUE);

      final JVar equalsBuilder = body.decl(
          JMod.FINAL,
          theClass.owner().ref(EqualsBuilder.class),
          "equalsBuilder",
          JExpr._new(theClass.owner().ref(getEqualsBuilderClass())));
      body.invoke("equals").arg(object).arg(equalsBuilder);
      body._return(equalsBuilder.invoke("isEquals"));
    }

Bye.
/lexi

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to