Java Map Merge mergeImportedPermissionsWithExistingPermissions( Map> existingRoleIdsToActionIds, Map importedRoleIdsToActionIds)

Here you can find the source of mergeImportedPermissionsWithExistingPermissions( Map> existingRoleIdsToActionIds, Map importedRoleIdsToActionIds)

Description

merge Imported Permissions With Existing Permissions

License

Open Source License

Declaration

public static Map<Long, String[]> mergeImportedPermissionsWithExistingPermissions(
            Map<Long, Set<String>> existingRoleIdsToActionIds, Map<Long, String[]> importedRoleIdsToActionIds) 

Method Source Code

//package com.java2s;
/**/*from   w w  w  .  j  av a 2 s. co m*/
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

import java.util.HashMap;

import java.util.Map;
import java.util.Set;

public class Main {
    public static Map<Long, String[]> mergeImportedPermissionsWithExistingPermissions(
            Map<Long, Set<String>> existingRoleIdsToActionIds, Map<Long, String[]> importedRoleIdsToActionIds) {

        Map<Long, String[]> mergedRoleIdsToActionIds = new HashMap<>();

        for (Map.Entry<Long, Set<String>> roleIdsToActionIds : existingRoleIdsToActionIds.entrySet()) {

            long roleId = roleIdsToActionIds.getKey();

            if (importedRoleIdsToActionIds.containsKey(roleId)) {
                String[] actionIds = importedRoleIdsToActionIds.remove(roleId);

                mergedRoleIdsToActionIds.put(roleId, actionIds);
            } else {
                mergedRoleIdsToActionIds.put(roleId, new String[0]);
            }
        }

        mergedRoleIdsToActionIds.putAll(importedRoleIdsToActionIds);

        return mergedRoleIdsToActionIds;
    }
}

Related

  1. mergeEnv(Map newEnv, Map env)
  2. mergeEnvironmentVariables(Map environmentSource, Map environmentDestination, String environmentVariable)
  3. mergeFamilies(Map familySource, Map familyTarget)
  4. mergeFixedValueConditions(Map> left, Map> right)
  5. mergeIfAbsent(Map map, Map toMerge)
  6. mergeListWithMap(List from, Map to)
  7. mergeMap(Map map, Object[]... pairs)
  8. mergeMap(Map primaryValues, Map defaultValues)
  9. mergeMap(Map first, Map second)