@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((block == null) ? 0 : block.hashCode()); result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); result = prime * result + ((storageUuid == null) ? 0 : storageUuid.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((block == null) ? 0 : block.hashCode()); result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); result = prime * result + ((storageUuid == null) ? 0 : storageUuid.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((block == null) ? 0 : block.hashCode()); result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); result = prime * result + ((storageUuid == null) ? 0 : storageUuid.hashCode()); return result; }
@Test public void testHashcode() { // Different pools, same block id -> different hashcode assertNotEquals( new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode(), new ExtendedBlock(POOL_B, BLOCK_1_GS1).hashCode()); // Same pool, different block id -> different hashcode assertNotEquals( new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode(), new ExtendedBlock(POOL_A, BLOCK_2_GS1).hashCode()); // Same block -> same hashcode assertEquals( new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode(), new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode()); }
@Test public void testHashcode() { // Different pools, same block id -> different hashcode assertNotEquals( new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode(), new ExtendedBlock(POOL_B, BLOCK_1_GS1).hashCode()); // Same pool, different block id -> different hashcode assertNotEquals( new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode(), new ExtendedBlock(POOL_A, BLOCK_2_GS1).hashCode()); // Same block -> same hashcode assertEquals( new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode(), new ExtendedBlock(POOL_A, BLOCK_1_GS1).hashCode()); }