Merge "Add a the logger config for debugging schema loading"
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / util / MapUtils.xtend
1 package org.opendaylight.controller.sal.binding.impl.util
2
3 import java.util.Map.Entry
4 import org.opendaylight.yangtools.concepts.Path
5 import java.util.Map
6 import java.util.Set
7 import java.util.Collection
8 import java.util.HashSet
9 import com.google.common.collect.Multimap
10
11 class MapUtils {
12
13     public static def <P extends Path<P>, V> Collection<Entry<? extends P, ? extends V>> getAllChildren(
14         Multimap<? extends P, ? extends V> map, P path) {
15         val ret = new HashSet();
16         val entries = map.entries;
17
18         for (entry : entries) {
19             val currentPath = entry.key;
20             // If the registered reader processes nested elements
21             if (path.contains(currentPath)) {
22                 ret.add(entry);
23             } else if(currentPath.contains(path)) {
24                 // If the registered reader is parent of entry
25                 ret.add(entry);
26             }
27         }
28
29         return ret;
30     }
31 }