@Test public void testEquals() { PaintMap m1 = new PaintMap(); PaintMap m2 = new PaintMap(); assertEquals(m1, m1); assertEquals(m1, m2); assertFalse(m1.equals(null)); assertFalse(m1.equals("ABC")); m1.put("K1", Color.RED); assertFalse(m1.equals(m2)); m2.put("K1", Color.RED); assertEquals(m1, m2); m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(m1.equals(m2)); m2.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertEquals(m1, m2); m1.put("K2", null); assertFalse(m1.equals(m2)); m2.put("K2", null); assertEquals(m1, m2); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set<Comparable> keys = this.store.keySet(); for (Comparable key : keys) { Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; }
PaintMap implements Cloneable, Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set<Comparable> keys = this.store.keySet(); for (Comparable key : keys) { Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; } }
PaintMap implements Cloneable, Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set<Comparable> keys = this.store.keySet(); for (Comparable key : keys) { Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; } PaintMap(); }
PaintMap implements Cloneable, Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set<Comparable> keys = this.store.keySet(); for (Comparable key : keys) { Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; } PaintMap(); Paint getPaint(Comparable key); boolean containsKey(Comparable key); void put(Comparable key, Paint paint); void clear(); @Override boolean equals(Object obj); @Override Object clone(); }
PaintMap implements Cloneable, Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set<Comparable> keys = this.store.keySet(); for (Comparable key : keys) { Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; } PaintMap(); Paint getPaint(Comparable key); boolean containsKey(Comparable key); void put(Comparable key, Paint paint); void clear(); @Override boolean equals(Object obj); @Override Object clone();  }