11c7d04bd7306603f07e5fe4c8a097f7686fb2e7
[controller.git] / opendaylight / config / yang-jmx-generator / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / util / YangModelSearchUtils.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.controller.config.yangjmxgenerator.plugin.util;
9
10 import java.util.Collection;
11 import java.util.HashMap;
12 import java.util.Map;
13
14 import org.opendaylight.yangtools.yang.model.api.Module;
15
16 import com.google.common.base.Preconditions;
17
18 public class YangModelSearchUtils {
19
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);
29         }
30         return result;
31     }
32 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.