]> git.mxchange.org Git - jcontacts-core.git/commitdiff
rewrote to use unique proptery to avoid another @Index (lesser code)
authorRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 07:33:14 +0000 (09:33 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 07:33:14 +0000 (09:33 +0200)
src/org/mxchange/jcontacts/contact/Contact.java
src/org/mxchange/jcontacts/contact/UserContact.java

index e928b84c46bede51e4a9e5ee6b1e3b450ce0c601..0832aedf3b6589e21c960c902cc03e015d6b4705 100644 (file)
@@ -310,7 +310,7 @@ public interface Contact extends Serializable {
         * <p>
         * @param object Other possible contact class
         * <p>
-        * @return Whether both contacts are same TODO Needs a lot improvements
+        * @return Whether both contacts are same
         */
        @Override
        boolean equals (final Object object);
index 9304cf4ee3c60b0ba1d7a9758ed294f3e2104ed2..387e0273810125a0e2f60d22152a43617cf73909 100644 (file)
@@ -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;
        }
+
 }