From 03209c3c702f981ee2d04685037b9574da905829 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 18 May 2016 09:33:14 +0200 Subject: [PATCH] rewrote to use unique proptery to avoid another @Index (lesser code) --- src/org/mxchange/jcontacts/contact/Contact.java | 2 +- src/org/mxchange/jcontacts/contact/UserContact.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) 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; } + } -- 2.39.5