Added more tests for yang parser. Updated current tests.
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / InstanceIdentifier.java
index e39b1fa02646feec0263417e1e39e54ac4d5585c..05dffc62d132c6c987d8b2d7fab2c65f68477f63 100644 (file)
@@ -1,15 +1,13 @@
 /*
 * 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
 */
+ * 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.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -20,45 +18,43 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition;
 
 /**
- * The <code>default</code> implementation of Instance Identifier Type Definition interface.
+ * The <code>default</code> implementation of Instance Identifier Type
+ * Definition interface.
  *
  * @see InstanceIdentifierTypeDefinition
  */
-public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
-
-    private static final QName name = BaseTypes
-            .constructQName("instance-identifier");
-    private static final String description = "The instance-identifier built-in type is used to " +
-               "uniquely identify a particular instance node in the data tree.";
+public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
+    private static final QName name = BaseTypes.constructQName("instance-identifier");
+    private static final String description = "The instance-identifier built-in type is used to "
+            + "uniquely identify a particular instance node in the data tree.";
     private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.13";
 
     private final transient SchemaPath path;
     private final RevisionAwareXPath xpath;
     private final String units = "";
     private final InstanceIdentifierTypeDefinition baseType;
-    private final boolean requireInstance;
+    private boolean requireInstance = true;
 
-    private InstanceIdentifier(RevisionAwareXPath xpath, boolean requireInstance) {
+    public InstanceIdentifier(final SchemaPath path, final RevisionAwareXPath xpath) {
         super();
-        path = BaseTypes.schemaPath(name);
+        this.path = path;
         this.xpath = xpath;
-        this.requireInstance = requireInstance;
         this.baseType = this;
     }
 
-    public InstanceIdentifier(final List<String> actualPath, final URI namespace,
-            final Date revision, RevisionAwareXPath xpath, boolean requireInstance) {
+    public InstanceIdentifier(final SchemaPath path, final RevisionAwareXPath xpath, final boolean requireInstance) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         this.requireInstance = requireInstance;
-        this.baseType = new InstanceIdentifier(xpath, requireInstance);
+        this.baseType = this;
     }
 
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public InstanceIdentifierTypeDefinition getBaseType() {
@@ -78,7 +74,9 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -108,7 +106,8 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
@@ -138,7 +137,9 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes
+     * ()
      */
     @Override
     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
@@ -148,8 +149,8 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#
-     * getPathStatement()
+     * @see org.opendaylight.controller.yang.model.api.type.
+     * InstanceIdentifierTypeDefinition# getPathStatement()
      */
     @Override
     public RevisionAwareXPath getPathStatement() {
@@ -159,8 +160,8 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#
-     * requireInstance()
+     * @see org.opendaylight.controller.yang.model.api.type.
+     * InstanceIdentifierTypeDefinition# requireInstance()
      */
     @Override
     public boolean requireInstance() {