Wednesday, January 11, 2006
JWSDP Wish List
It would be nice if JAXB supports:
- Command chaining in setting the content model;
- Supports failfast validation so setting an invalid value causes an exception instead of delaying the process to validate-on-demand or unmarshalling;
- Supports Java 5 generics in the generated classes; (Actually this is supported in JAXB 2.0 but not JAXB 1.6.)
- Uses Java 5 enum instead of simulating a type safe enum; (This is also supported in JAXB 2.0)
Comments:
<< Home
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.)
(If you can file that as an RFE on http://jaxb.dev.java.net/, that would be appreciated.)
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.)
Post a Comment
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.)
<< Home