/*
* 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");
+ }
}