*/
package org.opendaylight.controller.yang.parser.util;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
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;
* @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);
}
/**
module.augmentResolved();
} else {
throw new YangParseException(module.getName(), line, "Target of type " + node.getClass()
- + " can not be augmented.");
+ + " cannot be augmented.");
}
}
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;
}