1.1 --- a/samples/aserverinfo/src/org/apidesign/aserverinfo/builder/ServerInfo.java Sat Nov 15 13:12:46 2008 +0100
1.2 +++ b/samples/aserverinfo/src/org/apidesign/aserverinfo/builder/ServerInfo.java Thu Oct 30 21:30:10 2014 +0100
1.3 @@ -6,7 +6,7 @@
1.4 import org.apidesign.aserverinfo.spi.URLProvider;
1.5
1.6 /**
1.7 - * Cumulative factory methods for the builder pattern
1.8 + * Mutable "setter" methods for the builder pattern.
1.9 *
1.10 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.11 */
1.12 @@ -18,15 +18,21 @@
1.13 }
1.14
1.15 public final ServerInfo nameProvider(NameProvider np) {
1.16 - return new ServerInfo(np, this.url, this.reset, this.shutdown);
1.17 + this.name = np;
1.18 + return this;
1.19 }
1.20
1.21 public final ServerInfo urlProvider(URLProvider up) {
1.22 - return new ServerInfo(this.name, up, this.reset, this.shutdown);
1.23 + this.url = up;
1.24 + return this;
1.25 }
1.26 + // BEGIN: aserverinfo.builder.setter
1.27 public final ServerInfo reset(ResetHandler h) {
1.28 - return new ServerInfo(this.name, this.url, h, this.shutdown);
1.29 + this.reset = h;
1.30 + return this;
1.31 }
1.32 + // END: aserverinfo.builder.setter
1.33 +
1.34 /** All one needs to do when there is a need to add new
1.35 * style of creation is to add new method for a builder.
1.36 * @param handler
1.37 @@ -34,7 +40,8 @@
1.38 * @since 2.0
1.39 */
1.40 public final ServerInfo shutdown(ShutdownHandler handler) {
1.41 - return new ServerInfo(this.name, this.url, this.reset, handler);
1.42 + this.shutdown = handler;
1.43 + return this;
1.44 }
1.45
1.46 /** Creates the server connector based on current values in the
1.47 @@ -46,10 +53,10 @@
1.48 }
1.49 // FINISH: aserverinfo.builder.factory
1.50
1.51 - private final NameProvider name;
1.52 - private final URLProvider url;
1.53 - private final ResetHandler reset;
1.54 - private final ShutdownHandler shutdown;
1.55 + private NameProvider name;
1.56 + private URLProvider url;
1.57 + private ResetHandler reset;
1.58 + private ShutdownHandler shutdown;
1.59
1.60 private ServerInfo(
1.61 NameProvider name, URLProvider url,