]> git.mxchange.org Git - jproduct-core.git/commitdiff
added equals()/hashCode() for easier checking
authorRoland Haeder <roland@mxchange.org>
Wed, 24 Feb 2016 16:28:59 +0000 (17:28 +0100)
committerRoland Haeder <roland@mxchange.org>
Wed, 24 Feb 2016 16:28:59 +0000 (17:28 +0100)
src/org/mxchange/jshopcore/model/customer/Customer.java
src/org/mxchange/jshopcore/model/customer/ShopCustomer.java

index 9ac6ae6f4ccf33d1116783cf4a47384138ac0d80..d2bd2b356744ba42ad66cdb9e0eb3bd971be99c9 100644 (file)
@@ -146,4 +146,10 @@ public interface Customer extends Serializable {
         * @param customerStatus Account status
         */
        void setCustomerAccountStatus (final CustomerAccountStatus customerStatus);
+
+       @Override
+       boolean equals (final Object object);
+
+       @Override
+       int hashCode ();
 }
index 3eb53cccfca83d22e3f48460fd187d9d7fadf9e8..4fe55ce2a3f89cb9745d815eef1f9f4782d38ec8 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.jshopcore.model.customer;
 
 import java.util.Calendar;
+import java.util.Objects;
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
@@ -130,6 +131,36 @@ public class ShopCustomer implements Customer, Comparable<Customer> {
                this.setCustomerLocked(customer.getCustomerLocked());
        }
 
+       @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 Customer other = (Customer) obj;
+
+               if (!Objects.equals(this.getCustomerNumber(), other.getCustomerNumber())) {
+                       return false;
+               } else if (!Objects.equals(this.getContact(), other.getContact())) {
+                       return false;
+               }
+
+               return Objects.equals(this.getContact(), other.getContact());
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 3;
+               hash = 17 * hash + Objects.hashCode(this.getContact());
+               hash = 17 * hash + Objects.hashCode(this.getCustomerId());
+               hash = 17 * hash + Objects.hashCode(this.getCustomerNumber());
+               return hash;
+       }
+
        @Override
        public Contact getContact () {
                return this.contact;