TargetQualifierMapKey { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((qualifier == null) ? 0 : qualifier.hashCode()); result = prime * result + ((targetName == null) ? 0 : targetName.hashCode()); return result; } TargetQualifierMapKey(FullQualifiedName targetName, String qualifier); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testHashMethod() { TargetQualifierMapKey key1 = new TargetQualifierMapKey(TARGET_NAME_1, "qualifier"); TargetQualifierMapKey key2 = new TargetQualifierMapKey(new FullQualifiedName("namespace", "name"), "qualifier"); assertEquals(key1.hashCode(), key1.hashCode()); key1 = new TargetQualifierMapKey(TARGET_NAME_1, "qualifier"); key2 = new TargetQualifierMapKey(new FullQualifiedName("namespace", "name"), "qualifier"); assertEquals(key1.hashCode(), key2.hashCode()); key1 = new TargetQualifierMapKey(TARGET_NAME_1, null); key2 = new TargetQualifierMapKey(TARGET_NAME_1, null); assertEquals(key1.hashCode(), key2.hashCode()); key1 = new TargetQualifierMapKey(TARGET_NAME_1, null); key2 = new TargetQualifierMapKey(new FullQualifiedName("namespace", "name"), null); assertEquals(key1.hashCode(), key2.hashCode()); key1 = new TargetQualifierMapKey(TARGET_NAME_1, "qualifier"); key2 = new TargetQualifierMapKey(TARGET_NAME_1, null); assertNotSame(key1.hashCode(), key2.hashCode()); key1 = new TargetQualifierMapKey(new FullQualifiedName("namespace", "name"), null); key2 = new TargetQualifierMapKey(new FullQualifiedName("namespace", "wrong"), null); assertNotSame(key1.hashCode(), key2.hashCode()); }