@Test public void testEquals() { ToDo td = new ToDo(); assertFalse(td.equals(null)); assertTrue(td.equals(td)); td.setTitle("this is a test task"); td.setCompleted(true); assertFalse(td.equals(new ToDo())); ToDo td2 = new ToDo(); td2.setTitle("this is a test task"); td2.setCompleted(true); assertTrue(td.equals(td2)); }
@Override public boolean equals(Object obj) { if(obj instanceof ToDo) { ToDo test = (ToDo)obj; boolean result = false; result = id == null ? id == test.getId() : id.equals(test.getId()); result &= title == null ? title == test.getTitle() : title.equals(test.getTitle()); result &= completed == test.isCompleted(); result &= order == test.getOrder(); return result; } else { return false; } }
ToDo { @Override public boolean equals(Object obj) { if(obj instanceof ToDo) { ToDo test = (ToDo)obj; boolean result = false; result = id == null ? id == test.getId() : id.equals(test.getId()); result &= title == null ? title == test.getTitle() : title.equals(test.getTitle()); result &= completed == test.isCompleted(); result &= order == test.getOrder(); return result; } else { return false; } } }
ToDo { @Override public boolean equals(Object obj) { if(obj instanceof ToDo) { ToDo test = (ToDo)obj; boolean result = false; result = id == null ? id == test.getId() : id.equals(test.getId()); result &= title == null ? title == test.getTitle() : title.equals(test.getTitle()); result &= completed == test.isCompleted(); result &= order == test.getOrder(); return result; } else { return false; } } ToDo(); }
ToDo { @Override public boolean equals(Object obj) { if(obj instanceof ToDo) { ToDo test = (ToDo)obj; boolean result = false; result = id == null ? id == test.getId() : id.equals(test.getId()); result &= title == null ? title == test.getTitle() : title.equals(test.getTitle()); result &= completed == test.isCompleted(); result &= order == test.getOrder(); return result; } else { return false; } } ToDo(); String getId(); void setId(String id); boolean isCompleted(); void setCompleted(boolean completed); String getTitle(); void setTitle(String title); int getOrder(); void setOrder(int order); @Override boolean equals(Object obj); @Override int hashCode(); }
ToDo { @Override public boolean equals(Object obj) { if(obj instanceof ToDo) { ToDo test = (ToDo)obj; boolean result = false; result = id == null ? id == test.getId() : id.equals(test.getId()); result &= title == null ? title == test.getTitle() : title.equals(test.getTitle()); result &= completed == test.isCompleted(); result &= order == test.getOrder(); return result; } else { return false; } } ToDo(); String getId(); void setId(String id); boolean isCompleted(); void setCompleted(boolean completed); String getTitle(); void setTitle(String title); int getOrder(); void setOrder(int order); @Override boolean equals(Object obj); @Override int hashCode();  }