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 / Leafref.java
index 21fdbde5fea6b7ede3d3ee8da8afa06e7e80c9d4..bd42903184b68a472bf93caa670fe752f1d0c34e 100644 (file)
@@ -1,10 +1,10 @@
 /*
 * 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.util.Collections;
@@ -18,37 +18,41 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
 
 /**
- * The <code>default</code> implementation of Instance Leafref Type Definition interface.
+ * The <code>default</code> implementation of Instance Leafref Type Definition
+ * interface.
  *
  * @see LeafrefTypeDefinition
  */
-public class Leafref implements LeafrefTypeDefinition {
+public final class Leafref implements LeafrefTypeDefinition {
     private static final QName name = BaseTypes.constructQName("leafref");
-    private static final String description = "The leafref type is used to reference a " +
-               "particular leaf instance in the data tree.";
+    private static final String description = "The leafref type is used to reference a "
+            + "particular leaf instance in the data tree.";
     private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";
-    private final SchemaPath path = BaseTypes.schemaPath(name);
+    private final SchemaPath path;
     private final RevisionAwareXPath xpath;
     private final String units = "";
+    private final LeafrefTypeDefinition baseType;
 
-    public Leafref(RevisionAwareXPath xpath) {
-        super();
+    public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
+        this.path = path;
         this.xpath = xpath;
+        baseType = this;
     }
 
     /*
      * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public LeafrefTypeDefinition getBaseType() {
-        return this;
+        return baseType;
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
@@ -58,8 +62,10 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -68,7 +74,7 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -78,7 +84,7 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -88,8 +94,9 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
@@ -98,7 +105,7 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
      */
     @Override
@@ -108,7 +115,7 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -118,8 +125,10 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (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() {
@@ -128,9 +137,10 @@ public class Leafref implements LeafrefTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see
-     * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition#getPathStatement()
+     * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition
+     * #getPathStatement()
      */
     @Override
     public RevisionAwareXPath getPathStatement() {