PortInfo { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PortInfo portInfo = (PortInfo) o; if (port != portInfo.port) return false; if (tags != null ? !tags.equals(portInfo.tags) : portInfo.tags != null) return false; return true; } PortInfo(int port, Collection<String> tags); int getPort(); Collection<String> getTags(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { PortInfo a = new PortInfo(1234, Arrays.asList("foo")); PortInfo b = new PortInfo(1234, Arrays.asList("foo")); PortInfo c = new PortInfo(1234, Arrays.asList("foo", "bar")); PortInfo d = new PortInfo(12345, Arrays.asList("foo")); new EqualsTester() .addEqualityGroup(a, b) .addEqualityGroup(c) .addEqualityGroup(d).testEquals(); }