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 QName BINARY_QNAME = constructQName("binary");
26 public static QName BITS_QNAME = constructQName("bits");
27 public static QName BOOLEAN_QNAME = constructQName("boolean");
28 public static QName DECIMAL64_QNAME = constructQName("decimal64");
29 public static QName EMPTY_QNAME = constructQName("empty");
30 public static QName ENUMERATION_QNAME = constructQName("enumeration");
31 public static QName INT8_QNAME = constructQName("int8");
32 public static QName INT16_QNAME = constructQName("int16");
33 public static QName INT32_QNAME = constructQName("int32");
34 public static QName INT64_QNAME = constructQName("int64");
35 public static QName LEAFREF_QNAME = constructQName("leafref");
36 public static QName STRING_QNAME = constructQName("string");
37 public static QName UINT8_QNAME = constructQName("uint8");
38 public static QName UINT16_QNAME = constructQName("uint16");
39 public static QName UINT32_QNAME = constructQName("uint32");
40 public static 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 List<QName> pathList = Collections.singletonList(typeName);
63 return new SchemaPath(pathList, true);
67 * Creates Schema Path from List of partial paths defined as Strings, module
68 * Namespace and module latest Revision Date.
71 * List of partial paths
78 public static SchemaPath schemaPath(final List<String> actualPath, final URI namespace, final Date revision) {
79 if (actualPath == null) {
80 throw new IllegalArgumentException("The actual path List MUST be specified.");
82 final List<QName> pathList = new ArrayList<QName>();
83 for (final String path : actualPath) {
84 final QName qname = new QName(namespace, revision, path);
89 return new SchemaPath(pathList, true);