Propagate @Nonnull and @Nullable annotations
[yangtools.git] / yang / yang-data-codec-xml / src / main / java / org / opendaylight / yangtools / yang / data / codec / xml / XmlStringIdentityrefCodec.java
index baeb011097f55ed31e446f56b0e47744dd437912..fab629d649b11f66cba17ef1cbc5b37127abe222 100644 (file)
@@ -10,30 +10,28 @@ package org.opendaylight.yangtools.yang.data.codec.xml;
 
 import com.google.common.base.Preconditions;
 import java.net.URI;
+import javax.annotation.Nonnull;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringIdentityrefCodec;
+import org.opendaylight.yangtools.yang.data.util.ModuleStringIdentityrefCodec;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-final class XmlStringIdentityrefCodec extends AbstractModuleStringIdentityrefCodec implements XmlCodec<QName> {
+final class XmlStringIdentityrefCodec extends ModuleStringIdentityrefCodec implements XmlCodec<QName> {
 
-    private final SchemaContext context;
-    private final QNameModule parentModuleQname;
     private final NamespaceContext namespaceContext;
 
     XmlStringIdentityrefCodec(final SchemaContext context, final QNameModule parentModule,
                               final NamespaceContext namespaceContext) {
-        this.context = Preconditions.checkNotNull(context);
-        this.parentModuleQname = Preconditions.checkNotNull(parentModule);
+        super(context, parentModule);
         this.namespaceContext = Preconditions.checkNotNull(namespaceContext);
     }
 
     @Override
-    protected Module moduleForPrefix(final String prefix) {
+    protected Module moduleForPrefix(@Nonnull final String prefix) {
         if (prefix.isEmpty()) {
             return context.findModuleByNamespaceAndRevision(parentModuleQname.getNamespace(),
                     parentModuleQname.getRevision());
@@ -43,12 +41,6 @@ final class XmlStringIdentityrefCodec extends AbstractModuleStringIdentityrefCod
         }
     }
 
-    @Override
-    protected String prefixForNamespace(final URI namespace) {
-        final Module module = context.findModuleByNamespaceAndRevision(namespace, null);
-        return module == null ? null : module.getName();
-    }
-
     /**
      * Serialize QName with specified XMLStreamWriter.
      *