code: public Set<Role> findRoles(final Set<Group> userGroups)
      {
          final Set<Role> result = new HashSet<Role>();
          
          for(final RoleMapping mapping : this.getRoleMappings())
          {
              final Object source = mapping.getSource();
              
              if((userGroups != null) && userGroups.contains(source))
              {
                  result.add(mapping.getTarget());
              }
          }
          
          return result;
      }
docs: Finds the roles mapped to given user groups.
  
  @param userGroups
  The user groups.
  @return The roles found.