Google
 
Web unafbapune.blogspot.com

Wednesday, January 11, 2006

 

JWSDP Wish List

It would be nice if JAXB supports:

Comments:
Could you expand more on what you mean by "command chaining"?

(If you can file that as an RFE on http://jaxb.dev.java.net/, that would be appreciated.)
 
This comment has been removed by a blog administrator.
 
What I mean by "command chaining" is basically method chaining or what Martin Fowler refers to as FluentInterface.

So instead of or in addition to the standard JavaBean way of returning void in the setter method, the setter method may return "this".

Example, instead of/in additon to:

USAddress address = new USAddress();

// set properties on it
address.setName( name );
address.setStreet( street );
address.setCity( city );
address.setState( state );
address.setZip( new BigDecimal( zip ) );

The chaining API will allow the client code to do something like:

USAddress address = new USAddress()
.setName(name)
.setStreet(street)
.setCity(city)
.setState(state)
.setZip(new BigDeciaml(zip));

I know this violates the JavaBean pattern. So maybe instead of changing the return type of the setter method, we may have some mutator method using prefix such as "with", to become something like:

USAddress address = new USAddress()
.withName(name)
.withStreet(street)
.withCity(city)
.withState(state)
.withZip(new BigDeciaml(zip));

And then provide a switch to xjc for the user to choose (ie prefer JavaBean pattern or chaining API.)
 
Also submitted as an RFE (jaxb Issue 115) to http://jaxb.dev.java.net/
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?