Reduce the use of AttrBuilders
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / rest / impl / StringModuleInstanceIdentifierCodec.java
index f119a148e31d114723303f59c449eb698a804651..ef0c8a3eb588a303fa017709cc6f131774a0ddf9 100644 (file)
@@ -20,8 +20,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 /**
  * Codec for module instance identifiers.
  *
- * @deprecated This class will be replaced by
- *             {@link org.opendaylight.restconf.jersey.providers.StringModuleInstanceIdentifierCodec}
+ * @deprecated This class will be replaced by StringModuleInstanceIdentifierCodec from restconf-nb-rfc8040
  */
 @Deprecated
 public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStringInstanceIdentifierCodec {
@@ -45,9 +44,9 @@ 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);
+            return this.context.findModules(this.defaultPrefix).stream().findFirst().orElse(null);
         } else {
-            return this.context.findModuleByName(prefix, null);
+            return this.context.findModules(prefix).stream().findFirst().orElse(null);
         }
     }
 
@@ -60,7 +59,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