From 57b940146e55f5584d960bab2d64b5a5e922e469 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 23 Jun 2017 20:47:20 +0200 Subject: [PATCH] Please cherry-pick: - renamed detachedFoo -> managedFoo - used new copyAll() methods MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../database/BaseAddressbookDatabaseBean.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java b/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java index 146d263..57b8abc 100644 --- a/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java +++ b/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java @@ -288,58 +288,58 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean { /** * Merges given (detached) contact's data *

- * @param contact Contact instance to merge + * @param detachedContact Contact instance to merge *

* @return Detached contact instance */ - protected Contact mergeContactData (final Contact contact) { + protected Contact mergeContactData (final Contact detachedContact) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: detachedContact={1} - CALLED!", this.getClass().getSimpleName(), detachedContact)); //NOI18N // The contact instance must be valid - if (null == contact) { + if (null == detachedContact) { // Throw NPE again throw new NullPointerException("detachedContact is null"); //NOI18N - } else if (contact.getContactId() == null) { + } else if (detachedContact.getContactId() == null) { // Throw NPE again throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N - } else if (contact.getContactId() < 1) { + } else if (detachedContact.getContactId() < 1) { // Not valid - throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), contact.getContactId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N } // Get contact from it and find it - Contact managedContact = this.getEntityManager().find(contact.getClass(), contact.getContactId()); + Contact managedContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId()); // Should be found - assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N + assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N // Debug message this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateUserPersonalData: managedContact.contactId={1}", this.getClass().getSimpleName(), managedContact.getContactId())); //NOI18N // Is a fax number set? - if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { + if (detachedContact.getContactFaxNumber() instanceof DialableFaxNumber) { // Make fax numbers managed - managedContact.setContactFaxNumber(this.getManaged(contact.getContactFaxNumber(), contact.getContactFaxNumber())); + managedContact.setContactFaxNumber(this.getManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber())); } // Is a land-line number set? - if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { + if (detachedContact.getContactLandLineNumber() instanceof DialableLandLineNumber) { // Make land-line numbers managed - managedContact.setContactLandLineNumber(this.getManaged(contact.getContactLandLineNumber(), contact.getContactLandLineNumber())); + managedContact.setContactLandLineNumber(this.getManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber())); } // Is a mobile number set? - if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { + if (detachedContact.getContactMobileNumber() instanceof DialableMobileNumber) { // Make mobile numbers managed - managedContact.setContactMobileNumber(this.getManaged(contact.getContactMobileNumber(), contact.getContactMobileNumber())); + managedContact.setContactMobileNumber(this.getManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber())); } // Set updated timestamp managedContact.setContactUpdated(new GregorianCalendar()); // Copy all - ContactUtils.copyAll(contact, managedContact); + ContactUtils.copyAll(detachedContact, managedContact); // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N -- 2.39.5