There are callers who are dealing with prefix being optional, possibly
added (or changed) in a later context. Add the ability to do that
without re-validating the local name.
JIRA: YANGTOOLS-1359
Change-Id: I099589d8a579f854dcc0ae1740027e7af24470bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
840bcc965c8eeb566d8cebd870f35e1be85cc617)
private final String prefix;
- private QualifiedQName(final String prefix, final String localName) {
+ QualifiedQName(final String prefix, final String localName) {
super(localName);
this.prefix = requireNonNull(prefix);
}
return isValidLocalName(localName) ? new UnqualifiedQName(localName) : null;
}
+ /**
+ * Return a {@link QualifiedQName} object bound to specified {@code prefix}.
+ *
+ * @return a {@link QualifiedQName} object bound to specified {@code prefix}
+ * @throws NullPointerException if {@code newPrefix} is null
+ */
+ public QualifiedQName withPrefix(final String newPrefix) {
+ return new QualifiedQName(newPrefix, getLocalName());
+ }
+
/**
* Read an UnqualifiedQName from a DataInput. The format is expected to match the output format of
* {@link #writeTo(DataOutput)}.