]> git.mxchange.org Git - jshop-core.git/commitdiff
added equals()/hashCode() for easier checking
authorRoland Haeder <roland@mxchange.org>
Wed, 24 Feb 2016 16:34:13 +0000 (17:34 +0100)
committerRoland Haeder <roland@mxchange.org>
Wed, 24 Feb 2016 16:34:13 +0000 (17:34 +0100)
src/org/mxchange/jshopcore/model/product/GenericProduct.java
src/org/mxchange/jshopcore/model/product/Product.java

index b36637cd4f96d0e099a14704d336ef8c0885d681..8a3fedb549f4239834711d130be84c2486ed91e0 100644 (file)
@@ -133,6 +133,33 @@ public class GenericProduct implements Product, Comparable<Product> {
                this.setProductTitle(product.getProductTitle());
        }
 
+       @Override
+       public boolean equals (final Object obj) {
+               if (this == obj) {
+                       return true;
+               } else if (obj == null) {
+                       return false;
+               } else if (this.getClass() != obj.getClass()) {
+                       return false;
+               }
+
+               final Product other = (Product) obj;
+
+               if (!Objects.equals(this.getProductTitle(), other.getProductTitle())) {
+                       return false;
+               }
+
+               return Objects.equals(this.getProductId(), other.getProductId());
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 7;
+               hash = 23 * hash + Objects.hashCode(this.getProductId());
+               hash = 23 * hash + Objects.hashCode(this.getProductTitle());
+               return hash;
+       }
+
        @Override
        public Boolean getProductAvailability () {
                return this.productAvailability;
index d6a2bb528fce713d39341ece34a9eb82e6f70bd5..88d2261fd0c90abc3528f6e73e223f199f00db25 100644 (file)
@@ -102,4 +102,10 @@ public interface Product extends Serializable {
         * @param productTitle the title to set
         */
        void setProductTitle (final String productTitle);
+
+       @Override
+       boolean equals (final Object object);
+
+       @Override
+       int hashCode ();
 }