]> git.mxchange.org Git - addressbook-core.git/commitdiff
Added protected method detachAllContactPhoneEntries()
authorRoland Häder <roland@mxchange.org>
Fri, 19 Aug 2016 15:57:54 +0000 (17:57 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 9 Jun 2017 19:28:29 +0000 (21:28 +0200)
Signed-off-by: Roland Häder <roland@haeder.net>
src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java

index 9f92bad74269cb7a6b0584cc6d6f55cd43ce314d..3c951a810197612446fe1158cf9851f833ef2e90 100644 (file)
@@ -57,7 +57,53 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
        }
 
        /**
-        * Updates all contact's phone entry's created timestamps
+        * Detaches all contact's phone instances.
+        * <p>
+        * @param contact Contact to set instances
+        */
+       protected void detachAllContactPhoneEntries (final Contact contact) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("detachAllContactPhoneEntries: contact={0} - CALLED!", contact)); //NOI18N
+
+               // Both must be the same and not null
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("detachAllContactPhoneEntries: contact.contactMobileNumber={0}", contact.getContactMobileNumber())); //NOI18N
+
+               // Is contact cellphone set?
+               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+                       // Copy cellphone number
+                       contact.setContactMobileNumber(this.getDetached(contact.getContactMobileNumber(), contact.getContactMobileNumber()));
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("detachAllContactPhoneEntries: contact.contactLandLineNumber={0}", contact.getContactLandLineNumber())); //NOI18N
+
+               // Is the land-line number set?
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Copy land-line number
+                       contact.setContactLandLineNumber(this.getDetached(contact.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("detachAllContactPhoneEntries: contact.contactFaxNumber={0}", contact.getContactFaxNumber())); //NOI18N
+
+               // Is the fax number set?
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Copy fax number
+                       contact.setContactFaxNumber(this.getDetached(contact.getContactFaxNumber(), contact.getContactFaxNumber()));
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("detachAllContactPhoneEntries: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Updates all contacts's phone entry's created timestamps
         * <p>
         * @param contact Contact instance to update
         */