From: Roland Häder Date: Wed, 1 Apr 2020 18:20:51 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=82d44b91e99ab046a714956d6b4465885c6851d1;p=jfinancials-ejb.git Please cherry-pick: - rewrote to avoid local Iterator instance Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jcontacts/model/contact/FinancialsContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/FinancialsContactSessionBean.java index 06ab264..a9d9cd3 100644 --- a/src/java/org/mxchange/jcontacts/model/contact/FinancialsContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/model/contact/FinancialsContactSessionBean.java @@ -17,7 +17,6 @@ package org.mxchange.jcontacts.model.contact; import java.text.MessageFormat; -import java.util.Iterator; import java.util.List; import java.util.Objects; import javax.ejb.Stateless; @@ -98,21 +97,15 @@ public class FinancialsContactSessionBean extends BaseFinancialsEnterpriseBean i return null; } - // Get iterator - final Iterator iterator = contacts.iterator(); - // Loop through all - while (iterator.hasNext()) { - // Get contact - final Contact next = iterator.next(); - + for (final Contact currentContact : contacts) { // Is same contact? - if ((Objects.equals(contact, next)) || (Contacts.isSameContact(contact, next))) { + if ((Objects.equals(contact, currentContact)) || (Contacts.isSameContact(contact, currentContact))) { // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), next.getContactId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), currentContact.getContactId())); //NOI18N // Found it - foundContact = next; + foundContact = currentContact; break; } }