@Test public void equals() throws Exception { assertTrue("same message", message1.equals(message1)); assertTrue("different messages", message1.equals(message3)); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChatMessage that = (ChatMessage) o; if (messageId != that.messageId) return false; if (groupId != that.groupId) return false; if (userId != that.userId) return false; if (content != null ? !content .equals(that.content) : that.content != null) { return false; } return timeSent != null ? timeSent .equals(that.timeSent) : that.timeSent == null; }
ChatMessage { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChatMessage that = (ChatMessage) o; if (messageId != that.messageId) return false; if (groupId != that.groupId) return false; if (userId != that.userId) return false; if (content != null ? !content .equals(that.content) : that.content != null) { return false; } return timeSent != null ? timeSent .equals(that.timeSent) : that.timeSent == null; } }
ChatMessage { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChatMessage that = (ChatMessage) o; if (messageId != that.messageId) return false; if (groupId != that.groupId) return false; if (userId != that.userId) return false; if (content != null ? !content .equals(that.content) : that.content != null) { return false; } return timeSent != null ? timeSent .equals(that.timeSent) : that.timeSent == null; } ChatMessage(int groupId,
                       String content,
                       int userId,
                       String username,
                       Date timeSent); }
ChatMessage { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChatMessage that = (ChatMessage) o; if (messageId != that.messageId) return false; if (groupId != that.groupId) return false; if (userId != that.userId) return false; if (content != null ? !content .equals(that.content) : that.content != null) { return false; } return timeSent != null ? timeSent .equals(that.timeSent) : that.timeSent == null; } ChatMessage(int groupId,
                       String content,
                       int userId,
                       String username,
                       Date timeSent); int getMessageId(); void setMessageId(int messageId); int getGroupId(); void setGroupId(int groupId); String getContent(); void setContent(String content); int getUserId(); void setUserId(int userId); String getUsername(); void setUsername(String username); Date getTimeSent(); void setTimeSent(Date timeSent); boolean equalContent(ChatMessage o); @Override boolean equals(Object o); @Override int hashCode(); }
ChatMessage { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChatMessage that = (ChatMessage) o; if (messageId != that.messageId) return false; if (groupId != that.groupId) return false; if (userId != that.userId) return false; if (content != null ? !content .equals(that.content) : that.content != null) { return false; } return timeSent != null ? timeSent .equals(that.timeSent) : that.timeSent == null; } ChatMessage(int groupId,
                       String content,
                       int userId,
                       String username,
                       Date timeSent); int getMessageId(); void setMessageId(int messageId); int getGroupId(); void setGroupId(int groupId); String getContent(); void setContent(String content); int getUserId(); void setUserId(int userId); String getUsername(); void setUsername(String username); Date getTimeSent(); void setTimeSent(Date timeSent); boolean equalContent(ChatMessage o); @Override boolean equals(Object o); @Override int hashCode();  }