Take advantage of ANTLR keyword validation
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / QName.java
index 2aa4d96f82200c519ebfa18df6ceb51a33291f73..f70a736217a554bb2271dbcf4b2f507c07746473 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.common;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.annotations.Beta;
 import com.google.common.collect.Interner;
 import com.google.common.collect.Interners;
 import java.io.DataInput;
@@ -207,6 +208,23 @@ public final class QName extends AbstractQName implements Comparable<QName> {
         return new QName(module, checkLocalName(in.readUTF()));
     }
 
+    /**
+     * Creates new QName composed of specified module and local name. This method does not perform lexical checking of
+     * localName, and it is the caller's responsibility to performs these checks.
+     *
+     * <p>
+     * When in doubt, use {@link #create(QNameModule, String)} instead.
+     *
+     * @param qnameModule Namespace and revision enclosed as a QNameModule
+     * @param localName Local name part of QName, required to have been validated
+     * @return Instance of QName
+     * @throws NullPointerException if any of the arguments is null
+     */
+    @Beta
+    public static @NonNull QName unsafeOf(final @NonNull QNameModule qnameModule, final @NonNull String localName) {
+        return new QName(qnameModule, localName);
+    }
+
     /**
      * Get the module component of the QName.
      *