*/
package org.opendaylight.netconf.sal.connect.netconf.schema.mapping;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.Arrays;
-import java.util.Map;
import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.common.QName;
.$YangModuleInfoImpl.getInstance()
);
- private final Map<QName, RpcDefinition> mappedRpcs;
+ private final ImmutableMap<QName, RpcDefinition> mappedRpcs;
private final SchemaContext schemaContext;
BaseSchema(final YangModuleInfo... modules) {
mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), RpcDefinition::getQName);
}
- Map<QName, RpcDefinition> getMappedRpcs() {
+ ImmutableMap<QName, RpcDefinition> getMappedRpcs() {
return mappedRpcs;
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Maps;
private final SchemaContext schemaContext;
private final BaseSchema baseSchema;
private final MessageCounter counter;
- private final Map<QName, RpcDefinition> mappedRpcs;
+ private final ImmutableMap<QName, RpcDefinition> mappedRpcs;
private final Multimap<QName, NotificationDefinition> mappedNotifications;
private final boolean strictParsing;
private final Set<ActionDefinition> actions;
// and also check if the device exposed model for base netconf.
// If no, use pre built base netconf operations model
final boolean needToUseBaseCtx = mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName);
- final Map<QName, RpcDefinition> currentMappedRpcs;
+ final ImmutableMap<QName, RpcDefinition> currentMappedRpcs;
if (needToUseBaseCtx) {
currentMappedRpcs = baseSchema.getMappedRpcs();
} else {
final RpcDefinition mappedRpc = Preconditions.checkNotNull(currentMappedRpcs.get(rpcQName),
"Unknown rpc %s, available rpcs: %s", rpcQName, currentMappedRpcs.keySet());
if (mappedRpc.getInput().getChildNodes().isEmpty()) {
- return new NetconfMessage(NetconfMessageTransformUtil
- .prepareDomResultForRpcRequest(rpcQName, counter).getNode().getOwnerDocument());
+ return new NetconfMessage(NetconfMessageTransformUtil.prepareDomResultForRpcRequest(rpcQName, counter)
+ .getNode().getOwnerDocument());
}
Preconditions.checkNotNull(payload, "Transforming an rpc with input: %s, payload cannot be null", rpcQName);
new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_QNAME))
.withChild(anyXmlNode).build();
} else {
-
- Map<QName, RpcDefinition> currentMappedRpcs = mappedRpcs;
-
// Determine whether a base netconf operation is being invoked
// and also check if the device exposed model for base netconf.
// If no, use pre built base netconf operations model
- final boolean needToUseBaseCtx = mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName);
- if (needToUseBaseCtx) {
+ final ImmutableMap<QName, RpcDefinition> currentMappedRpcs;
+ if (mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName)) {
currentMappedRpcs = baseSchema.getMappedRpcs();
+ } else {
+ currentMappedRpcs = mappedRpcs;
}
final RpcDefinition rpcDefinition = currentMappedRpcs.get(rpcQName);