Bug 8153: Enforce check-style rules for netconf - sal-netconf-connector
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / NetconfStateSchemasResolverImpl.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
9 package org.opendaylight.netconf.sal.connect.netconf;
10
11 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas;
12 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver;
13 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
14 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
15 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.ModulesState;
17 import org.opendaylight.yangtools.yang.common.QName;
18
19 /**
20  * Default implementation resolving schemas QNames from netconf-state or from modules-state.
21  */
22 public final class NetconfStateSchemasResolverImpl implements NetconfDeviceSchemasResolver {
23
24     @Override
25     public NetconfDeviceSchemas resolve(final NetconfDeviceRpc deviceRpc,
26                                         final NetconfSessionPreferences remoteSessionCapabilities,
27                                         final RemoteDeviceId id) {
28         if (remoteSessionCapabilities.isMonitoringSupported()) {
29             return NetconfStateSchemas.create(deviceRpc, remoteSessionCapabilities, id);
30         } else if (remoteSessionCapabilities.containsModuleCapability(QName.create(ModulesState.QNAME,
31                 "ietf-yang-library"))) {
32             return LibraryModulesSchemas.create(deviceRpc, id);
33         }
34         return NetconfStateSchemas.EMPTY;
35     }
36 }