--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.sal.core.impl;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+\r
+\r
+public class Utils {\r
+\r
+ public static <T> void addToMap(Map<QName, List<T>> map, QName key, T value) {\r
+ List<T> list = map.get(key);\r
+ if (list == null) {\r
+ list = new ArrayList<T>();\r
+ map.put(key, list);\r
+ }\r
+ list.add(value);\r
+ }\r
+\r
+ public static <T> void removeFromMap(Map<QName, List<T>> map, QName key,\r
+ T value) {\r
+ List<T> list = map.get(key);\r
+ if (list == null) {\r
+ return;\r
+ }\r
+ list.remove(value);\r
+ if (list.isEmpty()) {\r
+ map.remove(key);\r
+ }\r
+ }\r
+}\r
+