Add UnqualifiedQName.tryCreate()
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / QName.java
index fbd77df09a05b65c248cb6602596295513aa0c0d..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.
      *
@@ -298,18 +316,6 @@ public final class QName extends AbstractQName implements Comparable<QName> {
         return module.equals(namespace) ? this : super.bindTo(namespace);
     }
 
-    /**
-     * Returns a QName with the specified QNameModule and the same localname as this one.
-     *
-     * @param newModule New QNameModule to use
-     * @return a QName with specified QNameModule and same local name as this one
-     * @deprecated Use {@link #bindTo(QNameModule)} instead.
-     */
-    @Deprecated(forRemoval = true)
-    public @NonNull QName withModule(final QNameModule newModule) {
-        return bindTo(newModule);
-    }
-
     /**
      * Returns a QName with the same namespace and local name, but with no revision. If this QName does not have
      * a Revision, this object is returned.