This was highlighted at the aquarium:
http://blogs.sun.com/roller/page/theaquarium?entry=adding_support_for_methodchaining_to
Once again, nice work, Hanson!
Hanson Char wrote:
> 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
>
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com