users@jaxb.java.net

Re: [Issue 115] Supports Method Chaining/ FluentAPI

From: Hanson Char <hanson.char_at_gmail.com>
Date: Wed, 25 Jan 2006 21:40:17 -0800

Hi,

I am trying to write a xjc plugin to support a fluent api in addition to the
default (JavaBean) setter methods.

The initial idea is simply to add a "with*" method to the generated class
(via JDefinedClass.method) for every "set*" method encountered, with the
only difference of returning the class instance, instead of void.

In creating a "with*" method, I am trying to clone across the modifiers of
the corresponding setter method. These modifiers can be accessed via
JMethod.getMods() which is of type JMods. However, although JMods has an
internal "mods" int field, there seems no API to gain access to it. (I
don't want to resort to reflection to break the API.) Meanwhile, the
required "mods" parameter of JDefinedClass.method is an int.

Any chance this can be changed ?
ie.

   1. Either JDefinedClass.method should allow passing in a JMods instead
   of int for the modifiers; or
   2. JMods should provide a getter method to its internal "mods".

Does this make sense ?

Hanson