Source:
private TokenCacheItem findFamilyItemForUser(final UserIdentifierType userIdentifierType, final String userId) { final String methodName = ":findFamilyItemForUser"; if (StringExtensions.IsNullOrBlank(userId)) { Logger.v(TAG + methodName, "User id is not provided, cannot continue with finding family item."); return null; } Iterable<TokenCacheItem> allItems = mTokenCacheStore.getAll(); if (allItems == null || !allItems.iterator().hasNext()) { Logger.v(TAG + methodName, "No items in the cache, cannot continue with finding family item."); return null; } if (userIdentifierType == UserIdentifierType.UniqueId) { Logger.v(TAG + methodName, "UserIdentifier type is unique id, will look for the family item based on unique id."); for (final TokenCacheItem tokenCacheItem : allItems) { final UserInfo tokenUserInfo = tokenCacheItem.getUserInfo(); if (tokenUserInfo != null && userId.equalsIgnoreCase(tokenUserInfo.getUserId())) { if (!StringExtensions.IsNullOrBlank(tokenCacheItem.getFamilyClientId()) && !StringExtensions.IsNullOrBlank(tokenCacheItem.getRefreshToken())) { Logger.v(TAG + methodName, "Found family item matching the given user id, and the clientId selected for FoCI is: " + tokenCacheItem.getClientId()); return tokenCacheItem; } } } } else if (userIdentifierType == UserIdentifierType.LoginHint) { Logger.v(TAG + methodName, "UserIdentifier type is loginhint, will look for the family item based on login hint."); for (final TokenCacheItem tokenCacheItem : allItems) { final UserInfo tokenUserInfo = tokenCacheItem.getUserInfo(); if (tokenUserInfo != null && userId.equalsIgnoreCase(tokenUserInfo.getDisplayableId())) { if (!StringExtensions.IsNullOrBlank(tokenCacheItem.getFamilyClientId()) && !StringExtensions.IsNullOrBlank(tokenCacheItem.getRefreshToken())) { Logger.v(TAG + methodName, "Found family item matching the given user id, and the clientId selected for FoCI is: " + tokenCacheItem.getClientId()); return tokenCacheItem; } } } } Logger.v(TAG + methodName, "No family items found in the cache."); return null; }

Target:
private TokenCacheItem findFamilyItemForUser(final UserIdentifierType userIdentifierType, final String userId) { final String methodName = ":findFamilyItemForUser"; if (StringExtensions.IsNullOrBlank(userId)) { Logger.v(TAG + methodName, "User id is not provided, cannot continue with finding family item."); return null; } Iterator<TokenCacheItem> allItems = mTokenCacheStore.getAll(); if (allItems == null || !allItems.hasNext()) { Logger.v(TAG + methodName, "No items in the cache, cannot continue with finding family item."); return null; } if (userIdentifierType == UserIdentifierType.UniqueId) { Logger.v(TAG + methodName, "UserIdentifier type is unique id, will look for the family item based on unique id."); while (allItems.hasNext()) { final TokenCacheItem tokenCacheItem = allItems.next(); final UserInfo tokenUserInfo = tokenCacheItem.getUserInfo(); if (tokenUserInfo != null && userId.equalsIgnoreCase(tokenUserInfo.getUserId())) { if (!StringExtensions.IsNullOrBlank(tokenCacheItem.getFamilyClientId()) && !StringExtensions.IsNullOrBlank(tokenCacheItem.getRefreshToken())) { Logger.v(TAG + methodName, "Found family item matching the given user id, and the clientId selected for FoCI is: " + tokenCacheItem.getClientId()); return tokenCacheItem; } } } } else if (userIdentifierType == UserIdentifierType.LoginHint) { Logger.v(TAG + methodName, "UserIdentifier type is loginhint, will look for the family item based on login hint."); while (allItems.hasNext()) { final TokenCacheItem tokenCacheItem = allItems.next(); final UserInfo tokenUserInfo = tokenCacheItem.getUserInfo(); if (tokenUserInfo != null && userId.equalsIgnoreCase(tokenUserInfo.getDisplayableId())) { if (!StringExtensions.IsNullOrBlank(tokenCacheItem.getFamilyClientId()) && !StringExtensions.IsNullOrBlank(tokenCacheItem.getRefreshToken())) { Logger.v(TAG + methodName, "Found family item matching the given user id, and the clientId selected for FoCI is: " + tokenCacheItem.getClientId()); return tokenCacheItem; } } } } Logger.v(TAG + methodName, "No family items found in the cache."); return null; }