X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fconfig%2Fyang-store-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fstore%2Fimpl%2FYangStoreSnapshotImpl.java;fp=opendaylight%2Fconfig%2Fyang-store-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fstore%2Fimpl%2FYangStoreSnapshotImpl.java;h=474d7547984b73f0670d02e816a5a3309be2b079;hb=11d70e30dbd8a075b3f846b68ee9409c670a7965;hp=ea709e1a45cd9d39d6447b72bc06affe2a744a76;hpb=12e8be867090f66dc7d205efe9156210dc57214d;p=controller.git diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java index ea709e1a45..474d754798 100644 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java +++ b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java @@ -9,29 +9,39 @@ package org.opendaylight.controller.config.yang.store.impl; import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.Module; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Collections; import java.util.Map; -import java.util.Map.Entry; +import java.util.Set; public class YangStoreSnapshotImpl implements YangStoreSnapshot { + private static final Logger logger = LoggerFactory.getLogger(YangStoreSnapshotImpl.class); + @Deprecated private final Map> moduleMXBeanEntryMap; - private final Map> moduleMap; + private final Map modulesToSources; + private final Map> qNamesToIdentitiesToModuleMXBeanEntries; + + public YangStoreSnapshotImpl(Map> moduleMXBeanEntryMap, + Map modulesToSources, + Map> qNamesToIdentitiesToModuleMXBeanEntries) { - public YangStoreSnapshotImpl( - Map> moduleMXBeanEntryMap, - Map> moduleMap) { this.moduleMXBeanEntryMap = Collections.unmodifiableMap(moduleMXBeanEntryMap); - this.moduleMap = Collections.unmodifiableMap(moduleMap); + this.modulesToSources = Collections.unmodifiableMap(modulesToSources); + this.qNamesToIdentitiesToModuleMXBeanEntries = Collections.unmodifiableMap(qNamesToIdentitiesToModuleMXBeanEntries); } - public YangStoreSnapshotImpl(YangStoreSnapshot yangStoreSnapshot) { - this.moduleMXBeanEntryMap = yangStoreSnapshot.getModuleMXBeanEntryMap(); - this.moduleMap = yangStoreSnapshot.getModuleMap(); + public static YangStoreSnapshotImpl copy(YangStoreSnapshot yangStoreSnapshot) { + return new YangStoreSnapshotImpl( + yangStoreSnapshot.getModuleMXBeanEntryMap(), + yangStoreSnapshot.getModulesToSources(), + yangStoreSnapshot.getQNamesToIdentitiesToModuleMXBeanEntries()); } /** @@ -44,8 +54,28 @@ public class YangStoreSnapshotImpl implements YangStoreSnapshot { } @Override - public Map> getModuleMap() { - return moduleMap; + public Map> getQNamesToIdentitiesToModuleMXBeanEntries() { + return qNamesToIdentitiesToModuleMXBeanEntries; + } + + @Override + public Set getModules() { + return modulesToSources.keySet(); + } + + @Override + public String getModuleSource(Module module) { + String result = modulesToSources.get(module); + if (result == null) { + logger.trace("Cannot find module {} in {}", module, modulesToSources); + throw new IllegalArgumentException("Module not found in this snapshot:" + module); + } + return result; + } + + @Override + public Map getModulesToSources() { + return modulesToSources; } @Override