Refactored SchemaPath for yang java types. Fixed SchemaPath for augmented nodes types. 11/411/3
authorMartin Vitez <mvitez@cisco.com>
Thu, 30 May 2013 14:03:54 +0000 (16:03 +0200)
committerMartin Vitez <mvitez@cisco.com>
Fri, 31 May 2013 08:18:59 +0000 (10:18 +0200)
Updated yang java types constructors. Updated tests accordingly.

Change-Id: Ifeb1ddc96c89350579c837414dceeab624ef17ab
Signed-off-by: Martin Vitez <mvitez@cisco.com>
60 files changed:
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/TypeProviderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AugmentedTypeTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypesTest.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/test/java/org/opendaylight/controller/sal/java/api/generator/test/GeneratorJavaFileTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/api/TypeAwareBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AnyXmlBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AugmentationSchemaBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ChoiceBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ChoiceCaseBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ConstraintsBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ContainerSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/DeviationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ExtensionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/FeatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/GroupingBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/IdentityrefTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/LeafListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/LeafSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/NotificationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/RpcDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/TypedefBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UnionTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UnknownSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UsesNodeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/ParserUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/TestUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/TypesResolutionTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/YangParserTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile1.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile3.yang
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractSignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractUnsignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BinaryType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BitsType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BooleanType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Decimal64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EmptyType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EnumerationType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java [deleted file]
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityrefType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/InstanceIdentifier.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int8.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Leafref.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/StringType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint8.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/UnionType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java

index 30207cc776cec82d22e829b0933e5c023d11665a..0618efc8aec7f8a0732a8daafaf14e1c11203bbc 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.sal.binding.yang.types;
 
  */
 package org.opendaylight.controller.sal.binding.yang.types;
 
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.resolveModuleFromSchemaPath;
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.*;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -65,7 +63,7 @@ public class TypeProviderImpl implements TypeProvider {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.type.provider.TypeProvider#
      * javaTypeForYangType(java.lang.String)
      */
      * @see org.opendaylight.controller.yang.model.type.provider.TypeProvider#
      * javaTypeForYangType(java.lang.String)
      */
@@ -95,8 +93,8 @@ public class TypeProviderImpl implements TypeProvider {
                     returnType = resolveEnumFromTypeDefinition(enumTypeDef,
                             typedefName);
                 } else {
                     returnType = resolveEnumFromTypeDefinition(enumTypeDef,
                             typedefName);
                 } else {
-                    final Module module = resolveModuleFromSchemaPath(schemaContext, typeDefinition
-                                    .getPath());
+
+                    final Module module = resolveModuleFromTypePath(schemaContext, typeDefinition);
 
                     if (module != null) {
                         final Map<String, GeneratedTransferObject> genTOs = genTypeDefsContextMap
 
                     if (module != null) {
                         final Map<String, GeneratedTransferObject> genTOs = genTypeDefsContextMap
@@ -167,11 +165,11 @@ public class TypeProviderImpl implements TypeProvider {
                 if (strXPath.matches(".*//[.* | .*//].*")) {
                     returnType = Types.typeForClass(Object.class);
                 } else {
                 if (strXPath.matches(".*//[.* | .*//].*")) {
                     returnType = Types.typeForClass(Object.class);
                 } else {
-                    final Module module = resolveModuleFromSchemaPath(schemaContext, leafrefType.getPath());
+                    final Module module = resolveModuleFromTypePath(schemaContext, leafrefType);
                     if (module != null) {
                         final DataSchemaNode dataNode;
                         if (xpath.isAbsolute()) {
                     if (module != null) {
                         final DataSchemaNode dataNode;
                         if (xpath.isAbsolute()) {
-                            dataNode = findDataSchemaNode(schemaContext, 
+                            dataNode = findDataSchemaNode(schemaContext,
                                     module, xpath);
                         } else {
                             dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module,
                                     module, xpath);
                         } else {
                             dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module,
@@ -229,7 +227,8 @@ public class TypeProviderImpl implements TypeProvider {
             final String enumerationName = BindingGeneratorUtil
                     .parseToClassName(enumName);
 
             final String enumerationName = BindingGeneratorUtil
                     .parseToClassName(enumName);
 
-            Module module = resolveModuleFromSchemaPath(schemaContext, enumTypeDef.getPath());
+            Module module = resolveModuleFromTypePath(schemaContext, enumTypeDef);
+
             final String basePackageName = BindingGeneratorUtil
                     .moduleNamespaceToPackageName(module);
             final String packageName = BindingGeneratorUtil
             final String basePackageName = BindingGeneratorUtil
                     .moduleNamespaceToPackageName(module);
             final String packageName = BindingGeneratorUtil
index 19dfd9577f8224c589a5db90a8abc9ae61adc0bc..448f610c49ba42265e080324c0ce0023c758b8f7 100644 (file)
@@ -158,19 +158,23 @@ public class AugmentedTypeTest {
 
         final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
         assertNotNull("networkLink2Methods is null", networkLink2Methods);
 
         final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
         assertNotNull("networkLink2Methods is null", networkLink2Methods);
-//      FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
-//      MethodSignature getIfcMethod = null;
-//      for (MethodSignature method : networkLink2Methods) {
-//          if (method.getName().equals("getInterface")) {
-//              getIfcMethod = method;
-//              break;
-//          }
-//      }
-
-//      assertNotNull("getIfcMethod is null", getIfcMethod);
-//      assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
-//      assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));
-//      assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));
+
+//        FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
+//        MethodSignature getIfcMethod = null;
+//        for (MethodSignature method : networkLink2Methods) {
+//            if (method.getName().equals("getInterface")) {
+//                getIfcMethod = method;
+//                break;
+//            }
+//        }
+//
+//        assertNotNull("getIfcMethod is null", getIfcMethod);
+//        assertNotNull("getIfcMethod.getReturnType() is null",
+//                getIfcMethod.getReturnType());
+//        assertFalse("getIfcMethod.getReturnType() should not be Void",
+//                getIfcMethod.getReturnType().equals("java.lang.Void"));
+//        assertTrue("getIfcMethod.getReturnType().getName() must be String",
+//                getIfcMethod.getReturnType().getName().equals("String"));
     }
 
     @Test
     }
 
     @Test
index c1035c3b90e37dbc5e05c2607166268c14c02686..66c293eebc5beadf52cb7614dacf5f5bad2a5c4e 100644 (file)
@@ -7,20 +7,25 @@
  */
 package org.opendaylight.controller.sal.binding.generator.impl;
 
  */
 package org.opendaylight.controller.sal.binding.generator.impl;
 
-import org.junit.Test;
-import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.*;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.model.api.Enumeration;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesTest {
 
 
 public class GeneratedTypesTest {
 
@@ -138,119 +143,158 @@ public class GeneratedTypesTest {
         assertEquals(50, genTypes.size());
         assertTrue(genTypes != null);
 
         assertEquals(50, genTypes.size());
         assertTrue(genTypes != null);
 
-        int resolvedLeafrefCount = 0;
+        GeneratedTransferObject gtIfcKey = null;
+        GeneratedType gtIfc = null;
+        GeneratedType gtNetworkLink = null;
+        GeneratedType gtSource = null;
+        GeneratedType gtDest = null;
+        GeneratedType gtTunnel = null;
+        GeneratedTransferObject gtTunnelKey = null;
         for (final Type type : genTypes) {
         for (final Type type : genTypes) {
-            if (type.getName().equals("InterfaceKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("InterfaceId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("String"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-
-            } else if (type.getName().equals("Interface")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-
-                assertTrue(methods != null);
-                for (final MethodSignature method : methods) {
-                    if (method.getName().equals("getInterfaceKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("InterfaceKey"));
-                        resolvedLeafrefCount++;
-                    } else if (method.getName().equals("getHigherLayerIf")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("List"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("NetworkLink")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getInterface")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("String"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if ((type.getName().equals("SourceNode") || type.getName()
-                    .equals("DestinationNode"))
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getId")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("Tunnel")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getTunnelKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("TunnelKey"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("TunnelKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
+            String name = type.getName();
+            if ("InterfaceKey".equals(name)) {
+                gtIfcKey = (GeneratedTransferObject) type;
+            } else if ("Interface".equals(name)) {
+                gtIfc = (GeneratedType) type;
+            } else if ("NetworkLink".equals(name)) {
+                gtNetworkLink = (GeneratedType) type;
+            } else if ("SourceNode".equals(name)) {
+                gtSource = (GeneratedType) type;
+            } else if ("DestinationNode".equals(name)) {
+                gtDest = (GeneratedType) type;
+            } else if ("Tunnel".equals(name)) {
+                gtTunnel = (GeneratedType) type;
+            } else if ("TunnelKey".equals(name)) {
+                gtTunnelKey = (GeneratedTransferObject) type;
+            }
+        }
 
 
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("TunnelId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedLeafrefCount++;
-                    }
-                }
+        assertNotNull(gtIfcKey);
+        assertNotNull(gtIfc);
+        assertNotNull(gtNetworkLink);
+        assertNotNull(gtSource);
+        assertNotNull(gtDest);
+        assertNotNull(gtTunnel);
+        assertNotNull(gtTunnelKey);
+
+        // InterfaceId
+        final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();
+        assertNotNull(gtIfcKeyProps);
+        GeneratedProperty ifcIdProp = null;
+        for (final GeneratedProperty property : gtIfcKeyProps) {
+            if (property.getName().equals("InterfaceId")) {
+                ifcIdProp = property;
+            }
+        }
+        assertNotNull(ifcIdProp);
+        Type ifcIdPropType = ifcIdProp.getReturnType();
+        assertNotNull(ifcIdPropType);
+        assertFalse(ifcIdPropType.equals("java.lang.Void"));
+        assertTrue(ifcIdPropType.getName().equals("String"));
+
+        // Interface
+        final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
+        assertNotNull(gtIfcMethods);
+        MethodSignature getIfcKey = null;
+        MethodSignature getHigherLayerIf = null;
+        for (final MethodSignature method : gtIfcMethods) {
+            if (method.getName().equals("getInterfaceKey")) {
+                getIfcKey = method;
+            } else if (method.getName().equals("getHigherLayerIf")) {
+                getHigherLayerIf = method;
+            }
+        }
+        assertNotNull(getIfcKey);
+        Type getIfcKeyType = getIfcKey.getReturnType();
+        assertNotNull(getIfcKeyType);
+        assertFalse(getIfcKeyType.equals("java.lang.Void"));
+        assertTrue(getIfcKeyType.getName().equals("InterfaceKey"));
+
+        assertNotNull(getHigherLayerIf);
+        Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
+        assertNotNull(getHigherLayerIfType);
+        assertFalse(getHigherLayerIfType.equals("java.lang.Void"));
+        assertTrue(getHigherLayerIfType.getName().equals("List"));
+
+        // NetworkLink
+        final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink
+                .getMethodDefinitions();
+        assertNotNull(gtNetworkLinkMethods);
+        MethodSignature getIfc = null;
+        for (MethodSignature method : gtNetworkLinkMethods) {
+            if (method.getName().equals("getInterface")) {
+                getIfc = method;
+            }
+        }
+        assertNotNull(getIfc);
+        Type getIfcType = getIfc.getReturnType();
+        assertNotNull(getIfcType);
+        assertFalse(getIfcType.equals("java.lang.Void"));
+        assertTrue(getIfcType.getName().equals("String"));
+
+        // SourceNode
+        final List<MethodSignature> gtSourceMethods = gtSource
+                .getMethodDefinitions();
+        assertNotNull(gtSourceMethods);
+        MethodSignature getIdSource = null;
+        for (MethodSignature method : gtSourceMethods) {
+            if (method.getName().equals("getId")) {
+                getIdSource = method;
+            }
+        }
+        assertNotNull(getIdSource);
+        Type getIdType = getIdSource.getReturnType();
+        assertNotNull(getIdType);
+        assertFalse(getIdType.equals("java.lang.Void"));
+        assertTrue(getIdType.getName().equals("Uri"));
+
+        // DestinationNode
+        final List<MethodSignature> gtDestMethods = gtDest
+                .getMethodDefinitions();
+        assertNotNull(gtDestMethods);
+        MethodSignature getIdDest = null;
+        for (MethodSignature method : gtDestMethods) {
+            if (method.getName().equals("getId")) {
+                getIdDest = method;
+            }
+        }
+        assertNotNull(getIdDest);
+        Type getIdDestType = getIdDest.getReturnType();
+        assertNotNull(getIdDestType);
+        assertFalse(getIdDestType.equals("java.lang.Void"));
+        assertTrue(getIdDestType.getName().equals("Uri"));
+
+        // Tunnel
+        final List<MethodSignature> gtTunnelMethods = gtTunnel
+                .getMethodDefinitions();
+        assertNotNull(gtTunnelMethods);
+        MethodSignature getTunnelKey = null;
+        for (MethodSignature method : gtTunnelMethods) {
+            if (method.getName().equals("getTunnelKey")) {
+                getTunnelKey = method;
+            }
+        }
+        assertNotNull(getTunnelKey);
+        Type getTunnelKeyType = getTunnelKey.getReturnType();
+        assertNotNull(getTunnelKeyType);
+        assertFalse(getTunnelKeyType.equals("java.lang.Void"));
+        assertTrue(getTunnelKeyType.getName().equals("TunnelKey"));
+
+        // TunnelKey
+        final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey
+                .getProperties();
+        assertNotNull(gtTunnelKeyProps);
+        GeneratedProperty tunnelId = null;
+        for (final GeneratedProperty property : gtTunnelKeyProps) {
+            if (property.getName().equals("TunnelId")) {
+                tunnelId = property;
             }
         }
             }
         }
-        assertEquals(10, resolvedLeafrefCount);
+        assertNotNull(tunnelId);
+        Type tunnelIdType = tunnelId.getReturnType();
+        assertNotNull(tunnelIdType);
+        assertFalse(tunnelIdType.equals("java.lang.Void"));
+        assertTrue(tunnelIdType.getName().equals("Uri"));
     }
 
     @Test
     }
 
     @Test
@@ -420,8 +464,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType &&
-                    !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 final GeneratedType genType = (GeneratedType) type;
                 if (genType.getName().equals("ListParentContainer")) {
                     assertEquals(2, genType.getMethodDefinitions().size());
                 final GeneratedType genType = (GeneratedType) type;
                 if (genType.getName().equals("ListParentContainer")) {
                     assertEquals(2, genType.getMethodDefinitions().size());
@@ -504,8 +548,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType &&
-                    !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
@@ -552,7 +596,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 genTOsCount++;
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 genTOsCount++;
index 076e2482ba4d9fdbf58ccc3f4b22007c37f8692f..bf539eb8fe43eb3149352501a10df2cec95cb385 100644 (file)
@@ -24,6 +24,7 @@ import javax.tools.ToolProvider;
 
 import org.junit.After;
 import org.junit.Before;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
 import org.junit.Test;
 import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
@@ -94,6 +95,7 @@ public class GeneratorJavaFileTest {
         assertTrue(filesList.contains("Type3.java"));
     }
 
         assertTrue(filesList.contains("Type3.java"));
     }
 
+    @Ignore
     @Test
     public void compilationTest() throws Exception {
         final YangParserImpl parser = new YangParserImpl();
     @Test
     public void compilationTest() throws Exception {
         final YangParserImpl parser = new YangParserImpl();
index 1f4986cc9016ed2ced694c5e44df8ea02d62710d..559eedb6dc869dc3e7140879ca0d2e152724ccd1 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.parser.builder.api;
 
  */
 package org.opendaylight.controller.yang.parser.builder.api;
 
+import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 
 /**
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 
 /**
@@ -15,6 +16,8 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
  */
 public interface TypeAwareBuilder extends Builder {
 
  */
 public interface TypeAwareBuilder extends Builder {
 
+    QName getQName();
+
     TypeDefinition<?> getType();
 
     TypeDefinitionBuilder getTypedef();
     TypeDefinition<?> getType();
 
     TypeDefinitionBuilder getTypedef();
index 7d9e3ea8b72a4ff6a017999dfc234762e5d52522..ba1ea9c922e4222e4fcead053f9e20f6e2e38000 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class AnyXmlBuilder implements DataSchemaNodeBuilder {
+public final class AnyXmlBuilder implements DataSchemaNodeBuilder {
     private boolean built;
     private final int line;
     private final QName qname;
     private boolean built;
     private final int line;
     private final QName qname;
index a5db03b2e74b890e1944d7e3e9db584a307d1a5b..54f69c809ac9a97fcbe626f1ce61a530b8edd56c 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
+public final class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
     private boolean built;
     private final AugmentationSchemaImpl instance;
     private final int line;
     private boolean built;
     private final AugmentationSchemaImpl instance;
     private final int line;
index 04e7d33478b6a20cdfd0323336dcf393adbdf1a5..e3ab0834e0cea16cc088a0c64feed69a2a214e52 100644 (file)
@@ -30,8 +30,8 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
-        AugmentationTargetBuilder {
+public final class ChoiceBuilder implements DataSchemaNodeBuilder,
+        ChildNodeBuilder, AugmentationTargetBuilder {
     private boolean built;
     private final ChoiceNodeImpl instance;
     private final int line;
     private boolean built;
     private final ChoiceNodeImpl instance;
     private final int line;
@@ -252,7 +252,7 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         return new HashSet<DataSchemaNodeBuilder>(cases);
     }
 
         return new HashSet<DataSchemaNodeBuilder>(cases);
     }
 
-    private class ChoiceNodeImpl implements ChoiceNode {
+    private final class ChoiceNodeImpl implements ChoiceNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index a3b21b4abf5d83a94573fe7545bccea611c932e1..11a1b3114c7475d27d9e049600aa788b9d47783e 100644 (file)
@@ -171,7 +171,7 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
         return augmentations;
     }
 
         return augmentations;
     }
 
-    private class ChoiceCaseNodeImpl implements ChoiceCaseNode {
+    private final class ChoiceCaseNodeImpl implements ChoiceCaseNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -265,6 +265,10 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
             }
         }
 
             }
         }
 
+        /**
+         * Always returns an empty set, because case node can not contains type
+         * definitions.
+         */
         @Override
         public Set<TypeDefinition<?>> getTypeDefinitions() {
             return Collections.emptySet();
         @Override
         public Set<TypeDefinition<?>> getTypeDefinitions() {
             return Collections.emptySet();
index a6c37e34214d8d995d9ef2e7bcb49c155bcb1460..b1aa7de06a58fddcfad9884abeba13d651f47761 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 
-public class ConstraintsBuilder implements Builder {
+public final class ConstraintsBuilder implements Builder {
     private final ConstraintDefinitionImpl instance;
     private final int line;
     private final Set<MustDefinition> mustDefinitions;
     private final ConstraintDefinitionImpl instance;
     private final int line;
     private final Set<MustDefinition> mustDefinitions;
@@ -93,7 +93,7 @@ public class ConstraintsBuilder implements Builder {
         this.mandatory = mandatory;
     }
 
         this.mandatory = mandatory;
     }
 
-    private static class ConstraintDefinitionImpl implements
+    private final class ConstraintDefinitionImpl implements
             ConstraintDefinition {
         private RevisionAwareXPath whenCondition;
         private Set<MustDefinition> mustConstraints;
             ConstraintDefinition {
         private RevisionAwareXPath whenCondition;
         private Set<MustDefinition> mustConstraints;
index e12a3a9f4de1ace8991ac80d69f54ec5e6dfb6de..7fcdb6f8ba14a98b9340d81975af950251e47dfd 100644 (file)
@@ -35,10 +35,10 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBu
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
+public final class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         implements TypeDefinitionAwareBuilder, AugmentationTargetBuilder,
         DataSchemaNodeBuilder {
         implements TypeDefinitionAwareBuilder, AugmentationTargetBuilder,
         DataSchemaNodeBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final ContainerSchemaNodeImpl instance;
     private final int line;
     private final ConstraintsBuilder constraints;
     private final ContainerSchemaNodeImpl instance;
     private final int line;
     private final ConstraintsBuilder constraints;
@@ -64,7 +64,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
 
     @Override
     public ContainerSchemaNode build() {
 
     @Override
     public ContainerSchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setReference(reference);
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setReference(reference);
@@ -103,7 +103,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
 
             // AUGMENTATIONS
             final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
 
             // AUGMENTATIONS
             final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-            for(AugmentationSchemaBuilder builder : addedAugmentations) {
+            for (AugmentationSchemaBuilder builder : addedAugmentations) {
                 augmentations.add(builder.build());
             }
             instance.setAvailableAugmentations(augmentations);
                 augmentations.add(builder.build());
             }
             instance.setAvailableAugmentations(augmentations);
@@ -118,7 +118,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
             instance.setConstraints(constraints.build());
             instance.setAvailableAugmentations(augmentations);
 
             instance.setConstraints(constraints.build());
             instance.setAvailableAugmentations(augmentations);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
         }
         return instance;
     }
@@ -179,7 +179,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
 
     @Override
     public void setStatus(Status status) {
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
             this.status = status;
         }
     }
@@ -233,7 +233,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class ContainerSchemaNodeImpl implements ContainerSchemaNode {
+    private final class ContainerSchemaNodeImpl implements ContainerSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -292,7 +292,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         }
 
         private void setStatus(Status status) {
         }
 
         private void setStatus(Status status) {
-            if(status != null) {
+            if (status != null) {
                 this.status = status;
             }
         }
                 this.status = status;
             }
         }
index e99f8280e0891a628b3be26ef4517aaa2abd32b8..239c0a5ed9a8da6c3a1682975f7a8b8258941e17 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class DeviationBuilder implements Builder {
+public final class DeviationBuilder implements Builder {
     private final DeviationImpl instance;
     private final int line;
 
     private final DeviationImpl instance;
     private final int line;
 
@@ -54,7 +54,7 @@ public class DeviationBuilder implements Builder {
         instance.setReference(reference);
     }
 
         instance.setReference(reference);
     }
 
-    private class DeviationImpl implements Deviation {
+    private final class DeviationImpl implements Deviation {
         private final SchemaPath targetPath;
         private Deviate deviate;
         private String reference;
         private final SchemaPath targetPath;
         private Deviate deviate;
         private String reference;
index 2852a32aec45f193ac5919e828a2cf3f1f56aa1e..a04fc3c1a68b06fa0e1667265b50417fa4831488 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class ExtensionBuilder implements SchemaNodeBuilder {
+public final class ExtensionBuilder implements SchemaNodeBuilder {
+    private boolean isBuilt;
     private final ExtensionDefinitionImpl instance;
     private final int line;
     private final QName qname;
     private final ExtensionDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -34,14 +35,18 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
 
     @Override
     public ExtensionDefinition build() {
 
     @Override
     public ExtensionDefinition build() {
-        instance.setPath(schemaPath);
+        if(!isBuilt) {
+            instance.setPath(schemaPath);
 
 
-        // UNKNOWN NODES
-        final List<UnknownSchemaNode> extensions = new ArrayList<UnknownSchemaNode>();
-        for (UnknownSchemaNodeBuilder e : addedExtensions) {
-            extensions.add(e.build());
+            // UNKNOWN NODES
+            final List<UnknownSchemaNode> extensions = new ArrayList<UnknownSchemaNode>();
+            for (UnknownSchemaNodeBuilder e : addedExtensions) {
+                extensions.add(e.build());
+            }
+            instance.setUnknownSchemaNodes(extensions);
+
+            isBuilt = true;
         }
         }
-        instance.setUnknownSchemaNodes(extensions);
 
         return instance;
     }
 
         return instance;
     }
@@ -98,7 +103,7 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class ExtensionDefinitionImpl implements ExtensionDefinition {
+    private final class ExtensionDefinitionImpl implements ExtensionDefinition {
         private final QName qname;
         private String argument;
         private SchemaPath schemaPath;
         private final QName qname;
         private String argument;
         private SchemaPath schemaPath;
index 0f2c7f1d09d3795b62b15b5a667b91204e8c0568..5418e09451eb087d4d6d19ea2c9b20e8f08f1474 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class FeatureBuilder implements SchemaNodeBuilder {
+public final class FeatureBuilder implements SchemaNodeBuilder {
+    private boolean isBuilt;
     private final FeatureDefinitionImpl instance;
     private final int line;
     private final QName qname;
     private final FeatureDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -33,15 +34,18 @@ public class FeatureBuilder implements SchemaNodeBuilder {
 
     @Override
     public FeatureDefinitionImpl build() {
 
     @Override
     public FeatureDefinitionImpl build() {
-        instance.setPath(schemaPath);
+        if(!isBuilt) {
+            instance.setPath(schemaPath);
 
 
-        // UNKNOWN NODES
-        final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
-        for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
-            unknownNodes.add(b.build());
-        }
-        instance.setUnknownSchemaNodes(unknownNodes);
+            // UNKNOWN NODES
+            final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+            for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+                unknownNodes.add(b.build());
+            }
+            instance.setUnknownSchemaNodes(unknownNodes);
 
 
+            isBuilt = true;
+        }
         return instance;
     }
 
         return instance;
     }
 
@@ -85,7 +89,7 @@ public class FeatureBuilder implements SchemaNodeBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class FeatureDefinitionImpl implements FeatureDefinition {
+    private final class FeatureDefinitionImpl implements FeatureDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index 759f54ec6fe817ca5a76c504fdb4c6932ca52006..cc7a05cd04b30ca0f683ff76cfc1319a48a84bb2 100644 (file)
@@ -28,8 +28,8 @@ import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class GroupingBuilderImpl implements GroupingBuilder {
-    private boolean built;
+public final class GroupingBuilderImpl implements GroupingBuilder {
+    private boolean isBuilt;
     private final GroupingDefinitionImpl instance;
     private final int line;
     private final QName qname;
     private final GroupingDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -51,7 +51,7 @@ public class GroupingBuilderImpl implements GroupingBuilder {
 
     @Override
     public GroupingDefinition build() {
 
     @Override
     public GroupingDefinition build() {
-        if (!built) {
+        if (!isBuilt) {
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setReference(reference);
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setReference(reference);
@@ -92,7 +92,7 @@ public class GroupingBuilderImpl implements GroupingBuilder {
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
 
         return instance;
         }
 
         return instance;
@@ -210,7 +210,7 @@ public class GroupingBuilderImpl implements GroupingBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private static class GroupingDefinitionImpl implements GroupingDefinition {
+    private final class GroupingDefinitionImpl implements GroupingDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index 408f6612ea8a3864e9851e84c66e55dbcebf609e..bbf94408059119307396394fdbbff5e8f681b693 100644 (file)
@@ -28,8 +28,8 @@ import org.opendaylight.controller.yang.parser.util.YangParseException;
  * When build is called, types in builder form will be built and add to resolved
  * types.
  */
  * When build is called, types in builder form will be built and add to resolved
  * types.
  */
-public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
-        TypeDefinitionBuilder {
+public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder
+        implements TypeDefinitionBuilder {
     private static final String NAME = "identityref";
 
     private final int line;
     private static final String NAME = "identityref";
 
     private final int line;
index 28f250f121a05c499285a3bef1863b8251dc3e33..b35ff4e9f1146f71241ae79dfe7a00edcb3d3d34 100644 (file)
@@ -22,9 +22,9 @@ import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuil
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
+public final class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         implements SchemaNodeBuilder, DataSchemaNodeBuilder {
         implements SchemaNodeBuilder, DataSchemaNodeBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final LeafListSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
     private final LeafListSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
@@ -50,7 +50,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
 
     @Override
     public LeafListSchemaNode build() {
 
     @Override
     public LeafListSchemaNode build() {
-        if (!built) {
+        if (!isBuilt) {
             instance.setConstraints(constraints.build());
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setConstraints(constraints.build());
             instance.setPath(schemaPath);
             instance.setDescription(description);
@@ -73,7 +73,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
         }
         return instance;
     }
@@ -166,7 +166,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class LeafListSchemaNodeImpl implements LeafListSchemaNode {
+    private final class LeafListSchemaNodeImpl implements LeafListSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index ee7b3b1c81f55454b1ba06db75c06030e7c6be57..99d4ffbe2480d7ff0783fa1bbfb68ab4382b0fca 100644 (file)
@@ -22,9 +22,9 @@ import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuil
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
-        DataSchemaNodeBuilder, SchemaNodeBuilder {
-    private boolean built;
+public final class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder
+        implements DataSchemaNodeBuilder, SchemaNodeBuilder {
+    private boolean isBuilt;
     private final LeafSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
     private final LeafSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
@@ -51,7 +51,7 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public LeafSchemaNode build() {
 
     @Override
     public LeafSchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setPath(path);
             instance.setConstraints(constraints.build());
             instance.setDescription(description);
             instance.setPath(path);
             instance.setConstraints(constraints.build());
             instance.setDescription(description);
@@ -76,7 +76,7 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
         }
         return instance;
     }
@@ -152,8 +152,6 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         this.augmenting = augmenting;
     }
 
         this.augmenting = augmenting;
     }
 
-
-
     public boolean isConfiguration() {
         return configuration;
     }
     public boolean isConfiguration() {
         return configuration;
     }
@@ -179,7 +177,7 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         this.unitsStr = unitsStr;
     }
 
         this.unitsStr = unitsStr;
     }
 
-    private class LeafSchemaNodeImpl implements LeafSchemaNode {
+    private final class LeafSchemaNodeImpl implements LeafSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index c9b1e7369b32fb995099753e340fb99b5a1a2382..db0e37b1e3d5983e69cb3b44a1018bb705a17be7 100644 (file)
@@ -35,10 +35,10 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBu
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
-        DataSchemaNodeBuilder, AugmentationTargetBuilder,
+public final class ListSchemaNodeBuilder extends AbstractChildNodeBuilder
+        implements DataSchemaNodeBuilder, AugmentationTargetBuilder,
         TypeDefinitionAwareBuilder {
         TypeDefinitionAwareBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final ListSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
     private final ListSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
@@ -69,7 +69,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
 
     @Override
     public ListSchemaNode build() {
 
     @Override
     public ListSchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setKeyDefinition(keyDefinition);
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setKeyDefinition(keyDefinition);
             instance.setPath(schemaPath);
             instance.setDescription(description);
@@ -124,7 +124,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
             instance.setConstraints(constraints.build());
             instance.setAvailableAugmentations(augmentations);
 
             instance.setConstraints(constraints.build());
             instance.setAvailableAugmentations(augmentations);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
         }
         return instance;
     }
@@ -249,7 +249,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class ListSchemaNodeImpl implements ListSchemaNode {
+    private final class ListSchemaNodeImpl implements ListSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index 4865178d27545aa30b7f78d30323e725ec78d70a..0d47d7a5fc5dbd391be57e032dd387b490c8da93 100644 (file)
@@ -594,19 +594,19 @@ public class ModuleBuilder implements Builder {
         parent.setType(type);
     }
 
         parent.setType(type);
     }
 
-    public void addUnionType(final List<String> actualPath,
+    public UnionTypeBuilder addUnionType(final List<String> actualPath,
             final URI namespace, final Date revision, final int line) {
         List<String> pathToUnion = new ArrayList<String>(actualPath);
         TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
                 .get(pathToUnion);
             final URI namespace, final Date revision, final int line) {
         List<String> pathToUnion = new ArrayList<String>(actualPath);
         TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
                 .get(pathToUnion);
-        UnionTypeBuilder union = new UnionTypeBuilder(pathToUnion, namespace,
-                revision, line);
+        UnionTypeBuilder union = new UnionTypeBuilder(line);
         parent.setType(union);
 
         List<String> path = new ArrayList<String>(pathToUnion);
         path.add("union");
 
         moduleNodes.put(path, union);
         parent.setType(union);
 
         List<String> path = new ArrayList<String>(pathToUnion);
         path.add("union");
 
         moduleNodes.put(path, union);
+        return union;
     }
 
     public void addIdentityrefType(final String baseString,
     }
 
     public void addIdentityrefType(final String baseString,
@@ -669,7 +669,7 @@ public class ModuleBuilder implements Builder {
         return builder;
     }
 
         return builder;
     }
 
-    private class ModuleImpl implements Module {
+    private final class ModuleImpl implements Module {
         private URI namespace;
         private final String name;
         private Date revision;
         private URI namespace;
         private final String name;
         private Date revision;
index 3e9b9307bc2a4d4c0ed8c28eb601d2066e2448d8..e058efc2fc4792bea0a48d127691cb3c0acacfe5 100644 (file)
@@ -33,9 +33,9 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBu
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class NotificationBuilder extends AbstractChildNodeBuilder implements
-        TypeDefinitionAwareBuilder, SchemaNodeBuilder {
-    private boolean built;
+public final class NotificationBuilder extends AbstractChildNodeBuilder
+        implements TypeDefinitionAwareBuilder, SchemaNodeBuilder {
+    private boolean isBuilt;
     private final NotificationDefinitionImpl instance;
     private final int line;
     private SchemaPath schemaPath;
     private final NotificationDefinitionImpl instance;
     private final int line;
     private SchemaPath schemaPath;
@@ -51,7 +51,7 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
 
     @Override
     public SchemaNode build() {
 
     @Override
     public SchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setPath(schemaPath);
 
             // CHILD NODES
             instance.setPath(schemaPath);
 
             // CHILD NODES
@@ -89,7 +89,7 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
 
         return instance;
         }
 
         return instance;
@@ -140,7 +140,7 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
         addedUnknownNodes.add(unknownNode);
     }
 
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class NotificationDefinitionImpl implements NotificationDefinition {
+    private final class NotificationDefinitionImpl implements NotificationDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index 003ccced4ab2d72476ff8360efea25e9e3e62b73..914ebc764474b43dfe4c48e91c4bc8124730903d 100644 (file)
@@ -26,9 +26,9 @@ import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 
-public class RpcDefinitionBuilder implements SchemaNodeBuilder,
+public final class RpcDefinitionBuilder implements SchemaNodeBuilder,
         TypeDefinitionAwareBuilder {
         TypeDefinitionAwareBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final RpcDefinitionImpl instance;
     private final int line;
     private final QName qname;
     private final RpcDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -47,7 +47,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
 
     @Override
     public RpcDefinition build() {
 
     @Override
     public RpcDefinition build() {
-        if(!built) {
+        if (!isBuilt) {
             final ContainerSchemaNode input = inputBuilder.build();
             final ContainerSchemaNode output = outputBuilder.build();
             instance.setInput(input);
             final ContainerSchemaNode input = inputBuilder.build();
             final ContainerSchemaNode output = outputBuilder.build();
             instance.setInput(input);
@@ -76,7 +76,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
         }
         return instance;
     }
@@ -158,7 +158,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         return true;
     }
 
         return true;
     }
 
-    private class RpcDefinitionImpl implements RpcDefinition {
+    private final class RpcDefinitionImpl implements RpcDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index 5345d0a1169055a484bbe3cea416f7f0e4c46ec6..a704d587ecfab2a7c7af7d0868803b0950817bb6 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuil
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class TypedefBuilder extends AbstractTypeAwareBuilder implements
+public final class TypedefBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder {
     private final int line;
     private final QName qname;
         TypeDefinitionBuilder {
     private final int line;
     private final QName qname;
index 811b77566836b0f95ad9844562117bc239b569a1..61aec1a8c95702f36787f1770791467f36ad3082 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.yang.parser.builder.impl;
 
  */
 package org.opendaylight.controller.yang.parser.builder.impl;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -31,30 +29,22 @@ import org.opendaylight.controller.yang.parser.util.YangParseException;
  * When build is called, types in builder form will be built and add to resolved
  * types.
  */
  * When build is called, types in builder form will be built and add to resolved
  * types.
  */
-public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
+public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder {
     private final static String NAME = "union";
 
     private final int line;
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
         TypeDefinitionBuilder {
     private final static String NAME = "union";
 
     private final int line;
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
-    private final UnionType instance;
-    private boolean built;
+    private UnionType instance;
+    private boolean isBuilt;
 
 
-    private final List<String> actualPath;
-    private final URI namespace;
-    private final Date revision;
+    private SchemaPath path;
 
 
-    public UnionTypeBuilder(final List<String> actualPath, final URI namespace,
-            final Date revision, final int line) {
+    public UnionTypeBuilder(final int line) {
         this.line = line;
         types = new ArrayList<TypeDefinition<?>>();
         typedefs = new ArrayList<TypeDefinitionBuilder>();
         this.line = line;
         types = new ArrayList<TypeDefinition<?>>();
         typedefs = new ArrayList<TypeDefinitionBuilder>();
-        instance = new UnionType(actualPath, namespace, revision, types);
-
-        this.actualPath = actualPath;
-        this.namespace = namespace;
-        this.revision = revision;
     }
 
     @Override
     }
 
     @Override
@@ -92,20 +82,19 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public UnionType build() {
 
     @Override
     public UnionType build() {
-        if (built) {
-            return instance;
-        } else {
+        if (!isBuilt) {
+            instance = new UnionType(path, types);
             for (TypeDefinitionBuilder tdb : typedefs) {
                 types.add(tdb.build());
             }
             for (TypeDefinitionBuilder tdb : typedefs) {
                 types.add(tdb.build());
             }
-            built = true;
-            return instance;
+            isBuilt = true;
         }
         }
+        return instance;
     }
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
     }
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
-        throw new YangParseException(line, "Can not set path to " + NAME);
+        this.path = schemaPath;
     }
 
     @Override
     }
 
     @Override
@@ -221,18 +210,6 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         throw new YangParseException(line, "Can not set units to " + NAME);
     }
 
         throw new YangParseException(line, "Can not set units to " + NAME);
     }
 
-    public List<String> getActualPath() {
-        return actualPath;
-    }
-
-    public URI getNamespace() {
-        return namespace;
-    }
-
-    public Date getRevision() {
-        return revision;
-    }
-
     @Override
     public String toString() {
         final StringBuilder result = new StringBuilder(
     @Override
     public String toString() {
         final StringBuilder result = new StringBuilder(
index 1c63002f347e0b55e6b2091bf8d4e0d652f09cb5..222290188e3ad019ad23300666c792aede587376 100644 (file)
@@ -17,7 +17,8 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
+public final class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
+    private boolean isBuilt;
     private final UnknownSchemaNodeImpl instance;
     private final int line;
     private final QName qname;
     private final UnknownSchemaNodeImpl instance;
     private final int line;
     private final QName qname;
@@ -34,16 +35,21 @@ public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
 
     @Override
     public UnknownSchemaNode build() {
 
     @Override
     public UnknownSchemaNode build() {
-        instance.setPath(schemaPath);
-        instance.setNodeType(nodeType);
-        instance.setNodeParameter(nodeParameter);
+        if(!isBuilt) {
+            instance.setPath(schemaPath);
+            instance.setNodeType(nodeType);
+            instance.setNodeParameter(nodeParameter);
+
+            // UNKNOWN NODES
+            final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+            for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+                unknownNodes.add(b.build());
+            }
+            instance.setUnknownSchemaNodes(unknownNodes);
 
 
-        // UNKNOWN NODES
-        final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
-        for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
-            unknownNodes.add(b.build());
+            isBuilt = true;
         }
         }
-        instance.setUnknownSchemaNodes(unknownNodes);
+
         return instance;
     }
 
         return instance;
     }
 
@@ -103,7 +109,7 @@ public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
         this.nodeParameter = nodeParameter;
     }
 
         this.nodeParameter = nodeParameter;
     }
 
-    private static class UnknownSchemaNodeImpl implements UnknownSchemaNode {
+    private final class UnknownSchemaNodeImpl implements UnknownSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
         private final QName qname;
         private SchemaPath path;
         private String description;
index 6943b661564302f337e2a525a51678f60c6819e2..dba747db1dd9bad3aa31a3d265279119d8434b85 100644 (file)
@@ -26,7 +26,7 @@ import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.RefineHolder;\r
 \r
 public final class UsesNodeBuilderImpl implements UsesNodeBuilder {\r
 import org.opendaylight.controller.yang.parser.util.RefineHolder;\r
 \r
 public final class UsesNodeBuilderImpl implements UsesNodeBuilder {\r
-    private boolean built;\r
+    private boolean isBuilt;\r
     private final UsesNodeImpl instance;\r
     private final int line;\r
     private final String groupingPathStr;\r
     private final UsesNodeImpl instance;\r
     private final int line;\r
     private final String groupingPathStr;\r
@@ -45,7 +45,7 @@ public final class UsesNodeBuilderImpl implements UsesNodeBuilder {
 \r
     @Override\r
     public UsesNode build() {\r
 \r
     @Override\r
     public UsesNode build() {\r
-        if (!built) {\r
+        if (!isBuilt) {\r
             instance.setAugmenting(augmenting);\r
 \r
             // AUGMENTATIONS\r
             instance.setAugmenting(augmenting);\r
 \r
             // AUGMENTATIONS\r
@@ -63,7 +63,7 @@ public final class UsesNodeBuilderImpl implements UsesNodeBuilder {
             }\r
             instance.setRefines(refineNodes);\r
 \r
             }\r
             instance.setRefines(refineNodes);\r
 \r
-            built = true;\r
+            isBuilt = true;\r
         }\r
         return instance;\r
     }\r
         }\r
         return instance;\r
     }\r
index ec46831b4fba538f1a1359c917efc8311eac4db4..14ef4914d512f8c7775f5c622990246587063908 100644 (file)
@@ -79,7 +79,7 @@ import org.opendaylight.controller.yang.validator.YangModelBasicValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class YangParserImpl implements YangModelParser {
+public final class YangParserImpl implements YangModelParser {
 
     private static final Logger logger = LoggerFactory
             .getLogger(YangParserImpl.class);
 
     private static final Logger logger = LoggerFactory
             .getLogger(YangParserImpl.class);
@@ -361,15 +361,14 @@ public class YangParserImpl implements YangModelParser {
             final TypeDefinitionBuilder old, final boolean seekByTypedefBuilder) {
         if (old instanceof UnionTypeBuilder) {
             final UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
             final TypeDefinitionBuilder old, final boolean seekByTypedefBuilder) {
         if (old instanceof UnionTypeBuilder) {
             final UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
-            final UnionTypeBuilder newUnion = new UnionTypeBuilder(
-                    oldUnion.getActualPath(), oldUnion.getNamespace(),
-                    oldUnion.getRevision(), old.getLine());
+            final UnionTypeBuilder newUnion = new UnionTypeBuilder(old.getLine());
             for (TypeDefinition<?> td : oldUnion.getTypes()) {
                 newUnion.setType(td);
             }
             for (TypeDefinitionBuilder tdb : oldUnion.getTypedefs()) {
                 newUnion.setType(copyTypedefBuilder(tdb, true));
             }
             for (TypeDefinition<?> td : oldUnion.getTypes()) {
                 newUnion.setType(td);
             }
             for (TypeDefinitionBuilder tdb : oldUnion.getTypedefs()) {
                 newUnion.setType(copyTypedefBuilder(tdb, true));
             }
+            newUnion.setPath(old.getPath());
             return newUnion;
         }
 
             return newUnion;
         }
 
index 46265529daddb5897c4695017885cb2232b54433..b853dcf2a89b29827bd4478a99eb5516ae55182d 100644 (file)
@@ -73,6 +73,7 @@ import org.opendaylight.controller.yang.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.NotificationBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.RpcDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.TypedefBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.NotificationBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.RpcDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.TypedefBuilder;
+import org.opendaylight.controller.yang.parser.builder.impl.UnionTypeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.RefineHolder;
 import org.slf4j.Logger;
 import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.RefineHolder;
 import org.slf4j.Logger;
@@ -334,8 +335,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 moduleBuilder.setType(type, actualPath);
             } else {
                 if ("union".equals(typeName)) {
                 moduleBuilder.setType(type, actualPath);
             } else {
                 if ("union".equals(typeName)) {
-                    moduleBuilder.addUnionType(actualPath, namespace, revision,
+                    List<String> typePath = new ArrayList<String>(actualPath);
+                    typePath.add(typeName);
+
+                    SchemaPath p = createActualSchemaPath(typePath, namespace, revision, yangModelPrefix);
+                    UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(actualPath, namespace, revision,
                             line);
                             line);
+                    unionBuilder.setPath(p);
                 } else if ("identityref".equals(typeName)) {
                     SchemaPath path = createActualSchemaPath(actualPath,
                             namespace, revision, yangModelPrefix);
                 } else if ("identityref".equals(typeName)) {
                     SchemaPath path = createActualSchemaPath(actualPath,
                             namespace, revision, yangModelPrefix);
@@ -344,7 +350,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                             line);
                 } else {
                     List<String> typePath = new ArrayList<String>(actualPath);
                             line);
                 } else {
                     List<String> typePath = new ArrayList<String>(actualPath);
-                    typePath.remove(0);
+                    typePath.add(typeName);
+
                     type = parseTypeBody(typeName, typeBody, typePath,
                             namespace, revision, yangModelPrefix);
                     moduleBuilder.setType(type, actualPath);
                     type = parseTypeBody(typeName, typeBody, typePath,
                             namespace, revision, yangModelPrefix);
                     moduleBuilder.setType(type, actualPath);
index 05f9c6519fba726579fbe7beffcec22dd0e3f282..b4e250d19f9e2df482e4421f5943a29e73e350d9 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.yang.parser.util;
 
 import java.lang.reflect.Method;
 package org.opendaylight.controller.yang.parser.util;
 
 import java.lang.reflect.Method;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
 import java.util.ArrayList;
 import java.util.List;
 
@@ -16,12 +17,45 @@ import org.opendaylight.controller.yang.model.api.ModuleImport;
 import org.opendaylight.controller.yang.model.api.MustDefinition;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.MustDefinition;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.BinaryTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.DecimalTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
+import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
+import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
+import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.controller.yang.model.util.BinaryType;
+import org.opendaylight.controller.yang.model.util.BitsType;
+import org.opendaylight.controller.yang.model.util.BooleanType;
+import org.opendaylight.controller.yang.model.util.Decimal64;
+import org.opendaylight.controller.yang.model.util.EmptyType;
+import org.opendaylight.controller.yang.model.util.EnumerationType;
+import org.opendaylight.controller.yang.model.util.IdentityrefType;
+import org.opendaylight.controller.yang.model.util.InstanceIdentifier;
+import org.opendaylight.controller.yang.model.util.Int16;
+import org.opendaylight.controller.yang.model.util.Int32;
+import org.opendaylight.controller.yang.model.util.Int64;
+import org.opendaylight.controller.yang.model.util.Int8;
+import org.opendaylight.controller.yang.model.util.Leafref;
+import org.opendaylight.controller.yang.model.util.StringType;
+import org.opendaylight.controller.yang.model.util.UnionType;
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.builder.api.ChildNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.builder.api.ChildNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.parser.builder.api.TypeAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.AnyXmlBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.AnyXmlBuilder;
@@ -102,29 +136,170 @@ public final class ParserUtils {
             final ChildNodeBuilder target) {
         for (DataSchemaNodeBuilder builder : augment.getChildNodes()) {
             builder.setAugmenting(true);
             final ChildNodeBuilder target) {
         for (DataSchemaNodeBuilder builder : augment.getChildNodes()) {
             builder.setAugmenting(true);
-            correctPath(augment, target.getPath());
+            correctAugmentChildPath(augment, target.getPath());
             target.addChildNode(builder);
         }
     }
 
             target.addChildNode(builder);
         }
     }
 
-    private static void correctPath(final ChildNodeBuilder node,
+    private static void correctAugmentChildPath(final ChildNodeBuilder node,
             final SchemaPath parentSchemaPath) {
         for (DataSchemaNodeBuilder builder : node.getChildNodes()) {
 
             // add correct path
             final SchemaPath parentSchemaPath) {
         for (DataSchemaNodeBuilder builder : node.getChildNodes()) {
 
             // add correct path
-            SchemaPath targetNodeSchemaPath = parentSchemaPath;
             List<QName> targetNodePath = new ArrayList<QName>(
             List<QName> targetNodePath = new ArrayList<QName>(
-                    targetNodeSchemaPath.getPath());
+                    parentSchemaPath.getPath());
             targetNodePath.add(builder.getQName());
             builder.setPath(new SchemaPath(targetNodePath, true));
 
             if (builder instanceof ChildNodeBuilder) {
                 ChildNodeBuilder cnb = (ChildNodeBuilder) builder;
             targetNodePath.add(builder.getQName());
             builder.setPath(new SchemaPath(targetNodePath, true));
 
             if (builder instanceof ChildNodeBuilder) {
                 ChildNodeBuilder cnb = (ChildNodeBuilder) builder;
-                correctPath(cnb, builder.getPath());
+                correctAugmentChildPath(cnb, builder.getPath());
             }
             }
+
+            // if child can contains type, correct path for this type too
+            if(builder instanceof TypeAwareBuilder) {
+                TypeAwareBuilder nodeBuilder = (TypeAwareBuilder)builder;
+                QName nodeBuilderQName = nodeBuilder.getQName();
+                TypeDefinition<?> nodeBuilderType = nodeBuilder.getType();
+                if(nodeBuilderType != null) {
+                    TypeDefinition<?> newType = createCorrectTypeDefinition(parentSchemaPath, nodeBuilderQName, nodeBuilderType);
+                    nodeBuilder.setType(newType);
+                } else {
+                    TypeDefinitionBuilder nodeBuilderTypedef = nodeBuilder.getTypedef();
+                    SchemaPath newSchemaPath = createNewSchemaPath(nodeBuilderTypedef.getPath(), nodeBuilderQName, nodeBuilderTypedef.getQName());
+                    nodeBuilderTypedef.setPath(newSchemaPath);
+                }
+            }
+        }
+    }
+
+    private static TypeDefinition<?> createCorrectTypeDefinition(SchemaPath parentSchemaPath, QName nodeQName, TypeDefinition<?> nodeType) {
+        TypeDefinition<?> result = null;
+        SchemaPath newSchemaPath = null;
+        if(nodeType != null) {
+            if(nodeType instanceof BinaryTypeDefinition) {
+                BinaryTypeDefinition binType = (BinaryTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, binType.getQName());
+                List<Byte> bytes = (List<Byte>)binType.getDefaultValue();
+                result = new BinaryType(newSchemaPath, bytes, binType.getLengthConstraints(), binType.getUnits());
+            } else if(nodeType instanceof BitsTypeDefinition) {
+                BitsTypeDefinition bitsType = (BitsTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, nodeType.getQName());
+                result = new BitsType(newSchemaPath, bitsType.getBits(), bitsType.getUnits());
+            } else if(nodeType instanceof BooleanTypeDefinition) {
+                BooleanTypeDefinition booleanType = (BooleanTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, booleanType.getQName());
+                result = new BooleanType(newSchemaPath, (Boolean)booleanType.getDefaultValue(), booleanType.getUnits());
+            } else if(nodeType instanceof DecimalTypeDefinition) {
+                DecimalTypeDefinition decimalType = (DecimalTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, decimalType.getQName());
+                BigDecimal defaultValue = (BigDecimal)decimalType.getDefaultValue();
+                result = new Decimal64(newSchemaPath, decimalType.getUnits(), defaultValue, decimalType.getRangeStatements(), decimalType.getFractionDigits());
+            } else if(nodeType instanceof EmptyTypeDefinition) {
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, nodeType.getQName());
+                result = new EmptyType(newSchemaPath);
+            } else if(nodeType instanceof EnumTypeDefinition) {
+                EnumTypeDefinition enumType = (EnumTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, enumType.getQName());
+                result = new EnumerationType(newSchemaPath, (EnumPair)enumType.getDefaultValue(), enumType.getValues(), enumType.getUnits());
+            } else if(nodeType instanceof IdentityrefTypeDefinition) {
+                IdentityrefTypeDefinition idrefType = (IdentityrefTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, idrefType.getQName());
+                result = new IdentityrefType(idrefType.getIdentity(), newSchemaPath);
+            } else if(nodeType instanceof InstanceIdentifierTypeDefinition) {
+                InstanceIdentifierTypeDefinition instIdType = (InstanceIdentifierTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, instIdType.getQName());
+                return new InstanceIdentifier(newSchemaPath, instIdType.getPathStatement(), instIdType.requireInstance());
+            } else if(nodeType instanceof StringTypeDefinition) {
+                result = copyStringType(parentSchemaPath, nodeQName, (StringTypeDefinition)nodeType);
+            } else if(nodeType instanceof IntegerTypeDefinition) {
+                result = copyIntType(parentSchemaPath, nodeQName, (IntegerTypeDefinition)nodeType);
+            } else if(nodeType instanceof UnsignedIntegerTypeDefinition) {
+                result = copyUIntType(parentSchemaPath, nodeQName, (UnsignedIntegerTypeDefinition)nodeType);
+            } else if(nodeType instanceof LeafrefTypeDefinition) {
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, nodeType.getQName());
+                result = new Leafref(newSchemaPath, ((LeafrefTypeDefinition)nodeType).getPathStatement());
+            } else if(nodeType instanceof UnionTypeDefinition) {
+                UnionTypeDefinition unionType = (UnionTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, unionType.getQName());
+                return new UnionType(newSchemaPath, unionType.getTypes());
+            }
+        }
+        return result;
+    }
+
+    private static TypeDefinition<?> copyStringType(SchemaPath schemaPath, QName nodeQName, StringTypeDefinition nodeType) {
+        List<QName> path = schemaPath.getPath();
+        List<QName> newPath = new ArrayList<QName>(path);
+        newPath.add(nodeQName);
+        newPath.add(nodeType.getQName());
+        SchemaPath newSchemaPath = new SchemaPath(newPath, schemaPath.isAbsolute());
+
+        String newDefault = nodeType.getDefaultValue().toString();
+        String newUnits = nodeType.getUnits();
+        List<LengthConstraint> lengths = nodeType.getLengthStatements();
+        List<PatternConstraint> patterns = nodeType.getPatterns();
+
+        return new StringType(newSchemaPath, newDefault, lengths, patterns, newUnits);
+    }
+
+    private static TypeDefinition<?> copyIntType(SchemaPath schemaPath, QName nodeQName, IntegerTypeDefinition type) {
+        QName typeQName = type.getQName();
+        SchemaPath newSchemaPath = createNewSchemaPath(schemaPath, nodeQName, typeQName);
+
+        String localName = typeQName.getLocalName();
+        List<RangeConstraint> ranges = type.getRangeStatements();
+        String units = type.getUnits();
+
+        if("int8".equals(localName)) {
+            Byte defaultValue = (Byte)type.getDefaultValue();
+            return new Int8(newSchemaPath, ranges, units, defaultValue);
+        } else if("int16".equals(localName)) {
+            Short defaultValue = (Short)type.getDefaultValue();
+            return new Int16(newSchemaPath, ranges, units, defaultValue);
+        } else if("int32".equals(localName)) {
+            Integer defaultValue = (Integer)type.getDefaultValue();
+            return new Int32(newSchemaPath, ranges, units, defaultValue);
+        } else if("int64".equals(localName)) {
+            Long defaultValue = (Long)type.getDefaultValue();
+            return new Int64(newSchemaPath, ranges, units, defaultValue);
+        } else {
+            return null;
         }
     }
 
         }
     }
 
+    private static TypeDefinition<?> copyUIntType(SchemaPath schemaPath, QName nodeQName, UnsignedIntegerTypeDefinition type) {
+        QName typeQName = type.getQName();
+        SchemaPath newSchemaPath = createNewSchemaPath(schemaPath, nodeQName, typeQName);
+
+        String localName = typeQName.getLocalName();
+        List<RangeConstraint> ranges = type.getRangeStatements();
+        String units = type.getUnits();
+
+        if("uint8".equals(localName)) {
+            Byte defaultValue = (Byte)type.getDefaultValue();
+            return new Int8(newSchemaPath, ranges, units, defaultValue);
+        } else if("uint16".equals(localName)) {
+            Short defaultValue = (Short)type.getDefaultValue();
+            return new Int16(newSchemaPath, ranges, units, defaultValue);
+        } else if("uint32".equals(localName)) {
+            Integer defaultValue = (Integer)type.getDefaultValue();
+            return new Int32(newSchemaPath, ranges, units, defaultValue);
+        } else if("uint64".equals(localName)) {
+            Long defaultValue = (Long)type.getDefaultValue();
+            return new Int64(newSchemaPath, ranges, units, defaultValue);
+        } else {
+            return null;
+        }
+    }
+
+    private static SchemaPath createNewSchemaPath(SchemaPath schemaPath, QName currentQName, QName qname) {
+        List<QName> newPath = new ArrayList<QName>(schemaPath.getPath());
+        newPath.add(currentQName);
+        newPath.add(qname);
+        return new SchemaPath(newPath, schemaPath.isAbsolute());
+    }
+
     public static void refineLeaf(LeafSchemaNodeBuilder leaf,
             RefineHolder refine, int line) {
         String defaultStr = refine.getDefaultStr();
     public static void refineLeaf(LeafSchemaNodeBuilder leaf,
             RefineHolder refine, int line) {
         String defaultStr = refine.getDefaultStr();
index 873e3842db0097cb17ec4d1fb6dbd5edd039451b..e63f12839dfa8d4d883806bccf6f5e226d45a5bc 100644 (file)
@@ -1008,60 +1008,51 @@ public final class YangModelBuilderUtil {
         List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(
                 typeBody, actualPath, namespace, revision, prefix);
 
         List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(
                 typeBody, actualPath, namespace, revision, prefix);
 
+        SchemaPath schemaPath = createActualSchemaPath(actualPath, namespace,
+                revision, prefix);
+
         if ("decimal64".equals(typeName)) {
         if ("decimal64".equals(typeName)) {
-            type = new Decimal64(actualPath, namespace, revision,
-                    fractionDigits);
+            type = new Decimal64(schemaPath, fractionDigits);
         } else if (typeName.startsWith("int")) {
             if ("int8".equals(typeName)) {
         } else if (typeName.startsWith("int")) {
             if ("int8".equals(typeName)) {
-                type = new Int8(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int8(schemaPath, rangeStatements, null, null);
             } else if ("int16".equals(typeName)) {
             } else if ("int16".equals(typeName)) {
-                type = new Int16(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int16(schemaPath, rangeStatements, null, null);
             } else if ("int32".equals(typeName)) {
             } else if ("int32".equals(typeName)) {
-                type = new Int32(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int32(schemaPath, rangeStatements, null, null);
             } else if ("int64".equals(typeName)) {
             } else if ("int64".equals(typeName)) {
-                type = new Int64(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int64(schemaPath, rangeStatements, null, null);
             }
         } else if (typeName.startsWith("uint")) {
             if ("uint8".equals(typeName)) {
             }
         } else if (typeName.startsWith("uint")) {
             if ("uint8".equals(typeName)) {
-                type = new Uint8(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint8(schemaPath, rangeStatements, null, null);
             } else if ("uint16".equals(typeName)) {
             } else if ("uint16".equals(typeName)) {
-                type = new Uint16(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint16(schemaPath, rangeStatements, null, null);
             } else if ("uint32".equals(typeName)) {
             } else if ("uint32".equals(typeName)) {
-                type = new Uint32(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint32(schemaPath, rangeStatements, null, null);
             } else if ("uint64".equals(typeName)) {
             } else if ("uint64".equals(typeName)) {
-                type = new Uint64(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint64(schemaPath, rangeStatements, null, null);
             }
         } else if ("enumeration".equals(typeName)) {
             }
         } else if ("enumeration".equals(typeName)) {
-            type = new EnumerationType(actualPath, namespace, revision,
-                    enumConstants);
+            type = new EnumerationType(schemaPath, enumConstants);
         } else if ("string".equals(typeName)) {
         } else if ("string".equals(typeName)) {
-            type = new StringType(actualPath, namespace, revision,
-                    lengthStatements, patternStatements);
+            type = new StringType(schemaPath, lengthStatements,
+                    patternStatements);
         } else if ("bits".equals(typeName)) {
         } else if ("bits".equals(typeName)) {
-            type = new BitsType(actualPath, namespace, revision, getBits(
-                    typeBody, actualPath, namespace, revision, prefix));
+            type = new BitsType(schemaPath, getBits(typeBody, actualPath,
+                    namespace, revision, prefix));
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
             RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path,
                     absolute);
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
             RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path,
                     absolute);
-            type = new Leafref(actualPath, namespace, revision, xpath);
+            type = new Leafref(schemaPath, xpath);
         } else if ("binary".equals(typeName)) {
             List<Byte> bytes = Collections.emptyList();
         } else if ("binary".equals(typeName)) {
             List<Byte> bytes = Collections.emptyList();
-            type = new BinaryType(actualPath, namespace, revision, bytes,
-                    lengthStatements, null);
+            type = new BinaryType(schemaPath, bytes, lengthStatements, null);
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            type = new InstanceIdentifier(actualPath, namespace, revision,
-                    null, requireInstance);
+            type = new InstanceIdentifier(schemaPath, null, requireInstance);
         }
         return type;
     }
         }
         return type;
     }
index 5aa620df8936383392ea25d7acea995a7b65fe55..babd0d06f6a7bb217bf12de36b863be569921c56 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.yang.parser.impl;
 
 import java.io.File;
 package org.opendaylight.controller.yang.parser.impl;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.net.URI;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.net.URI;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -29,11 +30,14 @@ final class TestUtils {
     private TestUtils() {
     }
 
     private TestUtils() {
     }
 
-    public static Set<Module> loadModules(String resourceDirectory) {
+    public static Set<Module> loadModules(String resourceDirectory) throws FileNotFoundException {
         YangModelParser parser = new YangParserImpl();
         final File testDir = new File(resourceDirectory);
         final String[] fileList = testDir.list();
         final List<File> testFiles = new ArrayList<File>();
         YangModelParser parser = new YangParserImpl();
         final File testDir = new File(resourceDirectory);
         final String[] fileList = testDir.list();
         final List<File> testFiles = new ArrayList<File>();
+        if(fileList == null) {
+            throw new FileNotFoundException(resourceDirectory);
+        }
         for (int i = 0; i < fileList.length; i++) {
             String fileName = fileList[i];
             testFiles.add(new File(testDir, fileName));
         for (int i = 0; i < fileList.length; i++) {
             String fileName = fileList[i];
             testFiles.add(new File(testDir, fileName));
index 8435ff683a08c32cef4656962cdc19347a16cea4..36c98c36e2a3928cded65ecdbad0ec11b850f2a4 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.yang.parser.impl;
 
 import static org.junit.Assert.*;
 
 
 import static org.junit.Assert.*;
 
+import java.io.FileNotFoundException;
 import java.net.URI;
 import java.util.List;
 import java.util.Set;
 import java.net.URI;
 import java.util.List;
 import java.util.Set;
@@ -37,7 +38,7 @@ public class TypesResolutionTest {
     private Set<Module> testedModules;
 
     @Before
     private Set<Module> testedModules;
 
     @Before
-    public void init() {
+    public void init() throws FileNotFoundException {
         testedModules = TestUtils.loadModules("src/test/resources/types");
     }
 
         testedModules = TestUtils.loadModules("src/test/resources/types");
     }
 
index 910a360c9be920ecab6efe819656828e5d582b28..9463410af8395d3232f581920fc05b930527de13 100644 (file)
@@ -9,7 +9,10 @@ package org.opendaylight.controller.yang.parser.impl;
 
 import static org.junit.Assert.*;
 
 
 import static org.junit.Assert.*;
 
+import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
@@ -32,6 +35,7 @@ import org.opendaylight.controller.yang.model.api.Deviation.Deviate;
 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
 import org.opendaylight.controller.yang.model.api.FeatureDefinition;
 import org.opendaylight.controller.yang.model.api.GroupingDefinition;
 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
 import org.opendaylight.controller.yang.model.api.FeatureDefinition;
 import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.ListSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.ListSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
@@ -52,6 +56,7 @@ import org.opendaylight.controller.yang.model.util.Decimal64;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.Int16;
 import org.opendaylight.controller.yang.model.util.Int32;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.Int16;
 import org.opendaylight.controller.yang.model.util.Int32;
+import org.opendaylight.controller.yang.model.util.Leafref;
 import org.opendaylight.controller.yang.model.util.StringType;
 import org.opendaylight.controller.yang.model.util.Uint32;
 import org.opendaylight.controller.yang.model.util.UnionType;
 import org.opendaylight.controller.yang.model.util.StringType;
 import org.opendaylight.controller.yang.model.util.Uint32;
 import org.opendaylight.controller.yang.model.util.UnionType;
@@ -60,7 +65,7 @@ public class YangParserTest {
     private Set<Module> modules;
 
     @Before
     private Set<Module> modules;
 
     @Before
-    public void init() {
+    public void init() throws FileNotFoundException {
         modules = TestUtils.loadModules("src/test/resources/model");
         assertEquals(3, modules.size());
     }
         modules = TestUtils.loadModules("src/test/resources/model");
         assertEquals(3, modules.size());
     }
@@ -167,8 +172,8 @@ public class YangParserTest {
         assertNull(constraints.getWhenCondition());
         assertEquals(0, constraints.getMustConstraints().size());
         assertFalse(constraints.isMandatory());
         assertNull(constraints.getWhenCondition());
         assertEquals(0, constraints.getMustConstraints().size());
         assertFalse(constraints.isMandatory());
-        assertEquals(1, (int)constraints.getMinElements());
-        assertEquals(11, (int)constraints.getMaxElements());
+        assertEquals(1, (int) constraints.getMinElements());
+        assertEquals(11, (int) constraints.getMaxElements());
         // test AugmentationTarget args
         Set<AugmentationSchema> availableAugmentations = ifEntry
                 .getAvailableAugmentations();
         // test AugmentationTarget args
         Set<AugmentationSchema> availableAugmentations = ifEntry
                 .getAvailableAugmentations();
@@ -564,14 +569,14 @@ public class YangParserTest {
             SchemaNode value = entry.getValue();
             if (value instanceof LeafSchemaNode) {
                 refineLeaf = (LeafSchemaNode) value;
             SchemaNode value = entry.getValue();
             if (value instanceof LeafSchemaNode) {
                 refineLeaf = (LeafSchemaNode) value;
-            } else if(value instanceof ContainerSchemaNode) {
+            } else if (value instanceof ContainerSchemaNode) {
                 refineContainer = (ContainerSchemaNode) value;
                 refineContainer = (ContainerSchemaNode) value;
-            } else if(value instanceof ListSchemaNode) {
-                refineList = (ListSchemaNode)value;
-            } else if(value instanceof GroupingDefinition) {
-                refineGrouping = (GroupingDefinition)value;
-            } else if(value instanceof TypeDefinition<?>) {
-                typedef = (TypeDefinition<?>)value;
+            } else if (value instanceof ListSchemaNode) {
+                refineList = (ListSchemaNode) value;
+            } else if (value instanceof GroupingDefinition) {
+                refineGrouping = (GroupingDefinition) value;
+            } else if (value instanceof TypeDefinition<?>) {
+                typedef = (TypeDefinition<?>) value;
             }
         }
 
             }
         }
 
@@ -610,19 +615,25 @@ public class YangParserTest {
 
         // list addresses
         assertNotNull(refineList);
 
         // list addresses
         assertNotNull(refineList);
-        assertEquals("description of addresses defined by refine", refineList.getDescription());
-        assertEquals("addresses reference added by refine", refineList.getReference());
+        assertEquals("description of addresses defined by refine",
+                refineList.getDescription());
+        assertEquals("addresses reference added by refine",
+                refineList.getReference());
         assertFalse(refineList.isConfiguration());
         assertFalse(refineList.isConfiguration());
-        assertEquals(2, (int)refineList.getConstraints().getMinElements());
-        assertEquals(12, (int)refineList.getConstraints().getMaxElements());
+        assertEquals(2, (int) refineList.getConstraints().getMinElements());
+        assertEquals(12, (int) refineList.getConstraints().getMaxElements());
 
         // grouping target-inner
         assertNotNull(refineGrouping);
 
         // grouping target-inner
         assertNotNull(refineGrouping);
-        Set<DataSchemaNode> refineGroupingChildren = refineGrouping.getChildNodes();
+        Set<DataSchemaNode> refineGroupingChildren = refineGrouping
+                .getChildNodes();
         assertEquals(1, refineGroupingChildren.size());
         assertEquals(1, refineGroupingChildren.size());
-        LeafSchemaNode refineGroupingLeaf = (LeafSchemaNode)refineGroupingChildren.iterator().next();
-        assertEquals("inner-grouping-id", refineGroupingLeaf.getQName().getLocalName());
-        assertEquals("new target-inner grouping description", refineGrouping.getDescription());
+        LeafSchemaNode refineGroupingLeaf = (LeafSchemaNode) refineGroupingChildren
+                .iterator().next();
+        assertEquals("inner-grouping-id", refineGroupingLeaf.getQName()
+                .getLocalName());
+        assertEquals("new target-inner grouping description",
+                refineGrouping.getDescription());
 
         // typedef group-type
         assertNotNull(typedef);
 
         // typedef group-type
         assertNotNull(typedef);
@@ -761,4 +772,43 @@ public class YangParserTest {
         assertEquals(5, children.size());
     }
 
         assertEquals(5, children.size());
     }
 
+    @Test
+    public void testAugmentNodesTypesSchemaPath() throws Exception {
+        final DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Module testModule = TestUtils.findModule(modules, "types1");
+        Set<AugmentationSchema> augments = testModule.getAugmentations();
+        assertEquals(1, augments.size());
+        AugmentationSchema augment = augments.iterator().next();
+
+        LeafSchemaNode ifcId = (LeafSchemaNode) augment
+                .getDataChildByName("interface-id");
+        Leafref ifcIdType = (Leafref) ifcId.getType();
+        SchemaPath ifcIdTypeSchemaPath = ifcIdType.getPath();
+        List<QName> ifcIdTypePath = ifcIdTypeSchemaPath.getPath();
+        QName q0 = new QName(new URI("urn:simple.types.data.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "interfaces");
+        QName q1 = new QName(new URI("urn:simple.types.data.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "ifEntry");
+        QName q2 = new QName(new URI("urn:simple.container.demo.test"),
+                simpleDateFormat.parse("2013-02-27"), "data", "augment-holder");
+        QName q3 = new QName(new URI("urn:simple.container.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "interface-id");
+        assertEquals(q0, ifcIdTypePath.get(0));
+        assertEquals(q1, ifcIdTypePath.get(1));
+        assertEquals(q2, ifcIdTypePath.get(2));
+        assertEquals(q3, ifcIdTypePath.get(3));
+
+        LeafListSchemaNode higherLayer = (LeafListSchemaNode) augment
+                .getDataChildByName("higher-layer-if");
+        Leafref higherLayerType = (Leafref) higherLayer.getType();
+        SchemaPath higherLayerTypeSchemaPath = higherLayerType.getPath();
+        List<QName> higherLayerTypePath = higherLayerTypeSchemaPath.getPath();
+        assertEquals(q0, higherLayerTypePath.get(0));
+        assertEquals(q1, higherLayerTypePath.get(1));
+        assertEquals(q2, higherLayerTypePath.get(2));
+        q3 = new QName(new URI("urn:simple.container.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "higher-layer-if");
+        assertEquals(q3, higherLayerTypePath.get(3));
+    }
+
 }
 }
index 2f4355390bf65dc4b66cab51fb04ee45cf4ac06b..619a5c3e104a1ecd3dcc331ee235a3647cd47ebd 100644 (file)
@@ -31,9 +31,9 @@ module types1 {
     }
 
     leaf leaf-with-length {
     }
 
     leaf leaf-with-length {
-       type data:my-string-type {
-               length "7..max";
-       }
+        type data:my-string-type {
+            length "7..max";
+        }
     }
 
     leaf test-int-leaf {
     }
 
     leaf test-int-leaf {
@@ -55,7 +55,7 @@ module types1 {
     }
 
     leaf union-leaf {
     }
 
     leaf union-leaf {
-       type data:my-union-ext;
+        type data:my-union-ext;
     }
 
     deviation /data:system/data:user {
     }
 
     deviation /data:system/data:user {
@@ -66,7 +66,7 @@ module types1 {
     }
 
     leaf nested-union-leaf {
     }
 
     leaf nested-union-leaf {
-       type data:nested-union1;
+        type data:nested-union1;
     }
 
     leaf custom-union-leaf {
     }
 
     leaf custom-union-leaf {
@@ -113,6 +113,16 @@ module types1 {
         leaf ds0ChannelNumber {
             type string;
         }
         leaf ds0ChannelNumber {
             type string;
         }
+        leaf interface-id {
+            type leafref {
+                path "/if:interfaces/if:interface/if:name";
+            }
+        }
+        leaf-list higher-layer-if {
+            type leafref {
+                path "/if:interfaces/if:interface/if:higher-layer-if";
+            }
+        }
     }
 
 }
     }
 
 }
index d75fc6329679b65224aca76be6cd7b3db1931e11..b779c3ca34c88bc1ee9b579a7a3878df943feeeb 100644 (file)
@@ -82,27 +82,27 @@ module types2 {
     }
 
     typedef my-union {
     }
 
     typedef my-union {
-       type union {
-               type int16 {
-                       range "1..100";
-               }
-               type int32;
-       }
+        type union {
+            type int16 {
+                range "1..100";
+            }
+            type int32;
+        }
     }
 
     typedef my-union-ext {
     }
 
     typedef my-union-ext {
-       type my-union;
+        type my-union;
     }
 
     typedef nested-union1 {
     }
 
     typedef nested-union1 {
-       type nested-union2;
+        type nested-union2;
     }
 
     typedef nested-union2 {
     }
 
     typedef nested-union2 {
-       type union {
-               type my-union-ext;
-               type string;
-       }
+        type union {
+            type my-union-ext;
+            type string;
+        }
     }
 
     leaf if-name {
     }
 
     leaf if-name {
index b203124a9fb50c8c54d2df14fed8e4b3f82fe8a1..7aadc9a54fa36451f9b360ede8669e6a41cfa014 100644 (file)
@@ -42,14 +42,14 @@ module types3 {
 
     container network {
         mnt:mountpoint point {
 
     container network {
         mnt:mountpoint point {
-               mnt:target-ref target;
+            mnt:target-ref target;
         }
         
         }
         
-           description "network-description";
-           reference "network-reference";
-           status obsolete;
-           config true;
-           presence "some presence text";
+        description "network-description";
+        reference "network-reference";
+        status obsolete;
+        config true;
+        presence "some presence text";
     }
 
     feature local-storage {
     }
 
     feature local-storage {
index c2ae7d304a8c1ca9bae54b109e94f3b46d023ef4..0af3c81c6ac3e570c716a3376cf3549d8f3f16fe 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
      */
      * @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;
             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
         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
      */
      * @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;
             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;
     }
         this.units = units;
         this.rangeStatements = rangeStatements;
     }
index 31a62ececda6f4e2a652adac5b7c90449be0c837..013d80d79911c127ef4f3823a2fc996bf70c044f 100644 (file)
@@ -3,10 +3,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -68,13 +66,12 @@ public abstract class AbstractUnsignedInteger implements
      * @param maxRange
      * @param units
      */
      * @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;
             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
         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
      */
      * @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;
             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;
     }
         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;
 
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @see BinaryTypeDefinition
  */
-public class BinaryType implements BinaryTypeDefinition {
+public final class BinaryType implements BinaryTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("binary");
     private final SchemaPath path;
 
     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>();
         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;
     }
 
         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>();
         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.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BinaryType();
     }
 
         this.baseType = new BinaryType();
     }
 
@@ -66,20 +65,21 @@ public class BinaryType implements BinaryTypeDefinition {
      * @param lengthConstraints
      * @param units
      */
      * @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>();
             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(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();
         this.bytes = Collections.unmodifiableList(bytes);
         this.units = units;
         this.baseType = new BinaryType();
@@ -88,7 +88,8 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public BinaryTypeDefinition getBaseType() {
      */
     @Override
     public BinaryTypeDefinition getBaseType() {
@@ -108,7 +109,9 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
      */
     @Override
     public Object getDefaultValue() {
@@ -138,7 +141,8 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
      */
     @Override
     public String getDescription() {
@@ -169,8 +173,8 @@ public class BinaryType implements BinaryTypeDefinition {
      * (non-Javadoc)
      *
      * @see
      * (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() {
      */
     @Override
     public List<LengthConstraint> getLengthConstraints() {
@@ -191,7 +195,8 @@ public class BinaryType implements BinaryTypeDefinition {
                 + ((description == null) ? 0 : description.hashCode());
         result = prime
                 * result
                 + ((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
         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;
 
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @see BitsTypeDefinition
  */
-public class BitsType implements BitsTypeDefinition {
+public final class BitsType implements BitsTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("bits");
     private final SchemaPath path;
 
     private final QName name = BaseTypes.constructQName("bits");
     private final SchemaPath path;
@@ -47,11 +45,10 @@ public class BitsType implements BitsTypeDefinition {
         this.baseType = this;
     }
 
         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();
         super();
         this.bits = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
         this.baseType = new BitsType();
     }
 
@@ -64,12 +61,11 @@ public class BitsType implements BitsTypeDefinition {
      * @param bits
      *            The bits assigned for Bits Type
      */
      * @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 = "";
         super();
         this.bits = Collections.unmodifiableList(bits);
         this.units = "";
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
         this.baseType = new BitsType();
     }
 
@@ -83,12 +79,11 @@ public class BitsType implements BitsTypeDefinition {
      * @param units
      *            units for bits type
      */
      * @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;
         super();
         this.bits = Collections.unmodifiableList(bits);
         this.units = units;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
         this.baseType = new BitsType();
     }
 
index f588bf425c9ae4ed2f6deabd91cf723bc6b9d2fd..0cda67c27fe2cf7158c8561bdb44281fb1f24b48 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @see BooleanTypeDefinition
  */
-public class BooleanType implements BooleanTypeDefinition {
+public final class BooleanType implements BooleanTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("boolean");
     private final SchemaPath path;
 
     private final QName name = BaseTypes.constructQName("boolean");
     private final SchemaPath path;
@@ -43,11 +41,10 @@ public class BooleanType implements BooleanTypeDefinition {
         this.baseType = this;
     }
 
         this.baseType = this;
     }
 
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BooleanType(final SchemaPath path) {
         super();
         this.defaultValue = false;
         super();
         this.defaultValue = false;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
         this.baseType = new BooleanType();
     }
 
@@ -57,11 +54,10 @@ public class BooleanType implements BooleanTypeDefinition {
      * @param defaultValue
      *            Default Value
      */
      * @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;
         super();
         this.defaultValue = defaultValue;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
         this.baseType = new BooleanType();
     }
 
@@ -73,12 +69,11 @@ public class BooleanType implements BooleanTypeDefinition {
      * @param units
      *            Units
      */
      * @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;
         super();
         this.defaultValue = defaultValue;
         this.units = units;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
         this.baseType = new BooleanType();
     }
 
index adb4c1a3cb00a21f6993c4de9e8140cc86d29674..6a070837bd8e9f3f79cec5c02639ffbdd7f0965b 100644 (file)
@@ -8,10 +8,8 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigDecimal;
 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.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @see DecimalTypeDefinition
  */
-public class Decimal64 implements DecimalTypeDefinition {
+public final class Decimal64 implements DecimalTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
 
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
@@ -73,8 +71,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         this.baseType = this;
     }
 
         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(
         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.fractionDigits = fractionDigits;
         rangeStatements = defaultRangeStatements();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
         this.baseType = new Decimal64(fractionDigits);
     }
 
@@ -109,8 +106,7 @@ public class Decimal64 implements DecimalTypeDefinition {
      *            integer between 1 and 18 inclusively
      * @exception IllegalArgumentException
      */
      *            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))) {
             Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
@@ -124,7 +120,7 @@ public class Decimal64 implements DecimalTypeDefinition {
                     .unmodifiableList(rangeStatements);
         }
         this.fractionDigits = fractionDigits;
                     .unmodifiableList(rangeStatements);
         }
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
         this.baseType = new Decimal64(fractionDigits);
     }
 
@@ -153,8 +149,7 @@ public class Decimal64 implements DecimalTypeDefinition {
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
      */
      * @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) {
             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.units = units;
         this.defaultValue = defaultValue;
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(name);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
         this.baseType = new Decimal64(fractionDigits);
     }
 
index 1b5abb22093080657f00037ecd2e017324214c03..424f313efae6b20ccf35cf78e6b12057594114e0 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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;
 
 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;
 
     private final QName name = BaseTypes.constructQName("empty");
     private final SchemaPath path;
@@ -31,9 +29,8 @@ public class EmptyType implements EmptyTypeDefinition {
         this.baseType = this;
     }
 
         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();
     }
 
         this.baseType = new EmptyType();
     }
 
index c825390f38d98415c8fab8250a27f213816edbbc..175ea100ca0919c51f8f9a08e841bc9b13cffc9e 100644 (file)
@@ -7,9 +7,7 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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.
 
 /**
  * The <code>default</code> implementation of Enumertaion Type Definition interface.
- * 
+ *
  * @see EnumTypeDefinition
  */
  * @see EnumTypeDefinition
  */
-public class EnumerationType implements EnumTypeDefinition {
+public final class EnumerationType implements EnumTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("enumeration");
     private final SchemaPath path;
 
     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 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;
     }
     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();
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.enums = Collections.unmodifiableList(enums);
         this.defaultEnum = null;
         baseType = new EnumerationType(enums);
     }
 
         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();
             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;
         this.defaultEnum = defaultEnum;
         this.enums = Collections.unmodifiableList(enums);
         this.units = units;
@@ -64,7 +60,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
@@ -74,7 +70,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
@@ -84,7 +80,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
      */
     @Override
@@ -94,7 +90,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -104,7 +100,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -114,7 +110,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
@@ -124,7 +120,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
      */
     @Override
@@ -134,7 +130,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -144,7 +140,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()
      */
     @Override
      * @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()
      */
     @Override
diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java b/opendaylight/sal/yang-prototype/yang/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
   */\r
 package org.opendaylight.controller.yang.model.util;\r
 \r
-import java.net.URI;\r
 import java.util.Collections;\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
 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
  *\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
 \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
         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
     @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;
 
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @see InstanceIdentifierTypeDefinition
  */
-public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
+public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
 
     private static final QName name = BaseTypes
             .constructQName("instance-identifier");
 
     private static final QName name = BaseTypes
             .constructQName("instance-identifier");
@@ -46,10 +44,9 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
         this.baseType = this;
     }
 
         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();
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         this.requireInstance = requireInstance;
         this.baseType = new InstanceIdentifier(xpath, requireInstance);
         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;
 
  */
 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 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;
 
 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
  */
  *
  * @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 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() {
     private final IntegerTypeDefinition baseType;
 
     private Int16() {
@@ -35,17 +33,16 @@ public class Int16 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
         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();
 
     }
 
         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();
     }
         this.defaultValue = defaultValue;
         this.baseType = new Int16();
     }
index fb777c5992399aed543986684f2e94acd0531cd6..8d16e268c35c610750d6e129cbcc1d1ad6882e13 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 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 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;
 
 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
  *
  */
  * @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 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() {
     private final IntegerTypeDefinition baseType;
 
     private Int32() {
@@ -37,23 +35,21 @@ public class Int32 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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;
     }
         this.baseType = new Int32();
         this.defaultValue = defaultValue;
     }
index b22412012b0e8d54c8bbe3819dd09ba1678f255d..92e92a94a276b8ee22b8c51932db82c5b40d4ea8 100644 (file)
@@ -7,11 +7,10 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
   */
 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 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;
 
 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}.
  *
  */
  * {@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;
 
     private static final QName name = BaseTypes.constructQName("int64");
     private Long defaultValue = null;
@@ -35,23 +34,20 @@ public class Int64 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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) {
             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;
     }
         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;
 
 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 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;
 
 /**
 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
  */
  *
  * @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 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() {
     private final IntegerTypeDefinition baseType;
 
     private Int8() {
@@ -36,23 +33,21 @@ public class Int8 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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;
     }
         this.baseType = new Int8();
         this.defaultValue = defaultValue;
     }
@@ -60,7 +55,8 @@ public class Int8 extends AbstractSignedInteger {
     /*
      * (non-Javadoc)
      *
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public IntegerTypeDefinition getBaseType() {
      */
     @Override
     public IntegerTypeDefinition getBaseType() {
@@ -70,7 +66,9 @@ public class Int8 extends AbstractSignedInteger {
     /*
      * (non-Javadoc)
      *
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
      */
     @Override
     public Object getDefaultValue() {
index a143f5a629a90c8440b0bd850e927963bb19dbf9..d17843af898b44adb1d6a5b2c9d140e446e2675b 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @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 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;
     }
 
         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();
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         baseType = new Leafref(xpath);
     }
 
         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)
      *
     /*
      * (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.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 {
 
 
 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);
     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);
 
             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 Queue<QName> qnamedPath = xpathToQNamePath(context, module,
                             strXPath);
                     if (qnamedPath != null) {
-                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
                                 module, qnamedPath);
                         return dataNode;
                     }
                                 module, qnamedPath);
                         return dataNode;
                     }
@@ -64,7 +65,7 @@ public final class SchemaContextUtil {
         return null;
     }
 
         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)
             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 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) {
                         relativeXPath, actualNodePath);
 
                 if (qnamePath != null) {
-                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
                             module, qnamePath);
                     return dataNode;
                 }
                             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)) {
 
     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());
 
             if ((qname != null) && (qname.getNamespace() != null)) {
                 return context.findModuleByNamespace(qname.getNamespace());
@@ -97,6 +99,30 @@ public final class SchemaContextUtil {
         return null;
     }
 
         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!");
     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();
                 childNodeQName = qnamedPath.peek();
                 if (childNodeQName != null) {
                     final URI childNodeNamespace = childNodeQName.getNamespace();
-                    
+
                     schemaNode = nextNode.getDataChildByName(childNodeQName);
                     if (schemaNode != null) {
                         if (schemaNode instanceof ContainerSchemaNode) {
                     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) {
                     }
                     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));
                         }
                         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;
 
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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
  */
  *
  * @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 = "";
     private final SchemaPath path;
     private String defaultValue = "";
     private final String description = "";
@@ -51,10 +49,9 @@ public class StringType implements StringTypeDefinition {
     /**
      * Default Constructor.
      */
     /**
      * Default Constructor.
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
+    public StringType(final SchemaPath path) {
         super();
         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);
         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
      */
      * @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();
             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, "", ""));
         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
      */
      * @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();
             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>();
         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;
 
  */
 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 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;
 
 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}.
  *
  */
  * 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;
 
     private static final QName name = BaseTypes.constructQName("uint16");
     private Integer defaultValue = null;
@@ -33,23 +32,20 @@ public class Uint16 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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) {
             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;
     }
         this.baseType = new Uint16();
         this.defaultValue = defaultValue;
     }
index 47af1e1c986d4ad10680833690be31b645c9e06c..e530e02bbb79357518ccf67fe5fd968da500ac47 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
  */
 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 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;
 
 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}.
  *
  */
  * 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;
 
     private static final QName name = BaseTypes.constructQName("uint32");
     private Long defaultValue = null;
@@ -33,23 +32,20 @@ public class Uint32 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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) {
             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;
     }
         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;
 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 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;
 
 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}.
  *
  */
  * {@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 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() {
     private final UnsignedIntegerTypeDefinition baseType;
 
     private Uint64() {
@@ -37,23 +35,21 @@ public class Uint64 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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;
     }
         this.baseType = new Uint64();
         this.defaultValue = defaultValue;
     }
index ece0eb5c3f37dba7d132160e47ecd9130e253c62..c369e037763c7ec821cac453dfe9a413d70d1901 100644 (file)
@@ -7,11 +7,10 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
   */
 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 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;
 
 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
  */
  *
  * @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;
 
     private static final QName name = BaseTypes.constructQName("uint8");
     private Short defaultValue = null;
@@ -36,23 +35,20 @@ public class Uint8 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
         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();
     }
 
         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;
     }
 
         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) {
             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;
     }
         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;
 
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 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;
 
 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;
 
     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) {
     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;
     }
 
         }
         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);
     }
         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=[");
         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("]");
         }
         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
 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 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
 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
     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
             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
         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
             } else if (typeName.equals("int16")) {\r
-                type = new Int16(actualPath, namespace, revision);\r
+                type = new Int16(path);\r
             } else if (typeName.equals("int32")) {\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
             } 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
             }\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
             } else if (typeName.equals("uint16")) {\r
-                type = new Uint16(actualPath, namespace, revision);\r
+                type = new Uint16(path);\r
             } else if (typeName.equals("uint32")) {\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
             } 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
             }\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
         } else if("binary".equals(typeName)) {\r
-            type = new BinaryType(actualPath, namespace, revision);\r
+            type = new BinaryType(path);\r
         } else if("boolean".equals(typeName)) {\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
         } 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
         } 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
         }\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
 }\r