Here you can find the source of mergePermMap(Map
private static <T> void mergePermMap(Map<String, Set<T>> permMap, Map<String, Set<T>> subPermMap)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Main { private static <T> void mergePermMap(Map<String, Set<T>> permMap, Map<String, Set<T>> subPermMap) { Set<Entry<String, Set<T>>> subEntrySet = subPermMap.entrySet(); Iterator<Entry<String, Set<T>>> subEntryIterator = subEntrySet.iterator(); while (subEntryIterator.hasNext()) { Entry<String, Set<T>> subEntry = subEntryIterator.next(); String permTypeName = subEntry.getKey(); Set<T> permValueSet = subEntry.getValue(); if (permMap.containsKey(permTypeName)) { permMap.get(permTypeName).addAll(permValueSet); } else { permMap.put(permTypeName, permValueSet); }//ww w . j av a 2s . c o m } } }