Cleanup NetconfStateSchemasResolverImpl
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / NetconfStateSchemasResolverImpl.java
index c2947d9860a8a50b981e4787e5479da283155411..765c6108da846e97245aae4dc3df4572f2970fdf 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.yangtools.yang.common.QName;
  * 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,
@@ -27,10 +28,10 @@ public final class NetconfStateSchemasResolverImpl implements NetconfDeviceSchem
                                         final RemoteDeviceId id) {
         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.EMPTY;
+
+        // FIXME: I think we should prefer YANG library here
+        return remoteSessionCapabilities.containsModuleCapability(YANG_LIBRARY_CAPABILITY)
+            ? LibraryModulesSchemas.create(deviceRpc, id) : NetconfStateSchemas.EMPTY;
     }
 }