MessageServerControl: add toString(), missing javadocs
authorEddie <dev@fun2be.me>
Sat, 6 Jun 2015 09:53:47 +0000 (10:53 +0100)
committerEddie <dev@fun2be.me>
Sat, 6 Jun 2015 09:53:47 +0000 (10:53 +0100)
src/uk/ac/ntu/n0521366/wsyd/libs/message/MessageServerControl.java

index fdf7f98..eaec994 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * The MIT License
  *
- * Copyright 2015 eddie.
+ * Copyright 2015 Eddie Berrisford-Lynch <dev@fun2be.me>.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
 package uk.ac.ntu.n0521366.wsyd.libs.message;
 
 /**
- *
- * @author eddie
+ * Encapsulates RESTART or EXIT commands.
+ * 
+ * Sent by ServerManagement to ServerSocial and ServerChat
+ * 
+ * @author Eddie Berrisford-Lynch <dev@fun2be.me>
  */
 public class MessageServerControl extends MessageAbstract {
+    /**
+     * Exit control.
+     */
     public enum EXIT { NO, YES };
+    /**
+     * Restart control.
+     */
     public enum RESTART { NO, YES };
     
-    public static final String _type = "ServerControl";
+    /**
+     * Message type.
+     */
+    private static final String _type = "ServerControl";
     
+    /**
+     * Exit request.
+     */
     public EXIT exitReq;
     
+    /**
+     * Restart request.
+     */
     public RESTART restartReq;
     
+    /** 
+     *  The Message Class type.
+     * 
+     * @return Message type
+     */
     public static String getType()
     {
         return _type;
     }
     
+    /**
+     * The purpose of this class of message.
+     * 
+     * @return "ServerControl"
+     */
     @Override
     public String getMessageType()
     {
         return _type;
     }
     
-    public MessageServerControl(EXIT exit, RESTART restart)
-    {
+    /**
+     * Create a control request.
+     * @param exit true if target should exit
+     * @param restart true if target should restart
+     */
+    public MessageServerControl(EXIT exit, RESTART restart) {
         super();
         this.exitReq = exit;
         this.restartReq = restart;
     }
+    
+    /**
+     * Get a human readable representation of the control request.
+     * @return printable representation
+     */
+    @Override
+    public String toString() {
+        return getMessageType() +
+               " Restart: " + (restartReq == RESTART.YES ? "Yes" : "No") +
+               " Exit: " +(exitReq == EXIT.YES ? "Yes" : "No");
+    }
 }