From: Roland Häder Date: Wed, 18 May 2016 07:33:14 +0000 (+0200) Subject: rewrote to use unique proptery to avoid another @Index (lesser code) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=03209c3c702f981ee2d04685037b9574da905829;p=jcontacts-core.git rewrote to use unique proptery to avoid another @Index (lesser code) --- diff --git a/src/org/mxchange/jcontacts/contact/Contact.java b/src/org/mxchange/jcontacts/contact/Contact.java index e928b84..0832aed 100644 --- a/src/org/mxchange/jcontacts/contact/Contact.java +++ b/src/org/mxchange/jcontacts/contact/Contact.java @@ -310,7 +310,7 @@ public interface Contact extends Serializable { *

* @param object Other possible contact class *

- * @return Whether both contacts are same TODO Needs a lot improvements + * @return Whether both contacts are same */ @Override boolean equals (final Object object); diff --git a/src/org/mxchange/jcontacts/contact/UserContact.java b/src/org/mxchange/jcontacts/contact/UserContact.java index 9304cf4..387e027 100644 --- a/src/org/mxchange/jcontacts/contact/UserContact.java +++ b/src/org/mxchange/jcontacts/contact/UserContact.java @@ -60,11 +60,6 @@ import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; @Index ( name = "contact_gender", columnList = "contact_gender" - ), - @Index ( - name = "contact_email_address", - unique = true, - columnList = "contact_email_address" ) } ) @@ -131,7 +126,7 @@ public class UserContact implements Contact { /** * Email address */ - @Column (name = "contact_email_address", length = 100) + @Column (name = "contact_email_address", length = 100, unique = true) private String contactEmailAddress; /** @@ -279,7 +274,10 @@ public class UserContact implements Contact { @Override public boolean equals (final Object object) { // Is it same type? - if (!(object instanceof UserContact)) { + if (null == object) { + // Is null + return false; + } else if (!(object instanceof UserContact)) { // Not equal types return false; } else if (!(object instanceof Contact)) { @@ -504,4 +502,5 @@ public class UserContact implements Contact { public Boolean isOwnContact () { return this.contactOwnContact; } + }