Guest User

Untitled

a guest
Jan 21st, 2018
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. /*
  2.  * This software is provided "as is" and the authors
  3.  * hold no liability to any damage committed by the
  4.  * software to both physical and virtual objects.
  5.  *
  6.  * This software is "free" as in "freedom" and allows
  7.  * users to do whatever they please with it.
  8.  */
  9. package us.blaam;
  10.  
  11. import us.blaam.options.*;
  12.  
  13. /**
  14.  * Used to configure and build a server.
  15.  *
  16.  * @author Thomas G. P. Nappo <canownueasy@hotmail.com>
  17.  * @author Conner G. Davis <connergdavis@gmail.com>
  18.  * @author Ryley M. Kimmel <ryley.kimmel@live.com>
  19.  * @author Jordon Jensen <jwjens@live.com>
  20.  */
  21. public abstract class ServerFactory {
  22.  
  23.     /**
  24.      * The created server which <tt>ServerFactory</tt>
  25.      * implementations should configure.
  26.      */
  27.     private final Server server = new Server();
  28.  
  29.     /////////////////////////////////////////////////////////////////
  30.     //  /**
  31.     //   * Retrieves the factory's {@link #server}.
  32.     //   * @return The created server which is maintained by
  33.     //   * this <tt>ServerFactory</tt>. You should prefer to
  34.     //   * configure the server through factory methods rather
  35.     //   * than directly with the instance.
  36.     //   */
  37.     //  private final Server getServer() {
  38.     //      return server;
  39.     //  }
  40.     //////////// REMOVE NOTICE: Not needed //////////////////////////
  41.  
  42.     /**
  43.      * Configure this server object to your liking
  44.      * with the available options set.
  45.      */
  46.     public abstract void configureServer();
  47.  
  48.     /**
  49.      *
  50.      * @param option
  51.      */
  52.     protected final void setOption(ServerOption option) {
  53.         server.setOption(option);
  54.     }
  55.  
  56.     protected final void setPort(int port) {
  57.         server.setPort(port);
  58.     }
  59.  
  60.     protected final void setHostName(String hostName) {
  61.         server.setHostName(hostName);
  62.     }
  63.  
  64.     protected final void setName(String name) {
  65.         server.setName(name);
  66.     }
  67.    
  68.     public Server buildServer() {
  69.         configureServer();
  70.         return server;
  71.     }
  72.  
  73.     /**
  74.      *
  75.      * @author Thomas G. P. Nappo <canownueasy@hotmail.com>
  76.      * @author Conner G. Davis <connergdavis@gmail.com>
  77.      * @author Ryley M. Kimmel <ryley.kimmel@live.com>
  78.      * @author Jordon Jensen <jwjens@live.com>
  79.      */
  80.     protected enum ServerOption {
  81.  
  82.         DEBUG(new DebugOption());
  83.  
  84.         private final ServerOptionTask task;
  85.  
  86.         ServerOption(ServerOptionTask task) {
  87.             this.task = task;
  88.         }
  89.        
  90.         void runTask(Server server) {
  91.             task.run(server);
  92.         }
  93.  
  94.     }
  95.  
  96. }
Add Comment
Please, Sign In to add comment