Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This method implements a very weak notion of equivalence, where as long as the PersonCard's person and id are equal, the object is equal. However, such a weak notion of equivalence goes against the spirit of the UI architecture, which states that all UiParts represent a distinct part of the UI, and more importantly, wraps a subgraph of the JavaFX scene graph (accessible via UiPart#getRoot()). As such, just because two PersonCards A and B happen to contain the same ID and person value, doesn't mean they are "equal", because they may be holding different JavaFX scene graph objects. Any JavaFX-related operations on PersonCard A may give a different result to PersonCard B. Furthermore, this implementation of PersonCard#equals(Object) isn't actually used, not even by test code. It was introduced in baa5988 (PersonListPanelHandle: Update methods, 2017-07-14) so that one could do the following to assert that a certain PersonCard was selected: private void assertCardSelected(Index index) { PersonCard selectedCard = getPersonListPanel().getSelectedCard().get(); assertEquals(getPersonListPanel().getCard(index.getZeroBased()), selectedCard); } where the assertEquals() would then call PersonCard#equals(Object). However, since 04a675f (PersonListPanelHandle: Update getSelectedCard(), 2017-07-20) this pattern of code has been (rightly) removed, with test code preferring to compare what is actually displayed on the PersonCard, rather than using PersonCard#equals(Object): /** * Asserts that {@code actualCard} displays the same values as {@code expectedCard}. */ public static void assertCardEquals(PersonCardHandle expectedCard, PersonCardHandle actualCard) { assertEquals(expectedCard.getId(), actualCard.getId()); assertEquals(expectedCard.getAddress(), actualCard.getAddress()); assertEquals(expectedCard.getEmail(), actualCard.getEmail()); assertEquals(expectedCard.getName(), actualCard.getName()); assertEquals(expectedCard.getPhone(), actualCard.getPhone()); assertEquals(expectedCard.getTags(), actualCard.getTags()); } PersonCard#equals(Object) was, however, not removed then. So let's remove it now.
- Loading branch information