Convert anyxml nodes lazily
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / NetconfStateSchemasResolverImpl.java
index c2947d9860a8a50b981e4787e5479da283155411..f7c42ba360fb0681cabef36d935f543eb0c2c383 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.sal.connect.netconf;
 
 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas;
@@ -13,24 +12,26 @@ import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.ModulesState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * Default implementation resolving schemas QNames from netconf-state or from modules-state.
  */
 public final class NetconfStateSchemasResolverImpl implements NetconfDeviceSchemasResolver {
+    private static final QName YANG_LIBRARY_CAPABILITY = QName.create(ModulesState.QNAME, "ietf-yang-library").intern();
 
     @Override
     public NetconfDeviceSchemas resolve(final NetconfDeviceRpc deviceRpc,
-                                        final NetconfSessionPreferences remoteSessionCapabilities,
-                                        final RemoteDeviceId id) {
+            final NetconfSessionPreferences remoteSessionCapabilities,
+            final RemoteDeviceId id, final SchemaContext schemaContext) {
         if (remoteSessionCapabilities.isMonitoringSupported()) {
-            return NetconfStateSchemas.create(deviceRpc, remoteSessionCapabilities, id);
-        } else if (remoteSessionCapabilities.containsModuleCapability(QName.create(ModulesState.QNAME,
-                "ietf-yang-library"))) {
-            return LibraryModulesSchemas.create(deviceRpc, id);
+            return NetconfStateSchemas.create(deviceRpc, remoteSessionCapabilities, id, schemaContext);
         }
-        return NetconfStateSchemas.EMPTY;
+
+        // FIXME: I think we should prefer YANG library here
+        return remoteSessionCapabilities.containsModuleCapability(YANG_LIBRARY_CAPABILITY)
+            ? LibraryModulesSchemas.create(deviceRpc, id) : NetconfStateSchemas.EMPTY;
     }
 }