/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.data.util;

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.annotations.Beta;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;

@Beta
public abstract class AbstractModuleStringIdentityrefCodec extends AbstractStringIdentityrefCodec {
    /**
     * Resolve a string prefix into the corresponding module.
     *
     * @param prefix Prefix
     * @return module mapped to prefix, or null if the module cannot be resolved
     */
    protected abstract Module moduleForPrefix(@Nonnull String prefix);

    @Override
    protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
        final Module module = moduleForPrefix(prefix);
        checkArgument(module != null, "Failed to lookup prefix %s", prefix);
        return QName.create(module.getQNameModule(), localName);
    }
}

@@ -549,16 +549,85 @@
 .QName;%0A
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;%0A
 import o
@@ -1297,24 +1297,25 @@
 refix);%0A
+%0A
         
 return Q
@@ -1306,22 +1306,35 @@
         
-return
+final QName qname =
  QName.c
@@ -1376,16 +1376,296 @@
 lName);%0A
+        for (IdentitySchemaNode identity : module.getIdentities()) %7B%0A            if (qname.equals(identity.getQName())) %7B%0A                return identity.getQName();%0A            %7D%0A        %7D%0A%0A        throw new IllegalArgumentException(%22Failed to find identity matching %22 + qname);%0A
     %7D%0A%7D%0A

Validate parsed QName to identity