package org.mxchange.addressbook.model.addressbook;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.ejb.Stateless;
// Debug message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allShares.size()={0}", allShares.size())); //NOI18N
+ // List for users aharing with given
+ List<User> sharingUsers = new ArrayList<>(allShares.size());
+
+ // Check all entries
+ for (final ShareableAddressbook share : allShares) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0}", share.getShareUserSharee())); //NOI18N
+
+ // Add it
+ sharingUsers.add(share.getShareUserSharee());
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("allUsersNotSharing: sharingUsers.size()=" + sharingUsers.size());
+
// Init final user list
List<User> userList = new LinkedList<>();
// Walk through all users
- for (final ShareableAddressbook share : allShares) {
- // Log message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0}", share.getShareUserSharee())); //NOI18N
+ for (final User foundUser : allUsersExcept) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0}", foundUser)); //NOI18N
// Does the list contain it ?
- if (!allUsersExcept.contains(share.getShareUserSharee())) {
+ if (!sharingUsers.contains(foundUser)) {
// Found one to add
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0} - ADDING!", share.getShareUserSharee())); //NOI18N
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0} - ADDING!", foundUser)); //NOI18N
// Add it
- userList.add(share.getShareUserSharee());
+ userList.add(foundUser);
}
}