Initial code drop of yang model driven configuration system
[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 java.util.Map;
11 import java.util.Map.Entry;
12
13 import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
14 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16
17 public class YangStoreSnapshotImpl implements YangStoreSnapshot {
18
19     private final Map<String /* Namespace from yang file */, Map<String /*
20                                                                          * Name
21                                                                          * of
22                                                                          * module
23                                                                          * entry
24                                                                          * from
25                                                                          * yang
26                                                                          * file
27                                                                          */, ModuleMXBeanEntry>> moduleMXBeanEntryMap;
28
29     private final Map<String, Entry<Module, String>> moduleMap;
30
31     public YangStoreSnapshotImpl(
32             Map<String, Map<String, ModuleMXBeanEntry>> moduleMXBeanEntryMap,
33             Map<String, Entry<Module, String>> moduleMap) {
34         this.moduleMXBeanEntryMap = moduleMXBeanEntryMap;
35         this.moduleMap = moduleMap;
36     }
37
38     @Override
39     public Map<String, Map<String, ModuleMXBeanEntry>> getModuleMXBeanEntryMap() {
40         return moduleMXBeanEntryMap;
41     }
42
43     @Override
44     public Map<String, Entry<Module, String>> getModuleMap() {
45         return moduleMap;
46     }
47
48     @Override
49     public int countModuleMXBeanEntries() {
50         int i = 0;
51         for (Map<String, ModuleMXBeanEntry> value : moduleMXBeanEntryMap
52                 .values()) {
53             i += value.keySet().size();
54         }
55         return i;
56     }
57
58     @Override
59     public void close() {
60         // TODO: reference counting
61     }
62
63 }