@Test public void testHashCode() { UcteNodeCode node1 = new UcteNodeCode(UcteCountryCode.FR, "AAAAA", UcteVoltageLevelCode.VL_380, '1'); UcteNodeCode node2 = new UcteNodeCode(UcteCountryCode.BE, "BBBBB", UcteVoltageLevelCode.VL_380, '2'); UcteElementId id1 = new UcteElementId(node1, node2, '3'); UcteElementId id2 = new UcteElementId(node2, node1, '3'); UcteElementId id3 = new UcteElementId(node1, node2, '2'); new EqualsTester() .addEqualityGroup(id1) .addEqualityGroup(id2) .addEqualityGroup(id3) .testEquals(); id3.setOrderCode('3'); new EqualsTester() .addEqualityGroup(id1, id3) .addEqualityGroup(id2) .testEquals(); }
@Override public int hashCode() { return com.google.common.base.Objects.hashCode(nodeCode1, nodeCode2, orderCode); }
UcteElementId implements Comparable<UcteElementId> { @Override public int hashCode() { return com.google.common.base.Objects.hashCode(nodeCode1, nodeCode2, orderCode); } }
UcteElementId implements Comparable<UcteElementId> { @Override public int hashCode() { return com.google.common.base.Objects.hashCode(nodeCode1, nodeCode2, orderCode); } UcteElementId(UcteNodeCode nodeCode1, UcteNodeCode nodeCode2, char orderCode); }
UcteElementId implements Comparable<UcteElementId> { @Override public int hashCode() { return com.google.common.base.Objects.hashCode(nodeCode1, nodeCode2, orderCode); } UcteElementId(UcteNodeCode nodeCode1, UcteNodeCode nodeCode2, char orderCode); UcteNodeCode getNodeCode1(); UcteNodeCode getNodeCode2(); char getOrderCode(); void setOrderCode(char orderCode); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override int compareTo(UcteElementId ucteElementId); static Optional<UcteElementId> parseUcteElementId(String id); static boolean isUcteElementId(String id); }
UcteElementId implements Comparable<UcteElementId> { @Override public int hashCode() { return com.google.common.base.Objects.hashCode(nodeCode1, nodeCode2, orderCode); } UcteElementId(UcteNodeCode nodeCode1, UcteNodeCode nodeCode2, char orderCode); UcteNodeCode getNodeCode1(); UcteNodeCode getNodeCode2(); char getOrderCode(); void setOrderCode(char orderCode); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override int compareTo(UcteElementId ucteElementId); static Optional<UcteElementId> parseUcteElementId(String id); static boolean isUcteElementId(String id);  }