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");
25 public static final QName BINARY_QNAME = constructQName("binary");
26 public static final QName BITS_QNAME = constructQName("bits");
27 public static final QName BOOLEAN_QNAME = constructQName("boolean");
28 public static final QName DECIMAL64_QNAME = constructQName("decimal64");
29 public static final QName EMPTY_QNAME = constructQName("empty");
30 public static final QName ENUMERATION_QNAME = constructQName("enumeration");
31 public static final QName INT8_QNAME = constructQName("int8");
32 public static final QName INT16_QNAME = constructQName("int16");
33 public static final QName INT32_QNAME = constructQName("int32");
34 public static final QName INT64_QNAME = constructQName("int64");
35 public static final QName LEAFREF_QNAME = constructQName("leafref");
36 public static final QName STRING_QNAME = constructQName("string");
37 public static final QName UINT8_QNAME = constructQName("uint8");
38 public static final QName UINT16_QNAME = constructQName("uint16");
39 public static final QName UINT32_QNAME = constructQName("uint32");
40 public static final QName UINT64_QNAME = constructQName("uint64");
43 * Construct QName for Built-in base Yang type. The namespace for built-in
44 * base yang types is defined as: urn:ietf:params:xml:ns:yang:1
48 * @return built-in base yang type QName.
50 public static QName constructQName(final String typeName) {
51 return new QName(BASE_TYPES_NAMESPACE, typeName);
55 * Creates Schema Path from Qname.
59 * @return Schema Path from Qname.
61 public static SchemaPath schemaPath(final QName typeName) {
62 return SchemaPath.create(Collections.singletonList(typeName), true);
66 * Creates Schema Path from List of partial paths defined as Strings, module
67 * Namespace and module latest Revision Date.
70 * List of partial paths
77 public static SchemaPath schemaPath(final List<String> actualPath, final URI namespace, final Date revision) {
78 if (actualPath == null) {
79 throw new IllegalArgumentException("The actual path List MUST be specified.");
81 final List<QName> pathList = new ArrayList<QName>();
82 for (final String path : actualPath) {
83 final QName qname = new QName(namespace, revision, path);
88 return SchemaPath.create(pathList, true);