571970b6cf50985a1f3ed9255a6f453d634205cc
[netconf.git] / plugins / netconf-client-mdsal / src / main / java / org / opendaylight / netconf / client / mdsal / impl / BaseSchema.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.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
18 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
19
20 public final class BaseSchema implements EffectiveModelContextProvider, Immutable {
21     private final @NonNull ImmutableMap<QName, ? extends RpcDefinition> mappedRpcs;
22     private final @NonNull EmptyMountPointContext mountContext;
23
24     BaseSchema(final EffectiveModelContext context) {
25         mountContext = new EmptyMountPointContext(context);
26         mappedRpcs = Maps.uniqueIndex(context.getOperations(), RpcDefinition::getQName);
27     }
28
29     @NonNull ImmutableMap<QName, ? extends RpcDefinition> getMappedRpcs() {
30         return mappedRpcs;
31     }
32
33     public @NonNull EmptyMountPointContext getMountPointContext() {
34         return mountContext;
35     }
36
37     @Override
38     public @NonNull EffectiveModelContext getEffectiveModelContext() {
39         return mountContext.getEffectiveModelContext();
40     }
41 }