]> git.mxchange.org Git - jproduct-core.git/blobdiff - src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
added equals()/hashCode() for easier checking
[jproduct-core.git] / src / org / mxchange / jshopcore / model / customer / ShopCustomer.java
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;