Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make JAXB setters return "this", so that they are chainable?

Tags:

java

xml

jaxb

I am generating the Java from XML. The setters all return void. If they returned "this", then they could be called in a chain. Is there a way ( an easy way ) to make it generate setters that "return this;" ?

like image 410
Nick Perkins Avatar asked Jul 18 '14 21:07

Nick Perkins


1 Answers

Take a look at the JAXB Fluent API Plugin.

 USAddress address = new USAddress()
            .withName(name)
            .withStreet(street)
            .withCity(city)
            .withState(state)
            .withZip(new BigDecimal(zip));
like image 121
lexicore Avatar answered Sep 30 '22 03:09

lexicore