Add AbstractQName.bindTo(QNameModule)
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / AbstractQName.java
index da1521b76df5092ad3630358b9a1754690c89ae9..6709ad94a7db79c306c68166c4fd98948d68fc00 100644 (file)
@@ -61,6 +61,17 @@ public abstract class AbstractQName implements Identifier, WritableObject {
     @Override
     public abstract String toString();
 
+    /**
+     * Returns a QName with the specified namespace and the same local name as this one.
+     *
+     * @param namespace New namespace to use
+     * @return a QName with specified QNameModule and same local name as this one
+     * @throws NullPointerException if namespace is null
+     */
+    public QName bindTo(final QNameModule namespace) {
+        return new QName(namespace, getLocalName());
+    }
+
     abstract Object writeReplace();
 
     static final String checkLocalName(final @Nullable String localName) {