Projects moved under correct parent.
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / parser / util / ParserUtils.java
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.parser.util;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -93,6 +94,7 @@ import org.opendaylight.controller.yang.parser.builder.impl.ConstraintsBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.ContainerSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.ContainerSchemaNodeBuilder.ContainerSchemaNodeImpl;
 import org.opendaylight.controller.yang.parser.builder.impl.GroupingBuilderImpl;
+import org.opendaylight.controller.yang.parser.builder.impl.IdentityrefTypeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.LeafListSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.LeafSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.ListSchemaNodeBuilder;
@@ -121,12 +123,15 @@ public final class ParserUtils {
      * @param name
      * @return
      */
-    public static SchemaPath createSchemaPath(SchemaPath schemaPath, String name) {
-        List<QName> path = new ArrayList<QName>(schemaPath.getPath());
-        QName last = path.get(path.size() - 1);
-        QName newQName = new QName(last.getNamespace(), last.getRevision(), last.getPrefix(), name);
+    public static SchemaPath createSchemaPath(SchemaPath schemaPath, String name, URI namespace, Date revision, String prefix) {
+        List<QName> path = new ArrayList<QName>();
+        if(schemaPath != null) {
+            path.addAll(schemaPath.getPath());
+        }
+        QName newQName = new QName(namespace, revision, prefix, name);
         path.add(newQName);
-        return new SchemaPath(path, schemaPath.isAbsolute());
+        boolean abs = schemaPath == null ? true : schemaPath.isAbsolute();
+        return new SchemaPath(path, abs);
     }
 
     /**
@@ -997,7 +1002,7 @@ public final class ParserUtils {
             module.augmentResolved();
         } else {
             throw new YangParseException(module.getName(), line, "Target of type " + node.getClass()
-                    + " can not be augmented.");
+                    + " cannot be augmented.");
         }
     }
 
@@ -1173,8 +1178,8 @@ public final class ParserUtils {
             final TypeConstraints constraints, final Map<String, TreeMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder builder, final SchemaContext context) {
 
-        // union type cannot be restricted
-        if (nodeToResolve instanceof UnionTypeBuilder) {
+        // union and identityref types cannot be restricted
+        if (nodeToResolve instanceof UnionTypeBuilder || nodeToResolve instanceof IdentityrefTypeBuilder) {
             return constraints;
         }