ChiefControllerMessageEvent extends MultiUserEvent { @Override public int hashCode() { int hc = 5; int hcMul = 7; hc = hc * hcMul + (clusterWideMessage ? 0 : 1); hc = hc * hcMul + (msg == null ? 0 : msg.hashCode()); return hc * hcMul + super.hashCode(); } 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; }
@Test public void testHashCode() { 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); assertTrue("MUST BE SAME HASHCODE: same objectRefs, clusterwide", ccme_A_clusterwide.hashCode() == ccme_A_clusterwide.hashCode()); assertTrue("MUST BE SAME HASHCODE: same objectRefs, clusterwide", ccme_A_clusterwide.hashCode() == ccme_A_clusterwide.hashCode()); assertTrue("MUST BE SAME HASHCODE: same objectRefs", ccme_A.hashCode() == ccme_A.hashCode()); assertTrue("MUST BE SAME HASHCODE: same objectRefs", ccme_A.hashCode() == ccme_A.hashCode()); 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("MUST BE SAME HASHCODE: same message, and both clusterwide", ccme_A_clusterwide.hashCode() == ccme_B_clusterwide.hashCode()); assertTrue("MUST BE SAME HASHCODE: same message, and both clusterwide", ccme_A_clusterwide.hashCode() == ccme_B_clusterwide.hashCode()); assertTrue("MUST BE SAME HASHCODE: same message", ccme_A.hashCode() == ccme_B.hashCode()); assertTrue("MUST BE SAME HASHCODE: same message", ccme_A.hashCode() == ccme_B.hashCode()); }