Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / codecs / StringModuleInstanceIdentifierCodec.java
index 69d26a5a67b99739e6d8101c75ed07ca7ce24392..3dc7778782fb1e8a20ca70fc9157d3b2627b687e 100644 (file)
@@ -37,11 +37,8 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr
 
     @Override
     protected Module moduleForPrefix(@Nonnull final String prefix) {
-        if (prefix.isEmpty() && !this.defaultPrefix.isEmpty()) {
-            return this.context.findModuleByName(this.defaultPrefix, null);
-        } else {
-            return this.context.findModuleByName(prefix, null);
-        }
+        final String moduleName = prefix.isEmpty() && !defaultPrefix.isEmpty() ? defaultPrefix : prefix;
+        return context.findModules(moduleName).stream().findFirst().orElse(null);
     }
 
     @Nonnull
@@ -53,7 +50,6 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr
     @Nullable
     @Override
     protected String prefixForNamespace(@Nonnull final URI namespace) {
-        final Module module = this.context.findModuleByNamespaceAndRevision(namespace, null);
-        return module == null ? null : module.getName();
+        return this.context.findModules(namespace).stream().findFirst().map(Module::getName).orElse(null);
     }
-}
\ No newline at end of file
+}