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@337: * Mutable "setter" 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@337: this.name = np; jtulach@337: return this; jtulach@294: } jtulach@294: jtulach@294: public final ServerInfo urlProvider(URLProvider up) { jtulach@337: this.url = up; jtulach@337: return this; jtulach@294: } jtulach@337: // BEGIN: aserverinfo.builder.setter jtulach@294: public final ServerInfo reset(ResetHandler h) { jtulach@337: this.reset = h; jtulach@337: return this; jtulach@294: } jtulach@337: // END: aserverinfo.builder.setter jtulach@337: 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@337: this.shutdown = handler; jtulach@337: return this; 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@337: private NameProvider name; jtulach@337: private URLProvider url; jtulach@337: private ResetHandler reset; jtulach@337: private 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: }