@Test public void testListEquals() { String target1 = "ptcp:6653:192.168.1.1"; ControllerInfo controllerInfo1 = new ControllerInfo(target1); String target2 = "ptcp:6653:192.168.1.1"; ControllerInfo controllerInfo2 = new ControllerInfo(target2); String target3 = "tcp:192.168.1.1:6653"; ControllerInfo controllerInfo3 = new ControllerInfo(target3); String target4 = "tcp:192.168.1.1:6653"; ControllerInfo controllerInfo4 = new ControllerInfo(target4); List<ControllerInfo> list1 = new ArrayList<>(Arrays.asList(controllerInfo1, controllerInfo3)); List<ControllerInfo> list2 = new ArrayList<>(Arrays.asList(controllerInfo2, controllerInfo4)); assertTrue("wrong equals list method", list1.equals(list2)); }
@Override public boolean equals(Object toBeCompared) { if (toBeCompared instanceof ControllerInfo) { ControllerInfo controllerInfo = (ControllerInfo) toBeCompared; if (controllerInfo.type().equals(this.type) && controllerInfo.ip().equals(this.ip()) && controllerInfo.port() == this.port) { return true; } } return false; }
ControllerInfo { @Override public boolean equals(Object toBeCompared) { if (toBeCompared instanceof ControllerInfo) { ControllerInfo controllerInfo = (ControllerInfo) toBeCompared; if (controllerInfo.type().equals(this.type) && controllerInfo.ip().equals(this.ip()) && controllerInfo.port() == this.port) { return true; } } return false; } }
ControllerInfo { @Override public boolean equals(Object toBeCompared) { if (toBeCompared instanceof ControllerInfo) { ControllerInfo controllerInfo = (ControllerInfo) toBeCompared; if (controllerInfo.type().equals(this.type) && controllerInfo.ip().equals(this.ip()) && controllerInfo.port() == this.port) { return true; } } return false; } ControllerInfo(IpAddress ip, int port, String type);  ControllerInfo(String target); }
ControllerInfo { @Override public boolean equals(Object toBeCompared) { if (toBeCompared instanceof ControllerInfo) { ControllerInfo controllerInfo = (ControllerInfo) toBeCompared; if (controllerInfo.type().equals(this.type) && controllerInfo.ip().equals(this.ip()) && controllerInfo.port() == this.port) { return true; } } return false; } ControllerInfo(IpAddress ip, int port, String type);  ControllerInfo(String target); IpAddress ip(); int port(); String type(); String target(); @Override int hashCode(); @Override boolean equals(Object toBeCompared); }
ControllerInfo { @Override public boolean equals(Object toBeCompared) { if (toBeCompared instanceof ControllerInfo) { ControllerInfo controllerInfo = (ControllerInfo) toBeCompared; if (controllerInfo.type().equals(this.type) && controllerInfo.ip().equals(this.ip()) && controllerInfo.port() == this.port) { return true; } } return false; } ControllerInfo(IpAddress ip, int port, String type);  ControllerInfo(String target); IpAddress ip(); int port(); String type(); String target(); @Override int hashCode(); @Override boolean equals(Object toBeCompared);  }