Refactored SchemaPath for yang java types. Fixed SchemaPath for augmented nodes types. 78/678/1
authorMartin Vitez <mvitez@cisco.com>
Thu, 30 May 2013 14:03:54 +0000 (16:03 +0200)
committerMartin Vitez <mvitez@cisco.com>
Wed, 24 Jul 2013 11:44:52 +0000 (13:44 +0200)
Updated yang java types constructors. Updated tests accordingly.

Change-Id: Ifeb1ddc96c89350579c837414dceeab624ef17ab
Signed-off-by: Martin Vitez <mvitez@cisco.com>
24 files changed:
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractSignedInteger.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractUnsignedInteger.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BinaryType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BitsType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BooleanType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Decimal64.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EmptyType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EnumerationType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java [deleted file]
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityrefType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/InstanceIdentifier.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int16.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int32.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int64.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int8.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Leafref.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/StringType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint16.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint32.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint64.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint8.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/UnionType.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java

index c2ae7d304a8c1ca9bae54b109e94f3b46d023ef4..0af3c81c6ac3e570c716a3376cf3549d8f3f16fe 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -67,13 +65,12 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
      * @param maxRange
      * @param units
      */
-    public AbstractSignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractSignedInteger(final SchemaPath path, final QName name,
             final String description, final Number minRange,
             final Number maxRange, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = new ArrayList<RangeConstraint>();
         final String rangeDescription = "Integer values between " + minRange
@@ -89,13 +86,12 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
      * @param rangeStatements
      * @param units
      */
-    public AbstractSignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractSignedInteger(final SchemaPath path, final QName name,
             final String description,
             final List<RangeConstraint> rangeStatements, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = rangeStatements;
     }
index 31a62ececda6f4e2a652adac5b7c90449be0c837..013d80d79911c127ef4f3823a2fc996bf70c044f 100644 (file)
@@ -3,10 +3,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -68,13 +66,12 @@ public abstract class AbstractUnsignedInteger implements
      * @param maxRange
      * @param units
      */
-    public AbstractUnsignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractUnsignedInteger(final SchemaPath path, final QName name,
             final String description, final Number minRange,
             final Number maxRange, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = new ArrayList<RangeConstraint>();
         final String rangeDescription = "Integer values between " + minRange
@@ -90,13 +87,12 @@ public abstract class AbstractUnsignedInteger implements
      * @param rangeStatements
      * @param units
      */
-    public AbstractUnsignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractUnsignedInteger(final SchemaPath path, final QName name,
             final String description,
             final List<RangeConstraint> rangeStatements, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = rangeStatements;
     }
index 253fe484f0459a7f410014814a549166c5477dbd..74214dc0c77973a9f5b07777ea77d0735c33f9fc 100644 (file)
@@ -1,16 +1,14 @@
 /*
 * 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.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -25,7 +23,7 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
  *
  * @see BinaryTypeDefinition
  */
-public class BinaryType implements BinaryTypeDefinition {
+public final class BinaryType implements BinaryTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("binary");
     private final SchemaPath path;
@@ -40,22 +38,23 @@ public class BinaryType implements BinaryTypeDefinition {
         super();
 
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
+                ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
         this.path = BaseTypes.schemaPath(name);
         this.baseType = this;
     }
 
-    public BinaryType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BinaryType(final SchemaPath path) {
         super();
 
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
+                ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BinaryType();
     }
 
@@ -66,20 +65,21 @@ public class BinaryType implements BinaryTypeDefinition {
      * @param lengthConstraints
      * @param units
      */
-    public BinaryType(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<Byte> bytes,
+    public BinaryType(final SchemaPath path, final List<Byte> bytes,
             final List<LengthConstraint> lengthConstraints, final String units) {
         super();
 
         if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE,
+                    "", ""));
             this.lengthConstraints = Collections.unmodifiableList(constraints);
         } else {
-            this.lengthConstraints = Collections.unmodifiableList(lengthConstraints);
+            this.lengthConstraints = Collections
+                    .unmodifiableList(lengthConstraints);
         }
 
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.bytes = Collections.unmodifiableList(bytes);
         this.units = units;
         this.baseType = new BinaryType();
@@ -88,7 +88,8 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public BinaryTypeDefinition getBaseType() {
@@ -108,7 +109,9 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -138,7 +141,8 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
@@ -169,8 +173,8 @@ public class BinaryType implements BinaryTypeDefinition {
      * (non-Javadoc)
      *
      * @see
-     * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint
-     * ()
+     * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition
+     * #getLengthConstraint ()
      */
     @Override
     public List<LengthConstraint> getLengthConstraints() {
@@ -191,7 +195,8 @@ public class BinaryType implements BinaryTypeDefinition {
                 + ((description == null) ? 0 : description.hashCode());
         result = prime
                 * result
-                + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
+                + ((lengthConstraints == null) ? 0 : lengthConstraints
+                        .hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
         result = prime * result
index 717c24ed5083c2b89cc47fd0fa9a6b473aaa4d6d..51e0306e8b8737c1e7450c6fe60a8767b6c43280 100644 (file)
@@ -7,9 +7,7 @@
  */
 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;
@@ -23,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
  *
  * @see BitsTypeDefinition
  */
-public class BitsType implements BitsTypeDefinition {
+public final class BitsType implements BitsTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("bits");
     private final SchemaPath path;
@@ -47,11 +45,10 @@ public class BitsType implements BitsTypeDefinition {
         this.baseType = this;
     }
 
-    public BitsType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BitsType(final SchemaPath path) {
         super();
         this.bits = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
@@ -64,12 +61,11 @@ public class BitsType implements BitsTypeDefinition {
      * @param bits
      *            The bits assigned for Bits Type
      */
-    public BitsType(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<Bit> bits) {
+    public BitsType(final SchemaPath path, final List<Bit> bits) {
         super();
         this.bits = Collections.unmodifiableList(bits);
         this.units = "";
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
@@ -83,12 +79,11 @@ public class BitsType implements BitsTypeDefinition {
      * @param units
      *            units for bits type
      */
-    public BitsType(final List<String> actualPath, final URI namespace,
-            final Date revision, List<Bit> bits, String units) {
+    public BitsType(final SchemaPath path, List<Bit> bits, String units) {
         super();
         this.bits = Collections.unmodifiableList(bits);
         this.units = units;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
index f588bf425c9ae4ed2f6deabd91cf723bc6b9d2fd..0cda67c27fe2cf7158c8561bdb44281fb1f24b48 100644 (file)
@@ -7,9 +7,7 @@
  */
 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;
@@ -23,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
  *
  * @see BooleanTypeDefinition
  */
-public class BooleanType implements BooleanTypeDefinition {
+public final class BooleanType implements BooleanTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("boolean");
     private final SchemaPath path;
@@ -43,11 +41,10 @@ public class BooleanType implements BooleanTypeDefinition {
         this.baseType = this;
     }
 
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BooleanType(final SchemaPath path) {
         super();
         this.defaultValue = false;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
@@ -57,11 +54,10 @@ public class BooleanType implements BooleanTypeDefinition {
      * @param defaultValue
      *            Default Value
      */
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision, final Boolean defaultValue) {
+    public BooleanType(final SchemaPath path, final Boolean defaultValue) {
         super();
         this.defaultValue = defaultValue;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
@@ -73,12 +69,11 @@ public class BooleanType implements BooleanTypeDefinition {
      * @param units
      *            Units
      */
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision, final Boolean defaultValue, final String units) {
+    public BooleanType(final SchemaPath path, final Boolean defaultValue, final String units) {
         super();
         this.defaultValue = defaultValue;
         this.units = units;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
index adb4c1a3cb00a21f6993c4de9e8140cc86d29674..6a070837bd8e9f3f79cec5c02639ffbdd7f0965b 100644 (file)
@@ -8,10 +8,8 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigDecimal;
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -27,7 +25,7 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  * @see DecimalTypeDefinition
  */
-public class Decimal64 implements DecimalTypeDefinition {
+public final class Decimal64 implements DecimalTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
@@ -73,8 +71,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         this.baseType = this;
     }
 
-    public Decimal64(final List<String> actualPath, final URI namespace,
-            final Date revision, final Integer fractionDigits) {
+    public Decimal64(final SchemaPath path, final Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
             throw new IllegalArgumentException(
@@ -82,7 +79,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         }
         this.fractionDigits = fractionDigits;
         rangeStatements = defaultRangeStatements();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
@@ -109,8 +106,7 @@ public class Decimal64 implements DecimalTypeDefinition {
      *            integer between 1 and 18 inclusively
      * @exception IllegalArgumentException
      */
-    public Decimal64(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
+    public Decimal64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
@@ -124,7 +120,7 @@ public class Decimal64 implements DecimalTypeDefinition {
                     .unmodifiableList(rangeStatements);
         }
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
@@ -153,8 +149,7 @@ public class Decimal64 implements DecimalTypeDefinition {
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
      */
-    public Decimal64(final List<String> actualPath, final URI namespace,
-            final Date revision, final String units,
+    public Decimal64(final SchemaPath path, final String units,
             final BigDecimal defaultValue,
             final List<RangeConstraint> rangeStatements,
             final Integer fractionDigits) {
@@ -174,7 +169,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         this.units = units;
         this.defaultValue = defaultValue;
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(name);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
index 1b5abb22093080657f00037ecd2e017324214c03..424f313efae6b20ccf35cf78e6b12057594114e0 100644 (file)
@@ -7,9 +7,7 @@
  */
 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;
@@ -18,7 +16,7 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
 
-public class EmptyType implements EmptyTypeDefinition {
+public final class EmptyType implements EmptyTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("empty");
     private final SchemaPath path;
@@ -31,9 +29,8 @@ public class EmptyType implements EmptyTypeDefinition {
         this.baseType = this;
     }
 
-    public EmptyType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+    public EmptyType(final SchemaPath path) {
+        this.path = path;
         this.baseType = new EmptyType();
     }
 
index c825390f38d98415c8fab8250a27f213816edbbc..175ea100ca0919c51f8f9a08e841bc9b13cffc9e 100644 (file)
@@ -7,9 +7,7 @@
   */
 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,10 +18,10 @@ import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
 
 /**
  * The <code>default</code> implementation of Enumertaion Type Definition interface.
- * 
+ *
  * @see EnumTypeDefinition
  */
-public class EnumerationType implements EnumTypeDefinition {
+public final class EnumerationType implements EnumTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("enumeration");
     private final SchemaPath path;
@@ -34,29 +32,27 @@ public class EnumerationType implements EnumTypeDefinition {
     private final List<EnumPair> enums;
     private String units = "";
     private final EnumTypeDefinition baseType;
-    
+
     private EnumerationType(final List<EnumPair> enums) {
         this.path = BaseTypes.schemaPath(name);
         this.enums = Collections.unmodifiableList(enums);
         this.defaultEnum = null;
         baseType = this;
     }
-    
-    public EnumerationType(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<EnumPair> enums) {
+
+    public EnumerationType(final SchemaPath path, final List<EnumPair> enums) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.enums = Collections.unmodifiableList(enums);
         this.defaultEnum = null;
         baseType = new EnumerationType(enums);
     }
 
-    public EnumerationType(final List<String> actualPath, final URI namespace,
-            final Date revision, final EnumTypeDefinition baseType, final EnumPair defaultEnum,
+    public EnumerationType(final SchemaPath path, final EnumPair defaultEnum,
             final List<EnumPair> enums, final String units) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
-        this.baseType = baseType;
+        this.path = path;
+        baseType = new EnumerationType(enums);
         this.defaultEnum = defaultEnum;
         this.enums = Collections.unmodifiableList(enums);
         this.units = units;
@@ -64,7 +60,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
@@ -74,7 +70,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
@@ -84,7 +80,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
      */
     @Override
@@ -94,7 +90,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -104,7 +100,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -114,7 +110,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
@@ -124,7 +120,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
      */
     @Override
@@ -134,7 +130,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -144,7 +140,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()
      */
     @Override
diff --git a/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java b/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java
deleted file mode 100644 (file)
index 0c180d7..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
-  * 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;
-import java.util.List;
-
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.Status;
-import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.controller.yang.model.api.type.IdentityTypeDefinition;
-
-/**
- * The <code>default</code> implementation of Identity Type Definition interface.
- * 
- * @see IdentityTypeDefinition
- */
-public class IdentityType implements IdentityTypeDefinition {
-
-    private final QName name = BaseTypes.constructQName("identity");
-    private final SchemaPath path = BaseTypes.schemaPath(name);
-    private final String description = "The 'identity' statement is used to define a new " +
-               "globally unique, abstract, and untyped identity.";
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-7.16";
-
-    private String units = "";
-    private final QName identityName;
-
-    public IdentityType(QName identityName) {
-        super();
-        this.identityName = identityName;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public IdentityTypeDefinition getBaseType() {
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
-     */
-    @Override
-    public String getUnits() {
-        return units;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
-     */
-    @Override
-    public QName getQName() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
-     */
-    @Override
-    public SchemaPath getPath() {
-        return path;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
-     */
-    @Override
-    public String getDescription() {
-        return description;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
-     */
-    @Override
-    public String getReference() {
-        return reference;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
-     */
-    @Override
-    public Status getStatus() {
-        return Status.CURRENT;
-    }
-
-    @Override
-    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
-        return Collections.emptyList();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opendaylight.controller.yang.model.base.type.api.IdentityTypeDefinition#getIdentityName
-     * ()
-     */
-    @Override
-    public QName getIdentityName() {
-        return identityName;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
-        result = prime * result
-                + ((identityName == null) ? 0 : identityName.hashCode());
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        IdentityType other = (IdentityType) obj;
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
-        if (identityName == null) {
-            if (other.identityName != null) {
-                return false;
-            }
-        } else if (!identityName.equals(other.identityName)) {
-            return false;
-        }
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
-            return false;
-        }
-        if (path == null) {
-            if (other.path != null) {
-                return false;
-            }
-        } else if (!path.equals(other.path)) {
-            return false;
-        }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("IdentityType [name=");
-        builder.append(name);
-        builder.append(", path=");
-        builder.append(path);
-        builder.append(", description=");
-        builder.append(description);
-        builder.append(", reference=");
-        builder.append(reference);
-        builder.append(", units=");
-        builder.append(units);
-        builder.append(", identityName=");
-        builder.append(identityName);
-        builder.append("]");
-        return builder.toString();
-    }
-}
index 533318e39e3c15e8ac5fc1fcde2ac5d36fb669f0..6c4598131e496b405e1183ae521b44e507fb00ce 100644 (file)
@@ -7,9 +7,7 @@
   */\r
 package org.opendaylight.controller.yang.model.util;\r
 \r
-import java.net.URI;\r
 import java.util.Collections;\r
-import java.util.Date;\r
 import java.util.List;\r
 \r
 import org.opendaylight.controller.yang.common.QName;\r
@@ -23,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition
  *\r
  * @see IdentityrefTypeDefinition\r
  */\r
-public class IdentityrefType implements IdentityrefTypeDefinition {\r
+public final class IdentityrefType implements IdentityrefTypeDefinition {\r
 \r
     private final QName name = BaseTypes.constructQName("identityref");\r
     private final SchemaPath path;\r
@@ -47,13 +45,6 @@ public class IdentityrefType implements IdentityrefTypeDefinition {
         this.baseType = new IdentityrefType(identity);\r
     }\r
 \r
-    public IdentityrefType(final List<String> actualPath,\r
-            final URI namespace, final Date revision, final QName identity) {\r
-        this.identity = identity;\r
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);\r
-        this.baseType = new IdentityrefType(identity);\r
-    }\r
-\r
     @Override\r
     public String getUnits() {\r
         return units;\r
index e39b1fa02646feec0263417e1e39e54ac4d5585c..4c17fa6154248fb711c7bd844feb60e65cfd4ba3 100644 (file)
@@ -7,9 +7,7 @@
   */
 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;
@@ -24,7 +22,7 @@ import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDef
  *
  * @see InstanceIdentifierTypeDefinition
  */
-public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
+public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
 
     private static final QName name = BaseTypes
             .constructQName("instance-identifier");
@@ -46,10 +44,9 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
         this.baseType = this;
     }
 
-    public InstanceIdentifier(final List<String> actualPath, final URI namespace,
-            final Date revision, RevisionAwareXPath xpath, boolean requireInstance) {
+    public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         this.requireInstance = requireInstance;
         this.baseType = new InstanceIdentifier(xpath, requireInstance);
index 0e100dc79077d846d2f0ae83ce3dd4768cefdcec..0a24bf2d059166a65345775cbd34734e83813005 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
@@ -22,12 +21,11 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  * @see AbstractSignedInteger
  */
-public class Int16 extends AbstractSignedInteger {
+public final class Int16 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int16");
     private Short defaultValue = null;
-    private static final String description =
-            "int16  represents integer values between -32768 and 32767, inclusively.";
+    private static final String description = "int16  represents integer values between -32768 and 32767, inclusively.";
     private final IntegerTypeDefinition baseType;
 
     private Int16() {
@@ -35,17 +33,16 @@ public class Int16 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int16(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Int16(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Int16();
 
     }
 
-    public Int16(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final Short defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Int16(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final Short defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.defaultValue = defaultValue;
         this.baseType = new Int16();
     }
index fb777c5992399aed543986684f2e94acd0531cd6..8d16e268c35c610750d6e129cbcc1d1ad6882e13 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
@@ -24,12 +23,11 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * @see AbstractSignedInteger
  *
  */
-public class Int32 extends AbstractSignedInteger {
+public final class Int32 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int32");
     private Integer defaultValue = null;
-    private static final String description =
-            "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
+    private static final String description = "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
     private final IntegerTypeDefinition baseType;
 
     private Int32() {
@@ -37,23 +35,21 @@ public class Int32 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int32(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int32(final SchemaPath path) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int32();
     }
 
-    public Int32(final List<String> actualPath, final URI namespace,
-            final Date revision, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int32(final SchemaPath path, final Integer defaultValue) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int32();
         this.defaultValue = defaultValue;
     }
 
-    public Int32(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Int32(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final Integer defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Int32();
         this.defaultValue = defaultValue;
     }
index b22412012b0e8d54c8bbe3819dd09ba1678f255d..92e92a94a276b8ee22b8c51932db82c5b40d4ea8 100644 (file)
@@ -7,11 +7,10 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
@@ -22,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * {@link Long}.
  *
  */
-public class Int64 extends AbstractSignedInteger {
+public final class Int64 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int64");
     private Long defaultValue = null;
@@ -35,23 +34,20 @@ public class Int64 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int64(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int64(final SchemaPath path) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int64();
     }
 
-    public Int64(final List<String> actualPath, final URI namespace,
-            final Date revision, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int64(final SchemaPath path, final Long defaultValue) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int64();
         this.defaultValue = defaultValue;
     }
 
-    public Int64(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
+    public Int64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Int64();
         this.defaultValue = defaultValue;
     }
index 8b0fbe1fa7148197807db9ebbfc2e6b1b997091f..f77eebad5223cdc32476ccafa219c873e6d9329d 100644 (file)
@@ -1,34 +1,31 @@
 /*
 * 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.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
- * Implementation of Yang int8 built-in type.
- * <br>
- * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of
- * Yang int8 built-in type is {@link Byte}.
+ * Implementation of Yang int8 built-in type. <br>
+ * int8 represents integer values between -128 and 127, inclusively. The Java
+ * counterpart of Yang int8 built-in type is {@link Byte}.
  *
  * @see AbstractSignedInteger
  */
-public class Int8 extends AbstractSignedInteger {
+public final class Int8 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int8");
     private Byte defaultValue = null;
-    private static final String description =
-            "represents integer values between -128 and 127, inclusively.";
+    private static final String description = "represents integer values between -128 and 127, inclusively.";
     private final IntegerTypeDefinition baseType;
 
     private Int8() {
@@ -36,23 +33,21 @@ public class Int8 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int8(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
+    public Int8(final SchemaPath path) {
+        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
         this.baseType = new Int8();
     }
 
-    public Int8(final List<String> actualPath, final URI namespace,
-            final Date revision, final Byte defaultValue) {
-        super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
+    public Int8(final SchemaPath path, final Byte defaultValue) {
+        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
         this.baseType = new Int8();
         this.defaultValue = defaultValue;
     }
 
-    public Int8(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final Byte defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Int8(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final Byte defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Int8();
         this.defaultValue = defaultValue;
     }
@@ -60,7 +55,8 @@ public class Int8 extends AbstractSignedInteger {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public IntegerTypeDefinition getBaseType() {
@@ -70,7 +66,9 @@ public class Int8 extends AbstractSignedInteger {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
index a143f5a629a90c8440b0bd850e927963bb19dbf9..d17843af898b44adb1d6a5b2c9d140e446e2675b 100644 (file)
@@ -7,9 +7,7 @@
  */
 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;
@@ -25,7 +23,7 @@ import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
  *
  * @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.";
@@ -41,23 +39,13 @@ public class Leafref implements LeafrefTypeDefinition {
         this.baseType = this;
     }
 
-    public Leafref(final List<String> actualPath, final URI namespace,
-            final Date revision, final RevisionAwareXPath xpath) {
+    public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         baseType = new Leafref(xpath);
     }
 
-    public Leafref(final List<String> actualPath, final URI namespace,
-            final Date revision, final LeafrefTypeDefinition baseType,
-            final RevisionAwareXPath xpath) {
-        super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
-        this.xpath = xpath;
-        this.baseType = baseType;
-    }
-
     /*
      * (non-Javadoc)
      *
index 39865a9ddf4e00eb3a9977687dfdfaa6411a7484..2d6a78988752de136af601dd70ab40713cfa9a9e 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang.model.api.SchemaNode;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
 
 public final class SchemaContextUtil {
 
@@ -32,7 +33,7 @@ public final class SchemaContextUtil {
     public static DataSchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
         if (schemaPath != null) {
             final Module module = resolveModuleFromSchemaPath(context, schemaPath);
-            final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath()); 
+            final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath());
 
             if ((module != null) && (prefixedPath != null)) {
                 return findSchemaNodeForGivenPath(context, module, prefixedPath);
@@ -54,7 +55,7 @@ public final class SchemaContextUtil {
                     final Queue<QName> qnamedPath = xpathToQNamePath(context, module,
                             strXPath);
                     if (qnamedPath != null) {
-                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
                                 module, qnamedPath);
                         return dataNode;
                     }
@@ -64,7 +65,7 @@ public final class SchemaContextUtil {
         return null;
     }
 
-    public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, 
+    public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context,
             final Module module, final SchemaNode actualSchemaNode,
             final RevisionAwareXPath relativeXPath) {
         if ((actualSchemaNode != null) && (relativeXPath != null)
@@ -72,11 +73,11 @@ public final class SchemaContextUtil {
 
             final SchemaPath actualNodePath = actualSchemaNode.getPath();
             if (actualNodePath != null) {
-                final Queue<QName> qnamePath = resolveRelativeXPath(context, module, 
+                final Queue<QName> qnamePath = resolveRelativeXPath(context, module,
                         relativeXPath, actualNodePath);
 
                 if (qnamePath != null) {
-                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
                             module, qnamePath);
                     return dataNode;
                 }
@@ -88,7 +89,8 @@ public final class SchemaContextUtil {
 
     public static Module resolveModuleFromSchemaPath(final SchemaContext context, final SchemaPath schemaPath) {
         if ((schemaPath != null) && (schemaPath.getPath() != null)) {
-            final QName qname = schemaPath.getPath().get(0);
+            List<QName> path = schemaPath.getPath();
+            final QName qname = path.get(path.size()-1);
 
             if ((qname != null) && (qname.getNamespace() != null)) {
                 return context.findModuleByNamespace(qname.getNamespace());
@@ -97,6 +99,30 @@ public final class SchemaContextUtil {
         return null;
     }
 
+    public static Module resolveModuleFromTypePath(final SchemaContext context, final TypeDefinition<?> type) {
+        final SchemaPath schemaPath = type.getPath();
+        if ((schemaPath != null) && (schemaPath.getPath() != null)) {
+            if(type instanceof ExtendedType) {
+                List<QName> path = schemaPath.getPath();
+                final QName qname = path.get(path.size()-1);
+
+                if ((qname != null) && (qname.getNamespace() != null)) {
+                    return context.findModuleByNamespace(qname.getNamespace());
+                }
+            } else {
+                LinkedList<QName> path = new LinkedList<QName>(schemaPath.getPath());
+                path.removeLast();
+                final QName qname = path.get(path.size()-1);
+
+                if ((qname != null) && (qname.getNamespace() != null)) {
+                    return context.findModuleByNamespace(qname.getNamespace());
+                }
+            }
+
+        }
+        return null;
+    }
+
     public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
         if (context == null) {
             throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
@@ -133,7 +159,7 @@ public final class SchemaContextUtil {
                 childNodeQName = qnamedPath.peek();
                 if (childNodeQName != null) {
                     final URI childNodeNamespace = childNodeQName.getNamespace();
-                    
+
                     schemaNode = nextNode.getDataChildByName(childNodeQName);
                     if (schemaNode != null) {
                         if (schemaNode instanceof ContainerSchemaNode) {
@@ -229,7 +255,7 @@ public final class SchemaContextUtil {
                     }
                     final List<QName> path = leafrefSchemaPath.getPath();
                     if (path != null) {
-                        int lenght = path.size() - colCount;
+                        int lenght = path.size() - colCount - 1;
                         for (int i = 0; i < lenght; ++i) {
                             absolutePath.add(path.get(i));
                         }
index b4e2d6b9ad867dd3e4c3fac226be78c0fdd7a774..018ba00042d7ec27e9ee9c182c74ea56effdb98b 100644 (file)
@@ -7,10 +7,8 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -26,9 +24,9 @@ import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
  *
  * @see StringTypeDefinition
  */
-public class StringType implements StringTypeDefinition {
+public final class StringType implements StringTypeDefinition {
 
-    private final QName name = BaseTypes.constructQName("string");;
+    private final QName name = BaseTypes.constructQName("string");
     private final SchemaPath path;
     private String defaultValue = "";
     private final String description = "";
@@ -51,10 +49,9 @@ public class StringType implements StringTypeDefinition {
     /**
      * Default Constructor.
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
+    public StringType(final SchemaPath path) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
         lengthStatements = Collections.unmodifiableList(constraints);
@@ -70,11 +67,10 @@ public class StringType implements StringTypeDefinition {
      * @param lengthStatements
      * @param patterns
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<LengthConstraint> lengthStatements,
+    public StringType(final SchemaPath path, final List<LengthConstraint> lengthStatements,
             final List<PatternConstraint> patterns) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         if(lengthStatements == null || lengthStatements.size() == 0) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
             constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
@@ -94,12 +90,11 @@ public class StringType implements StringTypeDefinition {
      * @param patterns
      * @param units
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision, final String defaultValue,
+    public StringType(final SchemaPath path, final String defaultValue,
             final List<LengthConstraint> lengthStatements,
             final List<PatternConstraint> patterns, final String units) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.defaultValue = defaultValue;
         if(lengthStatements == null || lengthStatements.size() == 0) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
index 5764cb26c7bd0d616ac0ce9575d3fa9f752189c0..95b438b509f8258c722aa403ee64a8ac08985411 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -21,7 +20,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * counterpart of Yang uint32 built-in type is {@link Integer}.
  *
  */
-public class Uint16 extends AbstractUnsignedInteger {
+public final class Uint16 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint16");
     private Integer defaultValue = null;
@@ -33,23 +32,20 @@ public class Uint16 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint16(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint16(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint16();
     }
 
-    public Uint16(final List<String> actualPath,
-            final URI namespace, final Date revision, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint16(final SchemaPath path, final Integer defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint16();
         this.defaultValue = defaultValue;
     }
 
-    public Uint16(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+    public Uint16(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint16();
         this.defaultValue = defaultValue;
     }
index 47af1e1c986d4ad10680833690be31b645c9e06c..e530e02bbb79357518ccf67fe5fd968da500ac47 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -21,7 +20,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * Java counterpart of Yang uint32 built-in type is {@link Long}.
  *
  */
-public class Uint32 extends AbstractUnsignedInteger {
+public final class Uint32 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint32");
     private Long defaultValue = null;
@@ -33,23 +32,20 @@ public class Uint32 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint32(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint32(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint32();
     }
 
-    public Uint32(final List<String> actualPath,
-            final URI namespace, final Date revision, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint32(final SchemaPath path, final Long defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint32();
         this.defaultValue = defaultValue;
     }
 
-    public Uint32(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+    public Uint32(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint32();
         this.defaultValue = defaultValue;
     }
index f9c2aa3c90a15f41acb9700bae152aa953a237a9..a4aabb56c659bc939431fa8a581c83b091d7a63a 100644 (file)
@@ -8,11 +8,10 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigInteger;
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -23,13 +22,12 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * {@link BigInteger}.
  *
  */
-public class Uint64 extends AbstractUnsignedInteger {
+public final class Uint64 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint64");
 
     private BigInteger defaultValue = null;
-    private static final String description =
-            "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
+    private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
     private Uint64() {
@@ -37,23 +35,21 @@ public class Uint64 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint64(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint64(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint64();
     }
 
-    public Uint64(final List<String> actualPath,
-            final URI namespace, final Date revision, final BigInteger defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint64(final SchemaPath path, final BigInteger defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint64();
         this.defaultValue = defaultValue;
     }
 
-    public Uint64(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final BigInteger defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Uint64(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final BigInteger defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint64();
         this.defaultValue = defaultValue;
     }
index ece0eb5c3f37dba7d132160e47ecd9130e253c62..c369e037763c7ec821cac453dfe9a413d70d1901 100644 (file)
@@ -7,11 +7,10 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -23,7 +22,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  * @see AbstractUnsignedInteger
  */
-public class Uint8 extends AbstractUnsignedInteger {
+public final class Uint8 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint8");
     private Short defaultValue = null;
@@ -36,23 +35,20 @@ public class Uint8 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint8(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint8(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint8();
     }
 
-    public Uint8(final List<String> actualPath,
-            final URI namespace, final Date revision, final Short defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint8(final SchemaPath path, final Short defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint8();
         this.defaultValue = defaultValue;
     }
 
-    public Uint8(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+    public Uint8(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Short defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint8();
         this.defaultValue = defaultValue;
     }
index 1063f3b22b6bfe4720af2539803f6296875c9c72..f68cb191dc0cab382f88a5df791b46edae6153e6 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;
@@ -19,7 +17,7 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
 
-public class UnionType implements UnionTypeDefinition {
+public final class UnionType implements UnionTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("union");
     private final SchemaPath path;
@@ -29,20 +27,21 @@ public class UnionType implements UnionTypeDefinition {
     private final List<TypeDefinition<?>> types;
 
     private UnionType(List<TypeDefinition<?>> types) {
-        if(types == null) {
-            throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+        if (types == null) {
+            throw new NullPointerException(
+                    "When the type is 'union', the 'type' statement MUST be present.");
         }
         path = BaseTypes.schemaPath(name);
         this.types = types;
         this.baseType = this;
     }
 
-    public UnionType(final List<String> actualPath, final URI namespace,
-            final Date revision, List<TypeDefinition<?>> types) {
-        if(types == null) {
-            throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+    public UnionType(final SchemaPath path, List<TypeDefinition<?>> types) {
+        if (types == null) {
+            throw new NullPointerException(
+                    "When the type is 'union', the 'type' statement MUST be present.");
         }
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.types = types;
         this.baseType = new UnionType(types);
     }
@@ -135,8 +134,8 @@ public class UnionType implements UnionTypeDefinition {
         builder.append("UnionType [name=");
         builder.append(name);
         builder.append(", types=[");
-        for(TypeDefinition<?> td : types) {
-            builder.append(", "+ td.getQName().getLocalName());
+        for (TypeDefinition<?> td : types) {
+            builder.append(", " + td.getQName().getLocalName());
         }
         builder.append("]");
         builder.append("]");
index e4d176c12b1e62d45e4eb94e6ffe87e332c005a8..82849891f9b42b64c9043237598986b007d78403 100644 (file)
@@ -8,14 +8,17 @@
 package org.opendaylight.controller.yang.model.util;\r
 \r
 import java.net.URI;\r
+import java.util.ArrayList;\r
 import java.util.Date;\r
 import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Set;\r
 \r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
 \r
-public class YangTypesConverter {\r
+public final class YangTypesConverter {\r
     private static final Set<String> baseYangTypes = new HashSet<String>();\r
 \r
     static {\r
@@ -49,39 +52,48 @@ public class YangTypesConverter {
             String typeName) {\r
         TypeDefinition<?> type = null;\r
 \r
+        SchemaPath path = createSchemaPath(actualPath, namespace, revision);\r
         if (typeName.startsWith("int")) {\r
             if (typeName.equals("int8")) {\r
-                type = new Int8(actualPath, namespace, revision);\r
+                type = new Int8(path);\r
             } else if (typeName.equals("int16")) {\r
-                type = new Int16(actualPath, namespace, revision);\r
+                type = new Int16(path);\r
             } else if (typeName.equals("int32")) {\r
-                type = new Int32(actualPath, namespace, revision);\r
+                type = new Int32(path);\r
             } else if (typeName.equals("int64")) {\r
-                type = new Int64(actualPath, namespace, revision);\r
+                type = new Int64(path);\r
             }\r
         } else if (typeName.startsWith("uint")) {\r
             if (typeName.equals("uint8")) {\r
-                type = new Uint8(actualPath, namespace, revision);\r
+                type = new Uint8(path);\r
             } else if (typeName.equals("uint16")) {\r
-                type = new Uint16(actualPath, namespace, revision);\r
+                type = new Uint16(path);\r
             } else if (typeName.equals("uint32")) {\r
-                type = new Uint32(actualPath, namespace, revision);\r
+                type = new Uint32(path);\r
             } else if (typeName.equals("uint64")) {\r
-                type = new Uint64(actualPath, namespace, revision);\r
+                type = new Uint64(path);\r
             }\r
         } else if ("string".equals(typeName)) {\r
-            type = new StringType(actualPath, namespace, revision);\r
+            type = new StringType(path);\r
         } else if("binary".equals(typeName)) {\r
-            type = new BinaryType(actualPath, namespace, revision);\r
+            type = new BinaryType(path);\r
         } else if("boolean".equals(typeName)) {\r
-            type = new BooleanType(actualPath, namespace, revision);\r
+            type = new BooleanType(path);\r
         } else if("empty".equals(typeName)) {\r
-            type = new EmptyType(actualPath, namespace, revision);\r
+            type = new EmptyType(path);\r
         } else if("instance-identifier".equals(typeName)) {\r
-            type = new InstanceIdentifier(actualPath, namespace, revision, null, true);\r
+            type = new InstanceIdentifier(path, null, true);\r
         }\r
 \r
         return type;\r
     }\r
 \r
+    private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision) {\r
+        List<QName> path = new ArrayList<QName>();\r
+        for(String element : actualPath) {\r
+            path.add(new QName(namespace, revision, element));\r
+        }\r
+        return new SchemaPath(path, true);\r
+    }\r
+\r
 }\r