@Test public void equalsReturnsTrueWhenOtherHasTheSameMemoryReference() { Link underTest = new Link(edgeMock, 2, 1); assertThat(underTest.equals(underTest), is(true)); }
@Override public boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (!(other instanceof Link)) { return false; } Link otherLink = (Link) other; return otherLink.getType().equals(type) && ( (otherLink.getSource() == source && otherLink.getTarget() == target) || (otherLink.getSource() == target && otherLink.getTarget() == source)); }
Link { @Override public boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (!(other instanceof Link)) { return false; } Link otherLink = (Link) other; return otherLink.getType().equals(type) && ( (otherLink.getSource() == source && otherLink.getTarget() == target) || (otherLink.getSource() == target && otherLink.getTarget() == source)); } }
Link { @Override public boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (!(other instanceof Link)) { return false; } Link otherLink = (Link) other; return otherLink.getType().equals(type) && ( (otherLink.getSource() == source && otherLink.getTarget() == target) || (otherLink.getSource() == target && otherLink.getTarget() == source)); } Link(Edge edge, int source, int target); }
Link { @Override public boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (!(other instanceof Link)) { return false; } Link otherLink = (Link) other; return otherLink.getType().equals(type) && ( (otherLink.getSource() == source && otherLink.getTarget() == target) || (otherLink.getSource() == target && otherLink.getTarget() == source)); } Link(Edge edge, int source, int target); int getSource(); int getTarget(); String getType(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
Link { @Override public boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (!(other instanceof Link)) { return false; } Link otherLink = (Link) other; return otherLink.getType().equals(type) && ( (otherLink.getSource() == source && otherLink.getTarget() == target) || (otherLink.getSource() == target && otherLink.getTarget() == source)); } Link(Edge edge, int source, int target); int getSource(); int getTarget(); String getType(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }