2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.util;
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.Date;
14 import java.util.List;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 public final class BaseTypes {
24 public static final URI BASE_TYPES_NAMESPACE = URI.create("urn:ietf:params:xml:ns:yang:1");
27 * Construct QName for Built-in base Yang type. The namespace for built-in
28 * base yang types is defined as: urn:ietf:params:xml:ns:yang:1
32 * @return built-in base yang type QName.
34 public static QName constructQName(final String typeName) {
35 return new QName(BASE_TYPES_NAMESPACE, typeName);
39 * Creates Schema Path from Qname.
43 * @return Schema Path from Qname.
45 public static SchemaPath schemaPath(final QName typeName) {
46 List<QName> pathList = Collections.singletonList(typeName);
47 return new SchemaPath(pathList, true);
51 * Creates Schema Path from List of partial paths defined as Strings, module
52 * Namespace and module latest Revision Date.
55 * List of partial paths
62 public static SchemaPath schemaPath(final List<String> actualPath, final URI namespace, final Date revision) {
63 if (actualPath == null) {
64 throw new IllegalArgumentException("The actual path List MUST be specified.");
66 final List<QName> pathList = new ArrayList<QName>();
67 for (final String path : actualPath) {
68 final QName qname = new QName(namespace, revision, path);
73 return new SchemaPath(pathList, true);