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.yangjmxgenerator.plugin.util;
10 import java.util.Collection;
11 import java.util.HashMap;
14 import org.opendaylight.yangtools.yang.model.api.Module;
16 import com.google.common.base.Preconditions;
18 public class YangModelSearchUtils {
20 public static Map<String, Module> mapModulesByNames(
21 Collection<Module> modules) {
22 Map<String, Module> result = new HashMap<>();
23 for (Module m : modules) {
24 String moduleName = m.getName();
25 Preconditions.checkArgument(
26 result.containsKey(moduleName) == false,
27 "Two modules have same name " + moduleName);
28 result.put(moduleName, m);