From f708fa32d80dbbcff549731290c54becbd7d658c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 19 Aug 2016 17:57:54 +0200 Subject: [PATCH] Added protected method detachAllContactPhoneEntries() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../database/BasePizzaDatabaseBean.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java b/src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java index b5e74f6..7db3e73 100644 --- a/src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java +++ b/src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java @@ -107,6 +107,52 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean { } } + /** + * Detaches all contact's phone instances. + *

+ * @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 *

-- 2.39.5