1 package org.apidesign.aserverinfo.builder;
3 import org.apidesign.aserverinfo.spi.NameProvider;
4 import org.apidesign.aserverinfo.spi.ResetHandler;
5 import org.apidesign.aserverinfo.spi.ShutdownHandler;
6 import org.apidesign.aserverinfo.spi.URLProvider;
9 * Cumulative factory methods for the builder pattern
11 * @author Jaroslav Tulach <jtulach@netbeans.org>
13 // BEGIN: aserverinfo.builder.factory
14 public class ServerInfo {
16 public static ServerInfo empty() {
17 return new ServerInfo(null, null, null, null);
20 public final ServerInfo nameProvider(NameProvider np) {
21 return new ServerInfo(np, this.url, this.reset, this.shutdown);
24 public final ServerInfo urlProvider(URLProvider up) {
25 return new ServerInfo(this.name, up, this.reset, this.shutdown);
27 public final ServerInfo reset(ResetHandler h) {
28 return new ServerInfo(this.name, this.url, h, this.shutdown);
30 /** All one needs to do when there is a need to add new
31 * style of creation is to add new method for a builder.
36 public final ServerInfo shutdown(ShutdownHandler handler) {
37 return new ServerInfo(this.name, this.url, this.reset, handler);
40 /** Creates the server connector based on current values in the
41 * info. Builder factory method.
42 * @return server connector
44 public final ServerConnector connect() {
45 return new ServerConnector(name, url, reset, shutdown);
47 // FINISH: aserverinfo.builder.factory
49 private final NameProvider name;
50 private final URLProvider url;
51 private final ResetHandler reset;
52 private final ShutdownHandler shutdown;
55 NameProvider name, URLProvider url,
56 ResetHandler reset, ShutdownHandler shutdown
61 this.shutdown = shutdown;