private Collection<JID> getAffectedUsers(Group group, SharedGroupVisibility showInRoster, Collection<String> groupNames) {
        // Answer an empty collection if the group is not being shown in users' rosters
        if (SharedGroupVisibility.usersOfGroups != showInRoster && SharedGroupVisibility.everybody != showInRoster) {
            return new ArrayList<>();
        }
        // Add the users of the group
        Collection<JID> users = new HashSet<>(group.getMembers());
        users.addAll(group.getAdmins());
        // Check if anyone can see this shared group
        if (SharedGroupVisibility.everybody == showInRoster) {
            // Add all users in the system
            for (String username : UserManager.getInstance().getUsernames()) {
                users.add(server.createJID(username, null, true));
            }
            // Add all logged users. We don't need to add all users in the system since only the
            // logged ones will be affected.
            //users.addAll(SessionManager.getInstance().getSessionUsers());
        }
        else {
            // Add the users that may see the group
            Collection<Group> groupList = parseGroups(groupNames);
            for (Group groupInList : groupList) {
                users.addAll(groupInList.getMembers());
                users.addAll(groupInList.getAdmins());
            }
        }
        return users;
    }
This method is similar to {@link #getAffectedUsers(Group)} except that it receives
some group properties. The group properties are passed as parameters since the called of this
method may want to obtain the related users of the group based in some properties values.

This is useful when the group is being edited and some properties has changed and we need to
obtain the related users of the group based on the previous group state.
xmppserver/src/main/java/org/jivesoftware/openfire/roster/RosterManager.java