We need to validate if parsed QName refers to an existing identity,
this fixes up unused AbstractModuleStringIdentityrefCodec to check
Module references.
Change-Id: Iebbb43681e9b384c43bd81607d169294373bdd72
JIRA: YANGTOOLS-846
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
86ed935221b79680e8aca7a5e561fed6d89ed084)
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
@Beta
import org.opendaylight.yangtools.yang.model.api.Module;
@Beta
protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
final Module module = moduleForPrefix(prefix);
Preconditions.checkArgument(module != null, "Failed to lookup prefix %s", prefix);
protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
final Module module = moduleForPrefix(prefix);
Preconditions.checkArgument(module != null, "Failed to lookup prefix %s", prefix);
- return QName.create(module.getQNameModule(), localName);
+
+ final QName qname = QName.create(module.getQNameModule(), localName);
+ for (IdentitySchemaNode identity : module.getIdentities()) {
+ if (qname.equals(identity.getQName())) {
+ return identity.getQName();
+ }
+ }
+
+ throw new IllegalArgumentException("Failed to find identity matching " + qname);