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; } 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."); } 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 && tokenUserInfo.getUserId() != null && tokenUserInfo.getUserId().equalsIgnoreCase(userId)) { if (!StringExtensions.IsNullOrBlank(tokenCacheItem.getFamilyClientId())) { Logger.v(TAG + methodName, "Found family item matching the given user id."); 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 && tokenUserInfo.getDisplayableId() != null && tokenUserInfo.getDisplayableId().equalsIgnoreCase(userId)) { if (!StringExtensions.IsNullOrBlank(tokenCacheItem.getFamilyClientId())) { Logger.v(TAG + methodName, "Found family item matching the given user id."); return tokenCacheItem; } } } } 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."); } 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 && tokenUserInfo.getUserId() != null && tokenUserInfo.getUserId().equalsIgnoreCase(userId)) { 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 && tokenUserInfo.getDisplayableId() != null && tokenUserInfo.getDisplayableId().equalsIgnoreCase(userId)) { 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; } } } } return null; }