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