diff options
author | Artur Signell <artur@vaadin.com> | 2015-12-30 07:56:33 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-01-04 08:50:27 +0000 |
commit | 4154ef5bf6de5eb69bbb5d29f382bfb8df2ab773 (patch) | |
tree | f38133ef03767aeedb1524c29feb8524325dae92 /server/src/com/vaadin/data | |
parent | 393b71266c8874b4aa6a13df1b2d2c5281831566 (diff) | |
download | vaadin-framework-4154ef5bf6de5eb69bbb5d29f382bfb8df2ab773.tar.gz vaadin-framework-4154ef5bf6de5eb69bbb5d29f382bfb8df2ab773.zip |
Make GeneratedPropertyItem equals self (#19426)
Change-Id: Ieccb53a402dd6669fb684b0ef8e18e4c8778c58e
Diffstat (limited to 'server/src/com/vaadin/data')
-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; + } }; /** |