diff options
author | Artur Signell <artur@vaadin.com> | 2015-12-30 07:56:33 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-01-05 14:06:34 +0200 |
commit | a4269bca4b9d96257da8136413068093d53861b5 (patch) | |
tree | 588f8e360f7115e1f47df3c69c033607d1dbc254 /server/src/com/vaadin/data/util | |
parent | a5cfcdad652b469125989a956725548678cb36bc (diff) | |
download | vaadin-framework-a4269bca4b9d96257da8136413068093d53861b5.tar.gz vaadin-framework-a4269bca4b9d96257da8136413068093d53861b5.zip |
Make GeneratedPropertyItem equals self (#19426)
Change-Id: Ia9a8d56a3702d182b7fb79e3676844c9a10093a6
Diffstat (limited to 'server/src/com/vaadin/data/util')
-rw-r--r-- | server/src/com/vaadin/data/util/GeneratedPropertyContainer.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/server/src/com/vaadin/data/util/GeneratedPropertyContainer.java b/server/src/com/vaadin/data/util/GeneratedPropertyContainer.java index f50ff01fc6..cea1e27ee9 100644 --- a/server/src/com/vaadin/data/util/GeneratedPropertyContainer.java +++ b/server/src/com/vaadin/data/util/GeneratedPropertyContainer.java @@ -165,6 +165,39 @@ public class GeneratedPropertyContainer extends AbstractContainer implements throw new UnsupportedOperationException( "GeneratedPropertyItem does not support removing properties"); } + + /** + * Tests if the given object is the same as the this object. Two Items + * from the same container with the same ID are equal. + * + * @param obj + * an object to compare with this object + * @return <code>true</code> if the given object is the same as this + * object, <code>false</code> if not + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null + || !obj.getClass().equals(GeneratedPropertyItem.class)) { + return false; + } + final GeneratedPropertyItem li = (GeneratedPropertyItem) obj; + return getContainer() == li.getContainer() + && itemId.equals(li.itemId); + } + + @Override + public int hashCode() { + return itemId.hashCode(); + } + + private GeneratedPropertyContainer getContainer() { + return GeneratedPropertyContainer.this; + } }; /** |