bool RoleGraph::addPrivilegesForBuiltinRole(const RoleName& roleName, PrivilegeVector* result) {
    const bool isAdminDB = (roleName.getDB() == ADMIN_DBNAME);

    if (roleName.getRole() == BUILTIN_ROLE_READ) {
        addReadOnlyDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_READ_WRITE) {
        addReadWriteDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_USER_ADMIN) {
        addUserAdminDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_DB_ADMIN) {
        addDbAdminDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_DB_OWNER) {
        addDbOwnerPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_ENABLE_SHARDING) {
        addEnableShardingPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_READ_ANY_DB) {
        addReadOnlyAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_READ_WRITE_ANY_DB) {
        addReadWriteAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_USER_ADMIN_ANY_DB) {
        addUserAdminAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_DB_ADMIN_ANY_DB) {
        addDbAdminAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_CLUSTER_MONITOR) {
        addClusterMonitorPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_HOST_MANAGEMENT) {
        addHostManagerPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_CLUSTER_MANAGEMENT) {
        addClusterManagerPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_CLUSTER_ADMIN) {
        addClusterAdminPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_QUERYABLE_BACKUP) {
        addQueryableBackupPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_BACKUP) {
        addBackupPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_RESTORE) {
        addRestorePrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_ROOT) {
        addRootRolePrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_INTERNAL) {
        addInternalRolePrivileges(result);
    } else {
        return false;
    }

    // One of the roles has matched, otherwise we would have returned already.
    return true;
}
bool RoleGraph::addPrivilegesForBuiltinRole(const RoleName& roleName, PrivilegeVector* result) {
    const bool isAdminDB = (roleName.getDB() == ADMIN_DBNAME);

    if (roleName.getRole() == BUILTIN_ROLE_READ) {
        addReadOnlyDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_READ_WRITE) {
        addReadWriteDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_USER_ADMIN) {
        addUserAdminDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_DB_ADMIN) {
        addDbAdminDbPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_DB_OWNER) {
        addDbOwnerPrivileges(result, roleName.getDB());
    } else if (roleName.getRole() == BUILTIN_ROLE_ENABLE_SHARDING) {
        addEnableShardingPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_READ_ANY_DB) {
        addReadOnlyAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_READ_WRITE_ANY_DB) {
        addReadWriteAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_USER_ADMIN_ANY_DB) {
        addUserAdminAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_DB_ADMIN_ANY_DB) {
        addDbAdminAnyDbPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_CLUSTER_MONITOR) {
        addClusterMonitorPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_HOST_MANAGEMENT) {
        addHostManagerPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_CLUSTER_MANAGEMENT) {
        addClusterManagerPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_CLUSTER_ADMIN) {
        addClusterAdminPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_QUERYABLE_BACKUP) {
        addQueryableBackupPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_BACKUP) {
        addBackupPrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_RESTORE) {
        addRestorePrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_ROOT) {
        addRootRolePrivileges(result);
    } else if (isAdminDB && roleName.getRole() == BUILTIN_ROLE_INTERNAL) {
        addInternalRolePrivileges(result);
    } else {
        return false;
    }

     
    return true;
}