import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import java.io.Serializable;
private static final Pattern QNAME_PATTERN_NO_NAMESPACE_NO_REVISION =
Pattern.compile(QNAME_STRING_NO_NAMESPACE_NO_REVISION);
- private static final char[] ILLEGAL_CHARACTERS = new char[] { '?', '(', ')', '&', ':' };
+ private static final char[] ILLEGAL_CHARACTERS = { '?', '(', ')', '&', ':' };
// Non-null
private final QNameModule module;
private static String checkLocalName(final String localName) {
Preconditions.checkArgument(localName != null, "Parameter 'localName' may not be null.");
- Preconditions.checkArgument(!Strings.isNullOrEmpty(localName), "Parameter 'localName' must be a non-empty string.");
+ Preconditions.checkArgument(!localName.isEmpty(), "Parameter 'localName' must be a non-empty string.");
for (final char c : ILLEGAL_CHARACTERS) {
if (localName.indexOf(c) != -1) {
- throw new IllegalArgumentException(String.format(
- "Parameter 'localName':'%s' contains illegal character '%s'", localName, c));
+ throw new IllegalArgumentException("Parameter 'localName':'" + localName
+ + "' contains illegal character '" + c + "'");
}
}
return localName;
try {
return new URI(namespace);
} catch (final URISyntaxException ue) {
- throw new IllegalArgumentException(String.format("Namespace '%s' is not a valid URI", namespace), ue);
+ throw new IllegalArgumentException("Namespace '" + namespace + "' is not a valid URI", ue);
}
}
/**
* Creates copy of this with revision and prefix unset.
+ * 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
+ */
+ public QName withModule(@Nonnull final QNameModule newModule) {
+ return new QName(newModule, localName);
+ }
+
+ /**
+ * 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 retured.
*
* @return copy of this QName with revision and prefix unset.
*/