sal-remoterpc-connector: sync ch.qos.logback:logback-classic version
[controller.git] / opendaylight / config / yang-store-impl / src / main / java / org / opendaylight / controller / config / yang / store / impl / YangStoreSnapshotImpl.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.yang.store.impl;
9
10 import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
11 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
12 import org.opendaylight.yangtools.yang.model.api.Module;
13
14 import java.util.Collections;
15 import java.util.Map;
16 import java.util.Map.Entry;
17
18 public class YangStoreSnapshotImpl implements YangStoreSnapshot {
19
20     private final Map<String /* Namespace from yang file */,
21             Map<String /* Name of module entry from yang file */, ModuleMXBeanEntry>> moduleMXBeanEntryMap;
22
23     private final Map<String, Entry<Module, String>> moduleMap;
24
25     public YangStoreSnapshotImpl(
26             Map<String, Map<String, ModuleMXBeanEntry>> moduleMXBeanEntryMap,
27             Map<String, Entry<Module, String>> moduleMap) {
28         this.moduleMXBeanEntryMap = Collections.unmodifiableMap(moduleMXBeanEntryMap);
29         this.moduleMap = Collections.unmodifiableMap(moduleMap);
30     }
31
32     public YangStoreSnapshotImpl(YangStoreSnapshot yangStoreSnapshot) {
33         this.moduleMXBeanEntryMap = yangStoreSnapshot.getModuleMXBeanEntryMap();
34         this.moduleMap = yangStoreSnapshot.getModuleMap();
35     }
36
37     /**
38      * @return all loaded config modules. Key of outer map is namespace of yang file.
39      * Key of inner map is name of module entry. Value is module entry.
40      */
41     @Override
42     public Map<String, Map<String, ModuleMXBeanEntry>> getModuleMXBeanEntryMap() {
43         return moduleMXBeanEntryMap;
44     }
45
46     @Override
47     public Map<String, Entry<Module, String>> getModuleMap() {
48         return moduleMap;
49     }
50
51     @Override
52     public int countModuleMXBeanEntries() {
53         int i = 0;
54         for (Map<String, ModuleMXBeanEntry> value : moduleMXBeanEntryMap
55                 .values()) {
56             i += value.keySet().size();
57         }
58         return i;
59     }
60
61     @Override
62     public void close() {
63         // TODO: reference counting
64     }
65
66 }