@Test public void testEquals() { String msg_A = "A Test Message"; ChiefControllerMessageEvent ccme_A_clusterwide = new ChiefControllerMessageEvent(); ccme_A_clusterwide.setMsg(msg_A); ccme_A_clusterwide.setClusterWideMessage(true); ChiefControllerMessageEvent ccme_A = new ChiefControllerMessageEvent(); ccme_A.setMsg(msg_A); ccme_A.setClusterWideMessage(false); assertFalse("same message, but one is clusterwide other not.", ccme_A.equals(ccme_A_clusterwide)); assertFalse("never equal with <null>", ccme_A.equals(null)); assertTrue("same objectRefs, clusterwide", ccme_A_clusterwide.equals(ccme_A_clusterwide)); assertTrue("same objectRefs", ccme_A.equals(ccme_A)); String msg_B = "A Test Message"; ChiefControllerMessageEvent ccme_B_clusterwide = new ChiefControllerMessageEvent(); ccme_B_clusterwide.setMsg(msg_B); ccme_B_clusterwide.setClusterWideMessage(true); ChiefControllerMessageEvent ccme_B = new ChiefControllerMessageEvent(); ccme_B.setMsg(msg_B); ccme_B.setClusterWideMessage(false); assertTrue("same message, and both clusterwide", ccme_A_clusterwide.equals(ccme_B_clusterwide)); assertTrue("same message", ccme_A.equals(ccme_B)); String msg_C = "another message"; ChiefControllerMessageEvent ccme_C_clusterwide = new ChiefControllerMessageEvent(); ccme_C_clusterwide.setMsg(msg_C); ccme_C_clusterwide.setClusterWideMessage(true); ChiefControllerMessageEvent ccme_C = new ChiefControllerMessageEvent(); ccme_C.setMsg(msg_C); ccme_C.setClusterWideMessage(false); assertFalse("not same message, but both clusterwide", ccme_C.equals(ccme_A)); assertFalse("not same message", ccme_C.equals(ccme_A)); }
@Override public boolean equals(Object event) { if (event != null && event instanceof ChiefControllerMessageEvent) { ChiefControllerMessageEvent other = (ChiefControllerMessageEvent) event; boolean sameCommand = other.getCommand().equals(this.getCommand()); String othersMsg = other.getMsg(); boolean sameMsg = ((msg == null && othersMsg == null)); sameMsg = sameMsg || (msg != null && msg.equals(othersMsg)); sameMsg = sameMsg || (othersMsg != null && othersMsg.equals(msg)); boolean sameClusterWide = clusterWideMessage == other.isClusterWideMessage(); return sameCommand && sameMsg && sameClusterWide; } return false; }
ChiefControllerMessageEvent extends MultiUserEvent { @Override public boolean equals(Object event) { if (event != null && event instanceof ChiefControllerMessageEvent) { ChiefControllerMessageEvent other = (ChiefControllerMessageEvent) event; boolean sameCommand = other.getCommand().equals(this.getCommand()); String othersMsg = other.getMsg(); boolean sameMsg = ((msg == null && othersMsg == null)); sameMsg = sameMsg || (msg != null && msg.equals(othersMsg)); sameMsg = sameMsg || (othersMsg != null && othersMsg.equals(msg)); boolean sameClusterWide = clusterWideMessage == other.isClusterWideMessage(); return sameCommand && sameMsg && sameClusterWide; } return false; } }
ChiefControllerMessageEvent extends MultiUserEvent { @Override public boolean equals(Object event) { if (event != null && event instanceof ChiefControllerMessageEvent) { ChiefControllerMessageEvent other = (ChiefControllerMessageEvent) event; boolean sameCommand = other.getCommand().equals(this.getCommand()); String othersMsg = other.getMsg(); boolean sameMsg = ((msg == null && othersMsg == null)); sameMsg = sameMsg || (msg != null && msg.equals(othersMsg)); sameMsg = sameMsg || (othersMsg != null && othersMsg.equals(msg)); boolean sameClusterWide = clusterWideMessage == other.isClusterWideMessage(); return sameCommand && sameMsg && sameClusterWide; } return false; } ChiefControllerMessageEvent(); private  ChiefControllerMessageEvent(String command); }
ChiefControllerMessageEvent extends MultiUserEvent { @Override public boolean equals(Object event) { if (event != null && event instanceof ChiefControllerMessageEvent) { ChiefControllerMessageEvent other = (ChiefControllerMessageEvent) event; boolean sameCommand = other.getCommand().equals(this.getCommand()); String othersMsg = other.getMsg(); boolean sameMsg = ((msg == null && othersMsg == null)); sameMsg = sameMsg || (msg != null && msg.equals(othersMsg)); sameMsg = sameMsg || (othersMsg != null && othersMsg.equals(msg)); boolean sameClusterWide = clusterWideMessage == other.isClusterWideMessage(); return sameCommand && sameMsg && sameClusterWide; } return false; } ChiefControllerMessageEvent(); private  ChiefControllerMessageEvent(String command); String getMsg(); void setMsg(String msg); @Override String toString(); @Override boolean equals(Object event); boolean isClusterWideMessage(); void setClusterWideMessage(boolean clusterWideMessage); @Override int hashCode(); }
ChiefControllerMessageEvent extends MultiUserEvent { @Override public boolean equals(Object event) { if (event != null && event instanceof ChiefControllerMessageEvent) { ChiefControllerMessageEvent other = (ChiefControllerMessageEvent) event; boolean sameCommand = other.getCommand().equals(this.getCommand()); String othersMsg = other.getMsg(); boolean sameMsg = ((msg == null && othersMsg == null)); sameMsg = sameMsg || (msg != null && msg.equals(othersMsg)); sameMsg = sameMsg || (othersMsg != null && othersMsg.equals(msg)); boolean sameClusterWide = clusterWideMessage == other.isClusterWideMessage(); return sameCommand && sameMsg && sameClusterWide; } return false; } ChiefControllerMessageEvent(); private  ChiefControllerMessageEvent(String command); String getMsg(); void setMsg(String msg); @Override String toString(); @Override boolean equals(Object event); boolean isClusterWideMessage(); void setClusterWideMessage(boolean clusterWideMessage); @Override int hashCode(); static final ChiefControllerMessageEvent CLEAR; static final String CHANGED_EVENT_CMD; }