@Test public void testEquals() { HostRoute route1 = new DefaultHostRoute(nexthop1, destination1); HostRoute route2 = new DefaultHostRoute(nexthop1, destination1); HostRoute route3 = new DefaultHostRoute(nexthop2, destination2); new EqualsTester().addEqualityGroup(route1, route2) .addEqualityGroup(route3).testEquals(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultHostRoute) { final DefaultHostRoute other = (DefaultHostRoute) obj; return Objects.equals(this.nexthop, other.nexthop) && Objects.equals(this.destination, other.destination); } return false; }
DefaultHostRoute implements HostRoute { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultHostRoute) { final DefaultHostRoute other = (DefaultHostRoute) obj; return Objects.equals(this.nexthop, other.nexthop) && Objects.equals(this.destination, other.destination); } return false; } }
DefaultHostRoute implements HostRoute { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultHostRoute) { final DefaultHostRoute other = (DefaultHostRoute) obj; return Objects.equals(this.nexthop, other.nexthop) && Objects.equals(this.destination, other.destination); } return false; } DefaultHostRoute(IpAddress nexthop, IpPrefix destination); }
DefaultHostRoute implements HostRoute { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultHostRoute) { final DefaultHostRoute other = (DefaultHostRoute) obj; return Objects.equals(this.nexthop, other.nexthop) && Objects.equals(this.destination, other.destination); } return false; } DefaultHostRoute(IpAddress nexthop, IpPrefix destination); @Override IpAddress nexthop(); @Override IpPrefix destination(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
DefaultHostRoute implements HostRoute { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultHostRoute) { final DefaultHostRoute other = (DefaultHostRoute) obj; return Objects.equals(this.nexthop, other.nexthop) && Objects.equals(this.destination, other.destination); } return false; } DefaultHostRoute(IpAddress nexthop, IpPrefix destination); @Override IpAddress nexthop(); @Override IpPrefix destination(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }