diff -r b704be5f8463 -r 40cabcdcd2be samples/aserverinfo/src/org/apidesign/aserverinfo/builder/ServerInfo.java --- a/samples/aserverinfo/src/org/apidesign/aserverinfo/builder/ServerInfo.java Sat Nov 15 13:12:46 2008 +0100 +++ b/samples/aserverinfo/src/org/apidesign/aserverinfo/builder/ServerInfo.java Thu Oct 30 21:30:10 2014 +0100 @@ -6,7 +6,7 @@ import org.apidesign.aserverinfo.spi.URLProvider; /** - * Cumulative factory methods for the builder pattern + * Mutable "setter" methods for the builder pattern. * * @author Jaroslav Tulach */ @@ -18,15 +18,21 @@ } public final ServerInfo nameProvider(NameProvider np) { - return new ServerInfo(np, this.url, this.reset, this.shutdown); + this.name = np; + return this; } public final ServerInfo urlProvider(URLProvider up) { - return new ServerInfo(this.name, up, this.reset, this.shutdown); + this.url = up; + return this; } + // BEGIN: aserverinfo.builder.setter public final ServerInfo reset(ResetHandler h) { - return new ServerInfo(this.name, this.url, h, this.shutdown); + this.reset = h; + return this; } + // END: aserverinfo.builder.setter + /** All one needs to do when there is a need to add new * style of creation is to add new method for a builder. * @param handler @@ -34,7 +40,8 @@ * @since 2.0 */ public final ServerInfo shutdown(ShutdownHandler handler) { - return new ServerInfo(this.name, this.url, this.reset, handler); + this.shutdown = handler; + return this; } /** Creates the server connector based on current values in the @@ -46,10 +53,10 @@ } // FINISH: aserverinfo.builder.factory - private final NameProvider name; - private final URLProvider url; - private final ResetHandler reset; - private final ShutdownHandler shutdown; + private NameProvider name; + private URLProvider url; + private ResetHandler reset; + private ShutdownHandler shutdown; private ServerInfo( NameProvider name, URLProvider url,