2 * Copyright (c) 2015 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.yangtools.yang.parser.spi.source;
10 import java.util.HashMap;
12 import org.opendaylight.yangtools.yang.common.QNameModule;
13 import org.opendaylight.yangtools.yang.common.XMLNamespace;
16 * Map-based {@link PrefixToModule} namespace. This class is NOT thread-safe.
18 public class PrefixToModuleMap implements PrefixToModule {
19 private final Map<String, QNameModule> prefixToModuleMap = new HashMap<>();
20 private final Map<XMLNamespace, QNameModule> namespaceToModuleMap = new HashMap<>();
22 public void put(final String prefix, final QNameModule module) {
23 prefixToModuleMap.put(prefix, module);
24 namespaceToModuleMap.put(module.getNamespace(), module);
28 public QNameModule get(final String prefix) {
29 return prefixToModuleMap.get(prefix);
33 public QNameModule getByNamespace(final String namespace) {
34 return namespaceToModuleMap.get(XMLNamespace.of(namespace));