Rework BaseScheams
[netconf.git] / plugins / netconf-client-mdsal / src / main / java / org / opendaylight / netconf / client / mdsal / impl / DefaultBaseNetconfSchema.java
1 /*
2  * Copyright (c) 2016 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.netconf.client.mdsal.impl;
9
10 import com.google.common.collect.ImmutableMap;
11 import com.google.common.collect.Maps;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.netconf.client.mdsal.api.BaseNetconfSchema;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.schema.MountPointContext;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
18
19 /**
20  * An {@link EffectiveModelContext} corresponding to a NETCONF baseline advertized by a device..
21  */
22 public final class DefaultBaseNetconfSchema implements BaseNetconfSchema {
23     private final @NonNull ImmutableMap<QName, ? extends RpcDefinition> mappedRpcs;
24     private final @NonNull MountPointContext mountPointContext;
25
26     DefaultBaseNetconfSchema(final EffectiveModelContext context) {
27         mountPointContext = MountPointContext.of(context);
28         mappedRpcs = Maps.uniqueIndex(context.getOperations(), RpcDefinition::getQName);
29     }
30
31     @Override
32     public MountPointContext mountPointContext() {
33         return mountPointContext;
34     }
35
36     @Override
37     public ImmutableMap<QName, ? extends RpcDefinition> mappedRpcs() {
38         return mappedRpcs;
39     }
40 }