2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.manager.impl.util;
10 import org.opendaylight.controller.config.spi.ModuleFactory;
11 import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.osgi.framework.BundleContext;
15 import java.util.HashSet;
17 import java.util.Map.Entry;
20 public class ModuleQNameUtil {
22 public static Set<String> getQNames(Map<String, Entry<ModuleFactory, BundleContext>> resolved) {
23 Set<String> result = new HashSet<>();
24 for (Entry<ModuleFactory, BundleContext> entry : resolved.values()) {
25 Class<?> inspected = entry.getKey().getClass();
26 if (inspected.isInterface()) {
27 throw new IllegalArgumentException("Unexpected interface " + inspected);
29 ModuleQName annotation = null;
30 while(annotation == null && inspected != null) {
31 annotation = inspected.getAnnotation(ModuleQName.class);
32 inspected = inspected.getSuperclass();
34 if (annotation != null) {
35 result.add(QName.create(annotation.namespace(), annotation.revision(), annotation.name()).toString());