@Test public void testEquals() { final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); final TenantId tenantId = TenantId.tenantId("1"); final String name = "PortPair1"; final String description = "PortPair1"; final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1"; final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345"; DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder(); final PortPair portPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name) .setDescription(description).setIngress(ingress).setEgress(egress).build(); portPairBuilder = new DefaultPortPair.Builder(); final PortPair samePortPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name) .setDescription(description).setIngress(ingress).setEgress(egress).build(); final PortPairId portPairId2 = PortPairId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae"); final TenantId tenantId2 = TenantId.tenantId("2"); final String name2 = "PortPair2"; final String description2 = "PortPair2"; final String ingress2 = "d5555555-24fc-4fae-af4b-321c5e2eb3d1"; final String egress2 = "a6666666-4a56-2a6e-cd3a-9dee4e2ec345"; portPairBuilder = new DefaultPortPair.Builder(); final PortPair portPair2 = portPairBuilder.setId(portPairId2).setTenantId(tenantId2).setName(name2) .setDescription(description2).setIngress(ingress2).setEgress(egress2).build(); new EqualsTester().addEqualityGroup(portPair1, samePortPair1).addEqualityGroup(portPair2).testEquals(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultPortPair) { DefaultPortPair that = (DefaultPortPair) obj; return Objects.equals(portPairId, that.portPairId) && Objects.equals(tenantId, that.tenantId) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(ingress, that.ingress) && Objects.equals(egress, that.egress); } return false; }
DefaultPortPair implements PortPair { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultPortPair) { DefaultPortPair that = (DefaultPortPair) obj; return Objects.equals(portPairId, that.portPairId) && Objects.equals(tenantId, that.tenantId) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(ingress, that.ingress) && Objects.equals(egress, that.egress); } return false; } }
DefaultPortPair implements PortPair { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultPortPair) { DefaultPortPair that = (DefaultPortPair) obj; return Objects.equals(portPairId, that.portPairId) && Objects.equals(tenantId, that.tenantId) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(ingress, that.ingress) && Objects.equals(egress, that.egress); } return false; } private  DefaultPortPair(PortPairId portPairId, TenantId tenantId,
                            String name, String description,
                            String ingress, String egress); }
DefaultPortPair implements PortPair { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultPortPair) { DefaultPortPair that = (DefaultPortPair) obj; return Objects.equals(portPairId, that.portPairId) && Objects.equals(tenantId, that.tenantId) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(ingress, that.ingress) && Objects.equals(egress, that.egress); } return false; } private  DefaultPortPair(PortPairId portPairId, TenantId tenantId,
                            String name, String description,
                            String ingress, String egress); @Override PortPairId portPairId(); @Override TenantId tenantId(); @Override String name(); @Override String description(); @Override String ingress(); @Override String egress(); @Override int hashCode(); @Override boolean equals(Object obj); @Override boolean exactMatch(PortPair portPair); @Override String toString(); static Builder builder(); }
DefaultPortPair implements PortPair { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultPortPair) { DefaultPortPair that = (DefaultPortPair) obj; return Objects.equals(portPairId, that.portPairId) && Objects.equals(tenantId, that.tenantId) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(ingress, that.ingress) && Objects.equals(egress, that.egress); } return false; } private  DefaultPortPair(PortPairId portPairId, TenantId tenantId,
                            String name, String description,
                            String ingress, String egress); @Override PortPairId portPairId(); @Override TenantId tenantId(); @Override String name(); @Override String description(); @Override String ingress(); @Override String egress(); @Override int hashCode(); @Override boolean equals(Object obj); @Override boolean exactMatch(PortPair portPair); @Override String toString(); static Builder builder();  }