jtulach@294: package org.apidesign.aserverinfo.builder; jtulach@294: jtulach@294: import org.apidesign.aserverinfo.spi.NameProvider; jtulach@294: import org.apidesign.aserverinfo.spi.ResetHandler; jtulach@294: import org.apidesign.aserverinfo.spi.ShutdownHandler; jtulach@294: import org.apidesign.aserverinfo.spi.URLProvider; jtulach@294: jtulach@294: /** jtulach@300: * Cumulative factory methods for the builder pattern jtulach@294: * jtulach@294: * @author Jaroslav Tulach jtulach@294: */ jtulach@300: // BEGIN: aserverinfo.builder.factory jtulach@294: public class ServerInfo { jtulach@294: jtulach@294: public static ServerInfo empty() { jtulach@294: return new ServerInfo(null, null, null, null); jtulach@294: } jtulach@294: jtulach@294: public final ServerInfo nameProvider(NameProvider np) { jtulach@294: return new ServerInfo(np, this.url, this.reset, this.shutdown); jtulach@294: } jtulach@294: jtulach@294: public final ServerInfo urlProvider(URLProvider up) { jtulach@294: return new ServerInfo(this.name, up, this.reset, this.shutdown); jtulach@294: } jtulach@294: public final ServerInfo reset(ResetHandler h) { jtulach@294: return new ServerInfo(this.name, this.url, h, this.shutdown); jtulach@294: } jtulach@294: /** All one needs to do when there is a need to add new jtulach@294: * style of creation is to add new method for a builder. jtulach@294: * @param handler jtulach@294: * @return jtulach@294: * @since 2.0 jtulach@294: */ jtulach@294: public final ServerInfo shutdown(ShutdownHandler handler) { jtulach@294: return new ServerInfo(this.name, this.url, this.reset, handler); jtulach@294: } jtulach@294: jtulach@294: /** Creates the server connector based on current values in the jtulach@294: * info. Builder factory method. jtulach@294: * @return server connector jtulach@294: */ jtulach@294: public final ServerConnector connect() { jtulach@294: return new ServerConnector(name, url, reset, shutdown); jtulach@294: } jtulach@300: // FINISH: aserverinfo.builder.factory jtulach@294: jtulach@294: private final NameProvider name; jtulach@294: private final URLProvider url; jtulach@294: private final ResetHandler reset; jtulach@294: private final ShutdownHandler shutdown; jtulach@294: jtulach@294: private ServerInfo( jtulach@294: NameProvider name, URLProvider url, jtulach@294: ResetHandler reset, ShutdownHandler shutdown jtulach@294: ) { jtulach@294: this.name = name; jtulach@294: this.url = url; jtulach@294: this.reset = reset; jtulach@294: this.shutdown = shutdown; jtulach@294: } jtulach@294: jtulach@294: }