Merge "Bug 615: Removed xtend from Topology Manager"
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / util / MapUtils.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.sal.binding.impl.util;
10
11 import com.google.common.collect.Multimap;
12 import java.util.Collection;
13 import java.util.HashSet;
14 import java.util.Map.Entry;
15 import org.opendaylight.yangtools.concepts.Path;
16
17 @SuppressWarnings("all")
18 public class MapUtils {
19   public static <P extends Path<P>, V extends Object> Collection<Entry<? extends P,? extends V>> getAllChildren(final Multimap<? extends P,? extends V> map, final P path) {
20     HashSet<Entry<? extends P,? extends V>> _hashSet = new HashSet<Entry<? extends P, ? extends V>>();
21     final HashSet<Entry<? extends P,? extends V>> ret = _hashSet;
22     final Collection<? extends Entry<? extends P,? extends V>> entries = map.entries();
23     for (final Entry<? extends P,? extends V> entry : entries) {
24       {
25         final P currentPath = entry.getKey();
26         if (path.contains(currentPath)) {
27           ret.add(entry);
28         } else if (currentPath.contains(path)){
29             ret.add(entry);
30         }
31       }
32     }
33     return ret;
34   }
35 }
36