X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fyang%2Fmodel%2Futil%2FBaseTypes.java;h=3f5d3ed6cca3689586fd886e09089b78e4cfb7a4;hb=9ceed566491d172e02220b04ec6869867f2f2473;hp=5e8a641fc393d89c090b45c24628be73077d5b1e;hpb=4ce0f6630bc576b97c8c9a08848aafb6e90a75b0;p=controller.git diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BaseTypes.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BaseTypes.java index 5e8a641fc3..3f5d3ed6cc 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BaseTypes.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BaseTypes.java @@ -1,46 +1,70 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.yang.model.util; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.controller.yang.common.QName; -import org.opendaylight.controller.yang.model.api.SchemaPath; - -public final class BaseTypes { - - private BaseTypes() {} - - public static final URI BaseTypesNamespace = URI - .create("urn:ietf:params:xml:ns:yang:1"); - - /** - * Construct QName for Built-in base Yang type. The namespace for - * built-in base yang types is defined as: urn:ietf:params:xml:ns:yang:1 - * - * @param typeName yang type name - * @return built-in base yang type QName. - */ - public static final QName constructQName(final String typeName) { - return new QName(BaseTypesNamespace, typeName); - } - - /** - * Creates Schema Path from Qname. - * - * @param typeName yang type QName - * @return Schema Path from Qname. - */ - public static final SchemaPath schemaPath(final QName typeName) { - final List pathList = new ArrayList(); - pathList.add(typeName); - return new SchemaPath(pathList, true); - } -} +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.yang.model.util; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.opendaylight.controller.yang.common.QName; +import org.opendaylight.controller.yang.model.api.SchemaPath; + +public final class BaseTypes { + + private BaseTypes() {} + + public static final URI BaseTypesNamespace = URI + .create("urn:ietf:params:xml:ns:yang:1"); + + /** + * Construct QName for Built-in base Yang type. The namespace for + * built-in base yang types is defined as: urn:ietf:params:xml:ns:yang:1 + * + * @param typeName yang type name + * @return built-in base yang type QName. + */ + public static final QName constructQName(final String typeName) { + return new QName(BaseTypesNamespace, typeName); + } + + /** + * Creates Schema Path from Qname. + * + * @param typeName yang type QName + * @return Schema Path from Qname. + */ + public static final SchemaPath schemaPath(final QName typeName) { + final List pathList = new ArrayList(); + pathList.add(typeName); + return new SchemaPath(pathList, true); + } + + /** + * Creates Schema Path from List of partial paths defined as Strings, module Namespace and + * module latest Revision Date. + * + * @param actualPath List of partial paths + * @param namespace Module Namespace + * @param revision Revision Date + * @return Schema Path + */ + public static final SchemaPath schemaPath(final List actualPath, final URI namespace, final Date revision) { + if (actualPath == null) { + throw new IllegalArgumentException("The actual path List MUST be specified."); + } + final List pathList = new ArrayList(); + for (final String path : actualPath) { + final QName qname = new QName(namespace, revision, path); + if (qname != null) { + pathList.add(qname); + } + } + return new SchemaPath(pathList, true); + } +}