AbstractCollectionCacheKeyGenerator extends AbstractCacheKeyGenerator { @Override public boolean equals(Object other) { if (this == other) { return true; } return other != null && getClass().equals(other.getClass()) && isProvisional() == ((AbstractCollectionCacheKeyGenerator<?>)other).isProvisional() && ( getCollection() != null && getCollection().equals(((AbstractCollectionCacheKeyGenerator<?>)other).getCollection()) || getCollection() == null && ((AbstractCollectionCacheKeyGenerator<?>)other).getCollection() == null ); }  ICacheKeyGenerator combine(ICacheKeyGenerator otherKeyGen); @Override boolean equals(Object other); @Override int hashCode();  }
@Test public void testEquals() { TestCollectionCacheKeyGenerator gen1 = new TestCollectionCacheKeyGenerator(new HashSet<String>(Arrays.asList("a", "b")), false); TestCollectionCacheKeyGenerator gen2 = new TestCollectionCacheKeyGenerator(new HashSet<String>(Arrays.asList("a", "b")), false); TestCollectionCacheKeyGenerator gen3 = new TestCollectionCacheKeyGenerator(new HashSet<String>(Arrays.asList("a", "b")), true); TestCollectionCacheKeyGenerator gen4 = new TestCollectionCacheKeyGenerator(new HashSet<String>(Arrays.asList("b", "c")), false); TestCollectionCacheKeyGenerator nulcol1 = new TestCollectionCacheKeyGenerator(null, true); TestCollectionCacheKeyGenerator nulcol2 = new TestCollectionCacheKeyGenerator(null, true); TestCollectionCacheKeyGenerator nulcol3 = new TestCollectionCacheKeyGenerator(null, false); Assert.assertFalse(gen1.equals(null)); Assert.assertTrue(gen1.equals(gen1)); Assert.assertFalse(gen1.equals(null)); Assert.assertFalse(gen1.equals(new Object())); Assert.assertTrue(gen1.equals(gen2)); Assert.assertFalse(gen1.equals(gen3)); Assert.assertFalse(gen1.equals(gen4)); Assert.assertTrue(nulcol1.equals(nulcol1)); Assert.assertTrue(nulcol1.equals(nulcol2)); Assert.assertFalse(nulcol1.equals(nulcol3)); Assert.assertFalse(gen1.equals(nulcol1)); Assert.assertFalse(gen1.equals(nulcol3)); Assert.assertFalse(gen3.equals(nulcol1)); Assert.assertFalse(gen3.equals(nulcol3)); }