Fix for Bug 511 (code-generator) 25/5625/3
authorMartin Vitez <mvitez@cisco.com>
Thu, 13 Mar 2014 10:38:27 +0000 (11:38 +0100)
committerMartin Vitez <mvitez@cisco.com>
Tue, 18 Mar 2014 07:44:44 +0000 (08:44 +0100)
Removed \r characters from all projects under code-generator directory.

Change-Id: Ic6af8cc1b686c62caeaab9e5f2595a597750cafe
Signed-off-by: Martin Vitez <mvitez@cisco.com>
28 files changed:
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/AugmentedTypeTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/ExtendedTypedefTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GenEnumResolvingTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GenTypesSubSetTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesTest.java
code-generator/binding-generator-spi/src/main/java/org/opendaylight/yangtools/sal/binding/generator/spi/TypeProvider.java
code-generator/binding-generator-spi/src/main/java/org/opendaylight/yangtools/sal/binding/generator/spi/package-info.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMember.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/package-info.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/TOGenerator.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/UnionBuilderTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/package-info.java
code-generator/binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/ClassCodeGeneratorTest.java
code-generator/binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/package-info.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/AccessModifier.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/ParameterizedType.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/type/builder/package-info.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/type/provider/package-info.java
code-generator/binding-type-provider/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java
code-generator/binding-type-provider/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/package-info.java
code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/yang/unified/doc/generator/GeneratorImpl.xtend

index f2cf8ebc9ef4d5e73614b015f9cf3b137f5a4ebe..933db8dc8a7c6c4c0e8b44f2942fe8e05bdc885e 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.impl;\r
-\r
-import static org.junit.Assert.assertFalse;\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.File;\r
-import java.net.URISyntaxException;\r
-import java.net.URL;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
-\r
-public class AugmentedTypeTest {\r
-\r
-    private final static List<File> augmentModels = new ArrayList<>();\r
-    private final static URL augmentFolderPath = AugmentedTypeTest.class\r
-            .getResource("/augment-test-models");\r
-\r
-    @BeforeClass\r
-    public static void loadTestResources() throws URISyntaxException {\r
-        final File augFolder = new File(augmentFolderPath.toURI());\r
-\r
-        for (final File fileEntry : augFolder.listFiles()) {\r
-            if (fileEntry.isFile()) {\r
-                augmentModels.add(fileEntry);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void augmentedAbstractTopologyTest() {\r
-        final YangModelParser parser = new YangParserImpl();\r
-        final Set<Module> modules = parser.parseYangModels(augmentModels);\r
-        final SchemaContext context = parser.resolveSchemaContext(modules);\r
-\r
-        assertNotNull("context is null", context);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull("genTypes is null", genTypes);\r
-        assertFalse("genTypes is empty", genTypes.isEmpty());\r
-\r
-        GeneratedTransferObject gtInterfaceKey = null;\r
-        GeneratedType gtInterface = null;\r
-        GeneratedType gtTunnel = null;\r
-        GeneratedTransferObject gtTunnelKey = null;\r
-        GeneratedType gtNetworkLink2 = null;\r
-\r
-        for (final Type type : genTypes) {\r
-            if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {\r
-                gtInterfaceKey = (GeneratedTransferObject) type;\r
-            } else if (type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {\r
-                gtInterface = (GeneratedType) type;\r
-            } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {\r
-                gtTunnel = (GeneratedType) type;\r
-            } else if (type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {\r
-                gtTunnelKey = (GeneratedTransferObject) type;\r
-            } else if (type.getName().equals("NetworkLink2") && type.getPackageName().contains("augment._abstract.topology")) {\r
-                gtNetworkLink2 = (GeneratedType) type;\r
-            }\r
-        }\r
-\r
-        // 'Interface\r
-        assertNotNull("gtInterface is null", gtInterface);\r
-        final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();\r
-        assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);\r
-        MethodSignature getIfcKeyMethod = null;\r
-        for (final MethodSignature method : gtInterfaceMethods) {\r
-            if (method.getName().equals("getKey")) {\r
-                getIfcKeyMethod = method;\r
-                break;\r
-            }\r
-        }\r
-        assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);\r
-        assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());\r
-        assertFalse("getIfcKeyMethod.getReturnType() should not be Void",\r
-                getIfcKeyMethod.getReturnType().equals("java.lang.Void"));\r
-        assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey",\r
-                getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));\r
-\r
-        MethodSignature getHigherLayerIfMethod = null;\r
-        for (final MethodSignature method : gtInterfaceMethods) {\r
-            if (method.getName().equals("getHigherLayerIf")) {\r
-                getHigherLayerIfMethod = method;\r
-                break;\r
-            }\r
-        }\r
-        assertNotNull("getHigherLayerIfMethod is null", getHigherLayerIfMethod);\r
-        assertNotNull("getHigherLayerIfMethod.getReturnType() is null",\r
-                getHigherLayerIfMethod.getReturnType());\r
-        assertFalse("getHigherLayerIfMethod.getReturnType() should not be Void",\r
-                getHigherLayerIfMethod.getReturnType().equals("java.lang.Void"));\r
-        assertTrue("getHigherLayerIfMethod.getReturnType().getName() must be List",\r
-                getHigherLayerIfMethod.getReturnType().getName().equals("List"));\r
-\r
-        // 'InterfaceKey'\r
-        assertNotNull("gtInterfaceKey is null", gtInterfaceKey);\r
-        final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();\r
-        assertNotNull("properties is null", properties);\r
-        GeneratedProperty gtInterfaceId = null;\r
-        for (final GeneratedProperty property : properties) {\r
-            if (property.getName().equals("interfaceId")) {\r
-                gtInterfaceId = property;\r
-                break;\r
-            }\r
-        }\r
-        assertNotNull("gtInterfaceId is null", gtInterfaceId);\r
-        assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());\r
-        assertFalse("gtInterfaceId.getReturnType() should not be Void",\r
-                gtInterfaceId.getReturnType().equals("java.lang.Void"));\r
-        assertTrue("gtInterfaceId.getReturnType().getName() must be String",\r
-                gtInterfaceId.getReturnType().getName().equals("String"));\r
-\r
-        // 'Tunnel'\r
-        assertNotNull("gtTunnel is null", gtTunnel);\r
-        final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();\r
-        assertNotNull("tunnelMethods is null", tunnelMethods);\r
-        MethodSignature getTunnelKeyMethod = null;\r
-        for (MethodSignature method : tunnelMethods) {\r
-            if (method.getName().equals("getKey")) {\r
-                getTunnelKeyMethod = method;\r
-                break;\r
-            }\r
-        }\r
-        assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);\r
-        assertNotNull("getTunnelKeyMethod.getReturnType()",\r
-                getTunnelKeyMethod.getReturnType());\r
-        assertFalse("getTunnelKeyMethod.getReturnType() should not be Void",\r
-                getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));\r
-        assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey",\r
-                getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));\r
-\r
-        // 'TunnelKey'\r
-        assertNotNull("gtTunnelKey is null", gtTunnelKey);\r
-        final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();\r
-        assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);\r
-\r
-        GeneratedProperty gtTunnelId = null;\r
-        for (final GeneratedProperty property : tunnelKeyProperties) {\r
-            if (property.getName().equals("tunnelId")) {\r
-                gtTunnelId = property;\r
-            }\r
-        }\r
-        assertNotNull("gtTunnelId is null", gtTunnelId);\r
-        assertNotNull("gtTunnelId.getReturnType() is null",\r
-                gtTunnelId.getReturnType());\r
-        assertFalse("gtTunnelId.getReturnType() should not be Void",\r
-                gtTunnelId.getReturnType().equals("java.lang.Void"));\r
-        assertTrue("gtTunnelId.getReturnType().getName() must be Integer",\r
-                gtTunnelId.getReturnType().getName().equals("Integer"));\r
-\r
-        // 'NetworkLink2'\r
-        assertNotNull("gtNetworkLink2 is null", gtNetworkLink2);\r
-\r
-        final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();\r
-        assertNotNull("networkLink2Methods is null", networkLink2Methods);\r
-\r
-//        FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP\r
-//      MethodSignature getIfcMethod = null;\r
-//      for (MethodSignature method : networkLink2Methods) {\r
-//          if (method.getName().equals("getInterface")) {\r
-//              getIfcMethod = method;\r
-//              break;\r
-//          }\r
-//      }\r
-//\r
-//      assertNotNull("getIfcMethod is null", getIfcMethod);\r
-//      assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());\r
-//      assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));\r
-//      assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));\r
-    }\r
-\r
-    @Test\r
-    public void augmentedNetworkLinkTest() {\r
-\r
-    }\r
-\r
-    @Test\r
-    public void augmentedTopologyTunnelsTest() {\r
-\r
-    }\r
-}\r
+/*
+ * 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.yangtools.sal.binding.generator.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class AugmentedTypeTest {
+
+    private final static List<File> augmentModels = new ArrayList<>();
+    private final static URL augmentFolderPath = AugmentedTypeTest.class
+            .getResource("/augment-test-models");
+
+    @BeforeClass
+    public static void loadTestResources() throws URISyntaxException {
+        final File augFolder = new File(augmentFolderPath.toURI());
+
+        for (final File fileEntry : augFolder.listFiles()) {
+            if (fileEntry.isFile()) {
+                augmentModels.add(fileEntry);
+            }
+        }
+    }
+
+    @Test
+    public void augmentedAbstractTopologyTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(augmentModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        assertNotNull("context is null", context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull("genTypes is null", genTypes);
+        assertFalse("genTypes is empty", genTypes.isEmpty());
+
+        GeneratedTransferObject gtInterfaceKey = null;
+        GeneratedType gtInterface = null;
+        GeneratedType gtTunnel = null;
+        GeneratedTransferObject gtTunnelKey = null;
+        GeneratedType gtNetworkLink2 = null;
+
+        for (final Type type : genTypes) {
+            if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtInterfaceKey = (GeneratedTransferObject) type;
+            } else if (type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtInterface = (GeneratedType) type;
+            } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtTunnel = (GeneratedType) type;
+            } else if (type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtTunnelKey = (GeneratedTransferObject) type;
+            } else if (type.getName().equals("NetworkLink2") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtNetworkLink2 = (GeneratedType) type;
+            }
+        }
+
+        // 'Interface
+        assertNotNull("gtInterface is null", gtInterface);
+        final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
+        assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
+        MethodSignature getIfcKeyMethod = null;
+        for (final MethodSignature method : gtInterfaceMethods) {
+            if (method.getName().equals("getKey")) {
+                getIfcKeyMethod = method;
+                break;
+            }
+        }
+        assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);
+        assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());
+        assertFalse("getIfcKeyMethod.getReturnType() should not be Void",
+                getIfcKeyMethod.getReturnType().equals("java.lang.Void"));
+        assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey",
+                getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));
+
+        MethodSignature getHigherLayerIfMethod = null;
+        for (final MethodSignature method : gtInterfaceMethods) {
+            if (method.getName().equals("getHigherLayerIf")) {
+                getHigherLayerIfMethod = method;
+                break;
+            }
+        }
+        assertNotNull("getHigherLayerIfMethod is null", getHigherLayerIfMethod);
+        assertNotNull("getHigherLayerIfMethod.getReturnType() is null",
+                getHigherLayerIfMethod.getReturnType());
+        assertFalse("getHigherLayerIfMethod.getReturnType() should not be Void",
+                getHigherLayerIfMethod.getReturnType().equals("java.lang.Void"));
+        assertTrue("getHigherLayerIfMethod.getReturnType().getName() must be List",
+                getHigherLayerIfMethod.getReturnType().getName().equals("List"));
+
+        // 'InterfaceKey'
+        assertNotNull("gtInterfaceKey is null", gtInterfaceKey);
+        final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
+        assertNotNull("properties is null", properties);
+        GeneratedProperty gtInterfaceId = null;
+        for (final GeneratedProperty property : properties) {
+            if (property.getName().equals("interfaceId")) {
+                gtInterfaceId = property;
+                break;
+            }
+        }
+        assertNotNull("gtInterfaceId is null", gtInterfaceId);
+        assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());
+        assertFalse("gtInterfaceId.getReturnType() should not be Void",
+                gtInterfaceId.getReturnType().equals("java.lang.Void"));
+        assertTrue("gtInterfaceId.getReturnType().getName() must be String",
+                gtInterfaceId.getReturnType().getName().equals("String"));
+
+        // 'Tunnel'
+        assertNotNull("gtTunnel is null", gtTunnel);
+        final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
+        assertNotNull("tunnelMethods is null", tunnelMethods);
+        MethodSignature getTunnelKeyMethod = null;
+        for (MethodSignature method : tunnelMethods) {
+            if (method.getName().equals("getKey")) {
+                getTunnelKeyMethod = method;
+                break;
+            }
+        }
+        assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);
+        assertNotNull("getTunnelKeyMethod.getReturnType()",
+                getTunnelKeyMethod.getReturnType());
+        assertFalse("getTunnelKeyMethod.getReturnType() should not be Void",
+                getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));
+        assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey",
+                getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));
+
+        // 'TunnelKey'
+        assertNotNull("gtTunnelKey is null", gtTunnelKey);
+        final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
+        assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);
+
+        GeneratedProperty gtTunnelId = null;
+        for (final GeneratedProperty property : tunnelKeyProperties) {
+            if (property.getName().equals("tunnelId")) {
+                gtTunnelId = property;
+            }
+        }
+        assertNotNull("gtTunnelId is null", gtTunnelId);
+        assertNotNull("gtTunnelId.getReturnType() is null",
+                gtTunnelId.getReturnType());
+        assertFalse("gtTunnelId.getReturnType() should not be Void",
+                gtTunnelId.getReturnType().equals("java.lang.Void"));
+        assertTrue("gtTunnelId.getReturnType().getName() must be Integer",
+                gtTunnelId.getReturnType().getName().equals("Integer"));
+
+        // 'NetworkLink2'
+        assertNotNull("gtNetworkLink2 is null", gtNetworkLink2);
+
+        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"));
+    }
+
+    @Test
+    public void augmentedNetworkLinkTest() {
+
+    }
+
+    @Test
+    public void augmentedTopologyTunnelsTest() {
+
+    }
+}
index 09fe8914d7089860e9638dd95ef6f0b0cbdb1703..481d6149ede4e007e3c8680c058ed7fbb015b145 100644 (file)
@@ -5,8 +5,8 @@
  * 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.yangtools.sal.binding.generator.impl;\r
-\r
+package org.opendaylight.yangtools.sal.binding.generator.impl;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -30,127 +30,127 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-\r
-public class ExtendedTypedefTest {\r
-\r
-    private final static List<File> testModels = new ArrayList<File>();\r
-    private final static URL testFolderPath = AugmentedTypeTest.class.getResource("/typedef-of-typedef");\r
-\r
-    @BeforeClass\r
-    public static void loadTestResources() throws URISyntaxException {\r
-        final File testFolder = new File(testFolderPath.toURI());\r
-\r
-        for (final File fileEntry : testFolder.listFiles()) {\r
-            if (fileEntry.isFile()) {\r
-                testModels.add(fileEntry);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void constantGenerationTest() {\r
-        final YangModelParser parser = new YangParserImpl();\r
-        final Set<Module> modules = parser.parseYangModels(testModels);\r
-        final SchemaContext context = parser.resolveSchemaContext(modules);\r
-\r
-        assertNotNull(context);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        GeneratedTransferObject simpleTypedef4 = null;\r
-        GeneratedTransferObject extendedTypedefUnion = null;\r
-        GeneratedTransferObject unionTypedef = null;\r
-        GeneratedTransferObject typedefFromImport = null;\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedTransferObject) {\r
-                if (type.getName().equals("SimpleTypedef4")) {\r
-                    simpleTypedef4 = (GeneratedTransferObject) type;\r
-                } else if (type.getName().equals("ExtendedTypedefUnion")) {\r
-                    extendedTypedefUnion = (GeneratedTransferObject) type;\r
-                } else if (type.getName().equals("UnionTypedef")) {\r
-                    unionTypedef = (GeneratedTransferObject) type;\r
-                } else if (type.getName().equals("TypedefFromImport")) {\r
-                    typedefFromImport = (GeneratedTransferObject) type;\r
-                }\r
-            }\r
-        }\r
-\r
-        // typedef-from-import\r
-        assertNotNull("TypedefFromImport not found", typedefFromImport);\r
-        List<GeneratedProperty> properties = typedefFromImport.getProperties();\r
-        assertTrue("Properties of TypedefFromImport should be empty", properties.isEmpty());\r
-        assertEquals("TypedefFromImport should be extended", "Ipv4Address", typedefFromImport.getSuperType().getName());\r
-\r
-        // simple-typedef4\r
-        assertNotNull("SimpleTypedef4 not found", simpleTypedef4);\r
-        assertNotNull("ExtendedTypedefUnion not found", extendedTypedefUnion);\r
-        assertNotNull("UnionTypedef", unionTypedef);\r
-\r
-        properties = simpleTypedef4.getProperties();\r
-        assertTrue("SimpleTypedef4 shouldn't have properties.", properties.isEmpty());\r
-\r
-        GeneratedTransferObject extendTO = simpleTypedef4.getSuperType();\r
-        assertNotNull("SimpleTypedef4 should have extend.", extendTO);\r
-        assertEquals("Incorrect extension for SimpleTypedef4.", "SimpleTypedef3", extendTO.getName());\r
-        properties = extendTO.getProperties();\r
-        assertTrue("SimpleTypedef3 shouldn't have properties.", properties.isEmpty());\r
-\r
-        extendTO = extendTO.getSuperType();\r
-        assertNotNull("SimpleTypedef3 should have extend.", extendTO);\r
-        assertEquals("Incorrect extension for SimpleTypedef3.", "SimpleTypedef2", extendTO.getName());\r
-        properties = extendTO.getProperties();\r
-        assertTrue("SimpleTypedef2 shouldn't have properties.", properties.isEmpty());\r
-\r
-        extendTO = extendTO.getSuperType();\r
-        assertNotNull("SimpleTypedef2 should have extend.", extendTO);\r
-        assertEquals("SimpleTypedef2 should be extended with SimpleTypedef1.", "SimpleTypedef1", extendTO.getName());\r
-        properties = extendTO.getProperties();\r
-        assertEquals("Incorrect number of properties in class SimpleTypedef1.", 1, properties.size());\r
-\r
-        assertEquals("Incorrect property's name", "value", properties.get(0).getName());\r
-        assertEquals("Property's incorrect type", BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType());\r
-\r
-        extendTO = extendTO.getSuperType();\r
-        assertNull("SimpleTypedef1 shouldn't have extend.", extendTO);\r
-\r
-        // extended-typedef-union\r
-        assertNotNull("ExtendedTypedefUnion object not found", extendedTypedefUnion);\r
-        properties = extendedTypedefUnion.getProperties();\r
-        assertTrue("ExtendedTypedefUnion shouldn't have any property", properties.isEmpty());\r
-\r
-        extendTO = extendedTypedefUnion.getSuperType();\r
-        assertEquals("Incorrect extension fo ExtendedTypedefUnion.", "UnionTypedef", extendTO.getName());\r
-        assertNull("UnionTypedef shouldn't be extended", extendTO.getSuperType());\r
-        assertEquals("Incorrect number of properties for UnionTypedef.", 5, extendTO.getProperties().size());\r
-\r
-        GeneratedProperty simpleTypedef4Property = null;\r
-        GeneratedProperty simpleTypedef1Property = null;\r
-        GeneratedProperty byteTypeProperty = null;\r
-        GeneratedProperty typedefEnumFruitProperty = null;\r
-        for (GeneratedProperty genProperty : extendTO.getProperties()) {\r
-            if (genProperty.getName().equals("simpleTypedef1")) {\r
-                simpleTypedef1Property = genProperty;\r
-            } else if (genProperty.getName().equals("simpleTypedef4")) {\r
-                simpleTypedef4Property = genProperty;\r
-            } else if (genProperty.getName().equals("byteType")) {\r
-                byteTypeProperty = genProperty;\r
-            } else if (genProperty.getName().equals("typedefEnumFruit")) {\r
-                typedefEnumFruitProperty = genProperty;\r
-            }\r
-        }\r
-\r
-        assertNotNull("simpleTypedef4 property not found in UnionTypedef", simpleTypedef4Property);\r
-        assertNotNull("simpleTypedef1 property not found in UnionTypedef", simpleTypedef1Property);\r
-        assertNotNull("byteType property not found in UnionTypedef", byteTypeProperty);\r
-        assertNotNull("typedefEnumFruit property not found in UnionTypedef", typedefEnumFruitProperty);\r
-\r
-        assertEquals("Incorrect type for property simpleTypedef4.", "SimpleTypedef4", simpleTypedef4Property\r
-                .getReturnType().getName());\r
-        assertEquals("Incorrect type for property simpleTypedef1.", "SimpleTypedef1", simpleTypedef1Property\r
-                .getReturnType().getName());\r
-        assertEquals("Incorrect type for property byteType.", "ByteType", byteTypeProperty.getReturnType().getName());\r
-        assertEquals("Incorrect type for property typedefEnumFruit.", "TypedefEnumFruit", typedefEnumFruitProperty\r
-                .getReturnType().getName());\r
-    }\r
-\r
-}\r
+
+public class ExtendedTypedefTest {
+
+    private final static List<File> testModels = new ArrayList<File>();
+    private final static URL testFolderPath = AugmentedTypeTest.class.getResource("/typedef-of-typedef");
+
+    @BeforeClass
+    public static void loadTestResources() throws URISyntaxException {
+        final File testFolder = new File(testFolderPath.toURI());
+
+        for (final File fileEntry : testFolder.listFiles()) {
+            if (fileEntry.isFile()) {
+                testModels.add(fileEntry);
+            }
+        }
+    }
+
+    @Test
+    public void constantGenerationTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(testModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        assertNotNull(context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        GeneratedTransferObject simpleTypedef4 = null;
+        GeneratedTransferObject extendedTypedefUnion = null;
+        GeneratedTransferObject unionTypedef = null;
+        GeneratedTransferObject typedefFromImport = null;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedTransferObject) {
+                if (type.getName().equals("SimpleTypedef4")) {
+                    simpleTypedef4 = (GeneratedTransferObject) type;
+                } else if (type.getName().equals("ExtendedTypedefUnion")) {
+                    extendedTypedefUnion = (GeneratedTransferObject) type;
+                } else if (type.getName().equals("UnionTypedef")) {
+                    unionTypedef = (GeneratedTransferObject) type;
+                } else if (type.getName().equals("TypedefFromImport")) {
+                    typedefFromImport = (GeneratedTransferObject) type;
+                }
+            }
+        }
+
+        // typedef-from-import
+        assertNotNull("TypedefFromImport not found", typedefFromImport);
+        List<GeneratedProperty> properties = typedefFromImport.getProperties();
+        assertTrue("Properties of TypedefFromImport should be empty", properties.isEmpty());
+        assertEquals("TypedefFromImport should be extended", "Ipv4Address", typedefFromImport.getSuperType().getName());
+
+        // simple-typedef4
+        assertNotNull("SimpleTypedef4 not found", simpleTypedef4);
+        assertNotNull("ExtendedTypedefUnion not found", extendedTypedefUnion);
+        assertNotNull("UnionTypedef", unionTypedef);
+
+        properties = simpleTypedef4.getProperties();
+        assertTrue("SimpleTypedef4 shouldn't have properties.", properties.isEmpty());
+
+        GeneratedTransferObject extendTO = simpleTypedef4.getSuperType();
+        assertNotNull("SimpleTypedef4 should have extend.", extendTO);
+        assertEquals("Incorrect extension for SimpleTypedef4.", "SimpleTypedef3", extendTO.getName());
+        properties = extendTO.getProperties();
+        assertTrue("SimpleTypedef3 shouldn't have properties.", properties.isEmpty());
+
+        extendTO = extendTO.getSuperType();
+        assertNotNull("SimpleTypedef3 should have extend.", extendTO);
+        assertEquals("Incorrect extension for SimpleTypedef3.", "SimpleTypedef2", extendTO.getName());
+        properties = extendTO.getProperties();
+        assertTrue("SimpleTypedef2 shouldn't have properties.", properties.isEmpty());
+
+        extendTO = extendTO.getSuperType();
+        assertNotNull("SimpleTypedef2 should have extend.", extendTO);
+        assertEquals("SimpleTypedef2 should be extended with SimpleTypedef1.", "SimpleTypedef1", extendTO.getName());
+        properties = extendTO.getProperties();
+        assertEquals("Incorrect number of properties in class SimpleTypedef1.", 1, properties.size());
+
+        assertEquals("Incorrect property's name", "value", properties.get(0).getName());
+        assertEquals("Property's incorrect type", BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType());
+
+        extendTO = extendTO.getSuperType();
+        assertNull("SimpleTypedef1 shouldn't have extend.", extendTO);
+
+        // extended-typedef-union
+        assertNotNull("ExtendedTypedefUnion object not found", extendedTypedefUnion);
+        properties = extendedTypedefUnion.getProperties();
+        assertTrue("ExtendedTypedefUnion shouldn't have any property", properties.isEmpty());
+
+        extendTO = extendedTypedefUnion.getSuperType();
+        assertEquals("Incorrect extension fo ExtendedTypedefUnion.", "UnionTypedef", extendTO.getName());
+        assertNull("UnionTypedef shouldn't be extended", extendTO.getSuperType());
+        assertEquals("Incorrect number of properties for UnionTypedef.", 5, extendTO.getProperties().size());
+
+        GeneratedProperty simpleTypedef4Property = null;
+        GeneratedProperty simpleTypedef1Property = null;
+        GeneratedProperty byteTypeProperty = null;
+        GeneratedProperty typedefEnumFruitProperty = null;
+        for (GeneratedProperty genProperty : extendTO.getProperties()) {
+            if (genProperty.getName().equals("simpleTypedef1")) {
+                simpleTypedef1Property = genProperty;
+            } else if (genProperty.getName().equals("simpleTypedef4")) {
+                simpleTypedef4Property = genProperty;
+            } else if (genProperty.getName().equals("byteType")) {
+                byteTypeProperty = genProperty;
+            } else if (genProperty.getName().equals("typedefEnumFruit")) {
+                typedefEnumFruitProperty = genProperty;
+            }
+        }
+
+        assertNotNull("simpleTypedef4 property not found in UnionTypedef", simpleTypedef4Property);
+        assertNotNull("simpleTypedef1 property not found in UnionTypedef", simpleTypedef1Property);
+        assertNotNull("byteType property not found in UnionTypedef", byteTypeProperty);
+        assertNotNull("typedefEnumFruit property not found in UnionTypedef", typedefEnumFruitProperty);
+
+        assertEquals("Incorrect type for property simpleTypedef4.", "SimpleTypedef4", simpleTypedef4Property
+                .getReturnType().getName());
+        assertEquals("Incorrect type for property simpleTypedef1.", "SimpleTypedef1", simpleTypedef1Property
+                .getReturnType().getName());
+        assertEquals("Incorrect type for property byteType.", "ByteType", byteTypeProperty.getReturnType().getName());
+        assertEquals("Incorrect type for property typedefEnumFruit.", "TypedefEnumFruit", typedefEnumFruitProperty
+                .getReturnType().getName());
+    }
+
+}
index ce4983104b84295c72c2bbe20a1072d43998e31f..9e949e1ff34cb6764b112bf369e2033b25909924 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.impl;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.File;\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
-\r
-public class GenEnumResolvingTest {\r
-\r
-    private SchemaContext resolveSchemaContextFromFiles(\r
-            final URI... yangFiles) {\r
-        final YangModelParser parser = new YangParserImpl();\r
-\r
-        final List<File> inputFiles = new ArrayList<File>();\r
-        for (int i = 0; i < yangFiles.length; ++i) {\r
-            inputFiles.add(new File(yangFiles[i]));\r
-        }\r
-\r
-        final Set<Module> modules = parser.parseYangModels(inputFiles);\r
-        return parser.resolveSchemaContext(modules);\r
-    }\r
-\r
-    @Test\r
-    public void testLeafEnumResolving() throws URISyntaxException {\r
-        final URI ietfInterfacesPath = getClass().getResource(\r
-                "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();\r
-        final URI ifTypePath = getClass().getResource(\r
-                "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();\r
-        final URI yangTypesPath = getClass().getResource(\r
-                "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();\r
-\r
-        final SchemaContext context = resolveSchemaContextFromFiles(\r
-                ietfInterfacesPath, ifTypePath, yangTypesPath);\r
-        assertTrue(context != null);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-        assertTrue(genTypes != null);\r
-\r
-        assertEquals("Expected count of all Generated Types", 20, genTypes.size());\r
-\r
-        GeneratedType genInterface = null;\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedType) {\r
-                if (type.getName().equals("Interface")) {\r
-                    genInterface = (GeneratedType) type;\r
-                }\r
-            }\r
-        }\r
-        assertNotNull("Generated Type Interface is not present in list of " +\r
-                "Generated Types", genInterface);\r
-\r
-        Enumeration linkUpDownTrapEnable = null;\r
-        Enumeration operStatus = null;\r
-        final List<Enumeration> enums = genInterface.getEnumerations();\r
-        assertNotNull("Generated Type Interface cannot contain NULL reference" +\r
-                " to Enumeration types!", enums);\r
-        assertEquals("Generated Type Interface MUST contain 2 Enumeration " +\r
-                "Types", 2, enums.size());\r
-        for (final Enumeration e : enums) {\r
-            if (e.getName().equals("LinkUpDownTrapEnable")) {\r
-                linkUpDownTrapEnable = e;\r
-            } else if (e.getName().equals("OperStatus")) {\r
-                operStatus = e;\r
-            }\r
-        }\r
-\r
-        assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",\r
-                linkUpDownTrapEnable);\r
-        assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);\r
-\r
-        assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +\r
-                "not NULL reference!", linkUpDownTrapEnable.getValues());\r
-        assertNotNull("Enum OperStatus MUST contain Values definition not " +\r
-                "NULL reference!", operStatus.getValues());\r
-        assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,\r
-                linkUpDownTrapEnable.getValues().size());\r
-        assertEquals("Enum OperStatus MUST contain 7 values!", 7,\r
-                operStatus.getValues().size());\r
-\r
-        final List<MethodSignature> methods = genInterface\r
-                .getMethodDefinitions();\r
-\r
-        assertNotNull("Generated Interface cannot contain NULL reference for " +\r
-                "Method Signature Definitions!", methods);\r
-\r
-        assertEquals("Expected count of method signature definitions is 15",\r
-                15, methods.size());\r
-        Enumeration ianaIfType = null;\r
-        for (final MethodSignature method : methods) {\r
-            if (method.getName().equals("getType")) {\r
-                if (method.getReturnType() instanceof Enumeration) {\r
-                    ianaIfType = (Enumeration)method.getReturnType();\r
-                }\r
-            }\r
-        }\r
-\r
-        assertNotNull("Method getType MUST return Enumeration Type, " +\r
-                "not NULL reference!", ianaIfType);\r
-        assertEquals("Enumeration getType MUST contain 272 values!", 272,\r
-                ianaIfType.getValues().size());\r
-    }\r
-\r
-    @Test\r
-    public void testTypedefEnumResolving() throws URISyntaxException {\r
-        final URI ianaIfTypePath = getClass().getResource(\r
-                "/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();\r
-\r
-        final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);\r
-        assertTrue(context != null);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-        assertTrue(genTypes != null);\r
-        assertEquals(1, genTypes.size());\r
-\r
-        final Type type = genTypes.get(0);\r
-        assertTrue(type instanceof Enumeration);\r
-\r
-        final Enumeration enumer = (Enumeration) type;\r
-        assertEquals("Enumeration type MUST contain 272 values!", 272,\r
-                enumer.getValues().size());\r
-    }\r
-\r
-    @Test\r
-    public void testLeafrefEnumResolving() throws URISyntaxException {\r
-        final URI ietfInterfacesPath = getClass().getResource(\r
-                "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();\r
-        final URI ifTypePath = getClass().getResource(\r
-                "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();\r
-        final URI yangTypesPath = getClass().getResource(\r
-                "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();\r
-        final URI topologyPath = getClass().getResource(\r
-                "/enum-test-models/abstract-topology@2013-02-08.yang")\r
-                .toURI();\r
-        final URI inetTypesPath = getClass().getResource(\r
-                "/enum-test-models/ietf-inet-types@2010-09-24.yang")\r
-                .toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(\r
-                ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,\r
-                inetTypesPath);\r
-\r
-        assertNotNull(context);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-        assertNotNull(genTypes);\r
-        assertTrue(!genTypes.isEmpty());\r
-\r
-        GeneratedType genInterface = null;\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedType) {\r
-                if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")\r
-                        && type.getName().equals("Interface")) {\r
-                    genInterface = (GeneratedType) type;\r
-                }\r
-            }\r
-        }\r
-        assertNotNull("Generated Type Interface is not present in list of " +\r
-                "Generated Types", genInterface);\r
-\r
-        Type linkUpDownTrapEnable = null;\r
-        Type operStatus = null;\r
-        final List<MethodSignature> methods = genInterface.getMethodDefinitions();\r
-        assertNotNull("Generated Type Interface cannot contain NULL reference" +\r
-                " to Enumeration types!", methods);\r
-        assertEquals("Generated Type Interface MUST contain 5 Methods ",\r
-                5, methods.size());\r
-        for (final MethodSignature method : methods) {\r
-            if (method.getName().equals("getLinkUpDownTrapEnable")) {\r
-                linkUpDownTrapEnable = method.getReturnType();\r
-            } else if (method.getName().equals("getOperStatus")) {\r
-                operStatus = method.getReturnType();\r
-            }\r
-        }\r
-\r
-        assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",\r
-                linkUpDownTrapEnable);\r
-        assertTrue("Expected LinkUpDownTrapEnable of type ReferencedTypeImpl",\r
-                linkUpDownTrapEnable instanceof ReferencedTypeImpl);\r
-        assertEquals(linkUpDownTrapEnable.getPackageName(),\r
-                "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");\r
-\r
-        assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",\r
-                operStatus);\r
-        assertTrue("Expected OperStatus of type ReferencedTypeImpl",\r
-                operStatus instanceof  ReferencedTypeImpl);\r
-        assertEquals(operStatus.getPackageName(),\r
-                "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");\r
-    }\r
-}\r
+/*
+ * 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.yangtools.sal.binding.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class GenEnumResolvingTest {
+
+    private SchemaContext resolveSchemaContextFromFiles(
+            final URI... yangFiles) {
+        final YangModelParser parser = new YangParserImpl();
+
+        final List<File> inputFiles = new ArrayList<File>();
+        for (int i = 0; i < yangFiles.length; ++i) {
+            inputFiles.add(new File(yangFiles[i]));
+        }
+
+        final Set<Module> modules = parser.parseYangModels(inputFiles);
+        return parser.resolveSchemaContext(modules);
+    }
+
+    @Test
+    public void testLeafEnumResolving() throws URISyntaxException {
+        final URI ietfInterfacesPath = getClass().getResource(
+                "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
+        final URI ifTypePath = getClass().getResource(
+                "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+        final URI yangTypesPath = getClass().getResource(
+                "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+
+        final SchemaContext context = resolveSchemaContextFromFiles(
+                ietfInterfacesPath, ifTypePath, yangTypesPath);
+        assertTrue(context != null);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+        assertTrue(genTypes != null);
+
+        assertEquals("Expected count of all Generated Types", 20, genTypes.size());
+
+        GeneratedType genInterface = null;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType) {
+                if (type.getName().equals("Interface")) {
+                    genInterface = (GeneratedType) type;
+                }
+            }
+        }
+        assertNotNull("Generated Type Interface is not present in list of " +
+                "Generated Types", genInterface);
+
+        Enumeration linkUpDownTrapEnable = null;
+        Enumeration operStatus = null;
+        final List<Enumeration> enums = genInterface.getEnumerations();
+        assertNotNull("Generated Type Interface cannot contain NULL reference" +
+                " to Enumeration types!", enums);
+        assertEquals("Generated Type Interface MUST contain 2 Enumeration " +
+                "Types", 2, enums.size());
+        for (final Enumeration e : enums) {
+            if (e.getName().equals("LinkUpDownTrapEnable")) {
+                linkUpDownTrapEnable = e;
+            } else if (e.getName().equals("OperStatus")) {
+                operStatus = e;
+            }
+        }
+
+        assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",
+                linkUpDownTrapEnable);
+        assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
+
+        assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +
+                "not NULL reference!", linkUpDownTrapEnable.getValues());
+        assertNotNull("Enum OperStatus MUST contain Values definition not " +
+                "NULL reference!", operStatus.getValues());
+        assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,
+                linkUpDownTrapEnable.getValues().size());
+        assertEquals("Enum OperStatus MUST contain 7 values!", 7,
+                operStatus.getValues().size());
+
+        final List<MethodSignature> methods = genInterface
+                .getMethodDefinitions();
+
+        assertNotNull("Generated Interface cannot contain NULL reference for " +
+                "Method Signature Definitions!", methods);
+
+        assertEquals("Expected count of method signature definitions is 15",
+                15, methods.size());
+        Enumeration ianaIfType = null;
+        for (final MethodSignature method : methods) {
+            if (method.getName().equals("getType")) {
+                if (method.getReturnType() instanceof Enumeration) {
+                    ianaIfType = (Enumeration)method.getReturnType();
+                }
+            }
+        }
+
+        assertNotNull("Method getType MUST return Enumeration Type, " +
+                "not NULL reference!", ianaIfType);
+        assertEquals("Enumeration getType MUST contain 272 values!", 272,
+                ianaIfType.getValues().size());
+    }
+
+    @Test
+    public void testTypedefEnumResolving() throws URISyntaxException {
+        final URI ianaIfTypePath = getClass().getResource(
+                "/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
+
+        final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
+        assertTrue(context != null);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+        assertTrue(genTypes != null);
+        assertEquals(1, genTypes.size());
+
+        final Type type = genTypes.get(0);
+        assertTrue(type instanceof Enumeration);
+
+        final Enumeration enumer = (Enumeration) type;
+        assertEquals("Enumeration type MUST contain 272 values!", 272,
+                enumer.getValues().size());
+    }
+
+    @Test
+    public void testLeafrefEnumResolving() throws URISyntaxException {
+        final URI ietfInterfacesPath = getClass().getResource(
+                "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
+        final URI ifTypePath = getClass().getResource(
+                "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+        final URI yangTypesPath = getClass().getResource(
+                "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+        final URI topologyPath = getClass().getResource(
+                "/enum-test-models/abstract-topology@2013-02-08.yang")
+                .toURI();
+        final URI inetTypesPath = getClass().getResource(
+                "/enum-test-models/ietf-inet-types@2010-09-24.yang")
+                .toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(
+                ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,
+                inetTypesPath);
+
+        assertNotNull(context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+        assertNotNull(genTypes);
+        assertTrue(!genTypes.isEmpty());
+
+        GeneratedType genInterface = null;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType) {
+                if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
+                        && type.getName().equals("Interface")) {
+                    genInterface = (GeneratedType) type;
+                }
+            }
+        }
+        assertNotNull("Generated Type Interface is not present in list of " +
+                "Generated Types", genInterface);
+
+        Type linkUpDownTrapEnable = null;
+        Type operStatus = null;
+        final List<MethodSignature> methods = genInterface.getMethodDefinitions();
+        assertNotNull("Generated Type Interface cannot contain NULL reference" +
+                " to Enumeration types!", methods);
+        assertEquals("Generated Type Interface MUST contain 5 Methods ",
+                5, methods.size());
+        for (final MethodSignature method : methods) {
+            if (method.getName().equals("getLinkUpDownTrapEnable")) {
+                linkUpDownTrapEnable = method.getReturnType();
+            } else if (method.getName().equals("getOperStatus")) {
+                operStatus = method.getReturnType();
+            }
+        }
+
+        assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",
+                linkUpDownTrapEnable);
+        assertTrue("Expected LinkUpDownTrapEnable of type ReferencedTypeImpl",
+                linkUpDownTrapEnable instanceof ReferencedTypeImpl);
+        assertEquals(linkUpDownTrapEnable.getPackageName(),
+                "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
+
+        assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",
+                operStatus);
+        assertTrue("Expected OperStatus of type ReferencedTypeImpl",
+                operStatus instanceof  ReferencedTypeImpl);
+        assertEquals(operStatus.getPackageName(),
+                "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
+    }
+}
index 3b8f5e9448cc39ee176494ec7908df26cf0fc7e7..3f5295b02f7135ddf6ee1804f0af199bbcdd0dbc 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.impl;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertFalse;\r
-import static org.junit.Assert.assertNotNull;\r
-\r
-import java.io.File;\r
-import java.net.URISyntaxException;\r
-import java.net.URL;\r
-import java.util.ArrayList;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
-\r
-public class GenTypesSubSetTest {\r
-\r
-    private final static List<File> yangModels = new ArrayList<>();\r
-    private final static URL yangModelsFolder = AugmentedTypeTest.class\r
-            .getResource("/leafref-test-models");\r
-\r
-    @BeforeClass\r
-    public static void loadTestResources() throws URISyntaxException {\r
-        final File augFolder = new File(yangModelsFolder.toURI());\r
-\r
-        for (final File fileEntry : augFolder.listFiles()) {\r
-            if (fileEntry.isFile()) {\r
-                yangModels.add(fileEntry);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void genTypesFromSubsetOfTwoModulesTest() {\r
-        final YangModelParser parser = new YangParserImpl();\r
-        final Set<Module> modules = parser.parseYangModels(yangModels);\r
-        final SchemaContext context = parser.resolveSchemaContext(modules);\r
-\r
-        final Set<Module> toGenModules = new HashSet<>();\r
-        for (final Module module : modules) {\r
-            if (module.getName().equals("abstract-topology")) {\r
-                toGenModules.add(module);\r
-            } else if (module.getName().equals("ietf-interfaces")) {\r
-                toGenModules.add(module);\r
-            }\r
-        }\r
-\r
-        assertEquals("Set of to Generate Modules must contain 2 modules", 2,\r
-                toGenModules.size());\r
-        assertNotNull("Schema Context is null", context);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);\r
-        assertNotNull("genTypes is null", genTypes);\r
-        assertFalse("genTypes is empty", genTypes.isEmpty());\r
-        assertEquals("Expected Generated Types from provided sub set of " +\r
-                "modules should be 23!", 23,\r
-                genTypes.size());\r
-    }\r
-\r
-    @Test\r
-    public void genTypesFromSubsetOfThreeModulesTest() {\r
-        final YangModelParser parser = new YangParserImpl();\r
-        final Set<Module> modules = parser.parseYangModels(yangModels);\r
-        final SchemaContext context = parser.resolveSchemaContext(modules);\r
-\r
-        final Set<Module> toGenModules = new HashSet<>();\r
-        for (final Module module : modules) {\r
-            if (module.getName().equals("abstract-topology")) {\r
-                toGenModules.add(module);\r
-            } else if (module.getName().equals("ietf-interfaces")) {\r
-                toGenModules.add(module);\r
-            } else if (module.getName().equals("iana-if-type")) {\r
-                toGenModules.add(module);\r
-            }\r
-        }\r
-\r
-        assertEquals("Set of to Generate Modules must contain 3 modules", 3,\r
-                toGenModules.size());\r
-\r
-        assertNotNull("Schema Context is null", context);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);\r
-        assertNotNull("genTypes is null", genTypes);\r
-        assertFalse("genTypes is empty", genTypes.isEmpty());\r
-        assertEquals("Expected Generated Types", 24, genTypes.size());\r
-    }\r
-}\r
+/*
+ * 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.yangtools.sal.binding.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class GenTypesSubSetTest {
+
+    private final static List<File> yangModels = new ArrayList<>();
+    private final static URL yangModelsFolder = AugmentedTypeTest.class
+            .getResource("/leafref-test-models");
+
+    @BeforeClass
+    public static void loadTestResources() throws URISyntaxException {
+        final File augFolder = new File(yangModelsFolder.toURI());
+
+        for (final File fileEntry : augFolder.listFiles()) {
+            if (fileEntry.isFile()) {
+                yangModels.add(fileEntry);
+            }
+        }
+    }
+
+    @Test
+    public void genTypesFromSubsetOfTwoModulesTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(yangModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        final Set<Module> toGenModules = new HashSet<>();
+        for (final Module module : modules) {
+            if (module.getName().equals("abstract-topology")) {
+                toGenModules.add(module);
+            } else if (module.getName().equals("ietf-interfaces")) {
+                toGenModules.add(module);
+            }
+        }
+
+        assertEquals("Set of to Generate Modules must contain 2 modules", 2,
+                toGenModules.size());
+        assertNotNull("Schema Context is null", context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);
+        assertNotNull("genTypes is null", genTypes);
+        assertFalse("genTypes is empty", genTypes.isEmpty());
+        assertEquals("Expected Generated Types from provided sub set of " +
+                "modules should be 23!", 23,
+                genTypes.size());
+    }
+
+    @Test
+    public void genTypesFromSubsetOfThreeModulesTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(yangModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        final Set<Module> toGenModules = new HashSet<>();
+        for (final Module module : modules) {
+            if (module.getName().equals("abstract-topology")) {
+                toGenModules.add(module);
+            } else if (module.getName().equals("ietf-interfaces")) {
+                toGenModules.add(module);
+            } else if (module.getName().equals("iana-if-type")) {
+                toGenModules.add(module);
+            }
+        }
+
+        assertEquals("Set of to Generate Modules must contain 3 modules", 3,
+                toGenModules.size());
+
+        assertNotNull("Schema Context is null", context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);
+        assertNotNull("genTypes is null", genTypes);
+        assertFalse("genTypes is empty", genTypes.isEmpty());
+        assertEquals("Expected Generated Types", 24, genTypes.size());
+    }
+}
index 250c9559d8643a2f61bb9501b4e9767b0b3df524..dff47a37406b4f24c428c91df864d1620df2561d 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.impl;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
-\r
-public class GeneratedTypesLeafrefTest {\r
-\r
-    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {\r
-        final YangModelParser parser = new YangParserImpl();\r
-\r
-        final List<File> inputFiles = new ArrayList<File>();\r
-        for (int i = 0; i < yangFiles.length; ++i) {\r
-            inputFiles.add(new File(yangFiles[i]));\r
-        }\r
-\r
-        final Set<Module> modules = parser.parseYangModels(inputFiles);\r
-        return parser.resolveSchemaContext(modules);\r
-    }\r
-\r
-    @Test\r
-    public void testLeafrefResolving() throws URISyntaxException {\r
-        final URI topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")\r
-                .toURI();\r
-        final URI interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")\r
-                .toURI();\r
-        final URI inetTypesPath = getClass().getResource("/leafref-test-models/ietf-inet-types@2010-09-24.yang")\r
-                .toURI();\r
-        final URI yangTypesPath = getClass().getResource("/leafref-test-models/ietf-yang-types@2010-09-24.yang")\r
-                .toURI();\r
-\r
-        assertNotNull(topologyPath);\r
-        assertNotNull(interfacesPath);\r
-        assertNotNull(inetTypesPath);\r
-        assertNotNull(yangTypesPath);\r
-\r
-        final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,\r
-                yangTypesPath);\r
-        assertNotNull(context);\r
-        assertEquals(4, context.getModules().size());\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertEquals(54, genTypes.size());\r
-        assertNotNull(genTypes);\r
-\r
-        GeneratedTransferObject gtIfcKey = null;\r
-        GeneratedType gtIfc = null;\r
-        GeneratedType gtNetworkLink = null;\r
-        GeneratedType gtSource = null;\r
-        GeneratedType gtDest = null;\r
-        GeneratedType gtTunnel = null;\r
-        GeneratedTransferObject gtTunnelKey = null;\r
-        GeneratedType gtTopology = null;\r
-        for (final Type type : genTypes) {\r
-            String name = type.getName();\r
-            if ("InterfaceKey".equals(name)) {\r
-                gtIfcKey = (GeneratedTransferObject) type;\r
-            } else if ("Interface".equals(name)) {\r
-                gtIfc = (GeneratedType) type;\r
-            } else if ("NetworkLink".equals(name)) {\r
-                gtNetworkLink = (GeneratedType) type;\r
-            } else if ("SourceNode".equals(name)) {\r
-                gtSource = (GeneratedType) type;\r
-            } else if ("DestinationNode".equals(name)) {\r
-                gtDest = (GeneratedType) type;\r
-            } else if ("Tunnel".equals(name)) {\r
-                gtTunnel = (GeneratedType) type;\r
-            } else if ("TunnelKey".equals(name)) {\r
-                gtTunnelKey = (GeneratedTransferObject) type;\r
-            } else if ("Topology".equals(name)) {\r
-                gtTopology = (GeneratedType) type;\r
-            }\r
-        }\r
-\r
-        assertNotNull(gtIfcKey);\r
-        assertNotNull(gtIfc);\r
-        assertNotNull(gtNetworkLink);\r
-        assertNotNull(gtSource);\r
-        assertNotNull(gtDest);\r
-        assertNotNull(gtTunnel);\r
-        assertNotNull(gtTunnelKey);\r
-        assertNotNull(gtTopology);\r
-\r
-        // Topology\r
-        final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();\r
-        assertNotNull(gtTopoMethods);\r
-        MethodSignature condLeafref = null;\r
-        for (final MethodSignature method : gtTopoMethods) {\r
-            if (method.getName().equals("getCondLeafref")) {\r
-                condLeafref = method;\r
-            }\r
-        }\r
-        assertNotNull(condLeafref);\r
-        Type condLeafRT = condLeafref.getReturnType();\r
-        assertNotNull(condLeafRT);\r
-        assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());\r
-\r
-        // InterfaceId\r
-        final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();\r
-        assertNotNull(gtIfcKeyProps);\r
-        GeneratedProperty ifcIdProp = null;\r
-        for (final GeneratedProperty property : gtIfcKeyProps) {\r
-            if (property.getName().equals("interfaceId")) {\r
-                ifcIdProp = property;\r
-            }\r
-        }\r
-        assertNotNull(ifcIdProp);\r
-        Type ifcIdPropType = ifcIdProp.getReturnType();\r
-        assertNotNull(ifcIdPropType);\r
-        assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());\r
-\r
-        // Interface\r
-        final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();\r
-        assertNotNull(gtIfcMethods);\r
-        MethodSignature getIfcKey = null;\r
-        MethodSignature getHigherLayerIf = null;\r
-        for (final MethodSignature method : gtIfcMethods) {\r
-            if (method.getName().equals("getKey")) {\r
-                getIfcKey = method;\r
-            } else if (method.getName().equals("getHigherLayerIf")) {\r
-                getHigherLayerIf = method;\r
-            }\r
-        }\r
-        assertNotNull(getIfcKey);\r
-        Type getIfcKeyType = getIfcKey.getReturnType();\r
-        assertNotNull(getIfcKeyType);\r
-        assertNotSame("java.lang.Void", getIfcKeyType);\r
-        assertEquals("InterfaceKey", getIfcKeyType.getName());\r
-\r
-        assertNotNull(getHigherLayerIf);\r
-        Type getHigherLayerIfType = getHigherLayerIf.getReturnType();\r
-        assertNotNull(getHigherLayerIfType);\r
-        assertNotSame("java.lang.Void", getHigherLayerIfType);\r
-        assertEquals("List", getHigherLayerIfType.getName());\r
-\r
-        // NetworkLink\r
-        final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();\r
-        assertNotNull(gtNetworkLinkMethods);\r
-        MethodSignature getIfc = null;\r
-        for (MethodSignature method : gtNetworkLinkMethods) {\r
-            if (method.getName().equals("getInterface")) {\r
-                getIfc = method;\r
-            }\r
-        }\r
-        assertNotNull(getIfc);\r
-        Type getIfcType = getIfc.getReturnType();\r
-        assertNotNull(getIfcType);\r
-        assertNotSame("java.lang.Void", getIfcType);\r
-        assertEquals("String", getIfcType.getName());\r
-\r
-        // SourceNode\r
-        final List<MethodSignature> gtSourceMethods = gtSource.getMethodDefinitions();\r
-        assertNotNull(gtSourceMethods);\r
-        MethodSignature getIdSource = null;\r
-        for (MethodSignature method : gtSourceMethods) {\r
-            if (method.getName().equals("getId")) {\r
-                getIdSource = method;\r
-            }\r
-        }\r
-        assertNotNull(getIdSource);\r
-        Type getIdType = getIdSource.getReturnType();\r
-        assertNotNull(getIdType);\r
-        assertNotSame("java.lang.Void", getIdType);\r
-        assertEquals("Uri", getIdType.getName());\r
-\r
-        // DestinationNode\r
-        final List<MethodSignature> gtDestMethods = gtDest.getMethodDefinitions();\r
-        assertNotNull(gtDestMethods);\r
-        MethodSignature getIdDest = null;\r
-        for (MethodSignature method : gtDestMethods) {\r
-            if (method.getName().equals("getId")) {\r
-                getIdDest = method;\r
-            }\r
-        }\r
-        assertNotNull(getIdDest);\r
-        Type getIdDestType = getIdDest.getReturnType();\r
-        assertNotNull(getIdDestType);\r
-        assertNotSame("java.lang.Void", getIdDestType);\r
-        assertEquals("Uri", getIdDestType.getName());\r
-\r
-        // Tunnel\r
-        final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();\r
-        assertNotNull(gtTunnelMethods);\r
-        MethodSignature getTunnelKey = null;\r
-        for (MethodSignature method : gtTunnelMethods) {\r
-            if (method.getName().equals("getKey")) {\r
-                getTunnelKey = method;\r
-            }\r
-        }\r
-        assertNotNull(getTunnelKey);\r
-        Type getTunnelKeyType = getTunnelKey.getReturnType();\r
-        assertNotNull(getTunnelKeyType);\r
-        assertNotSame("java.lang.Void", getTunnelKeyType);\r
-        assertEquals("TunnelKey", getTunnelKeyType.getName());\r
-\r
-        // TunnelKey\r
-        final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();\r
-        assertNotNull(gtTunnelKeyProps);\r
-        GeneratedProperty tunnelId = null;\r
-        for (final GeneratedProperty property : gtTunnelKeyProps) {\r
-            if (property.getName().equals("tunnelId")) {\r
-                tunnelId = property;\r
-            }\r
-        }\r
-        assertNotNull(tunnelId);\r
-        Type tunnelIdType = tunnelId.getReturnType();\r
-        assertNotNull(tunnelIdType);\r
-        assertNotSame("java.lang.Void", tunnelIdType);\r
-        assertEquals("Uri", tunnelIdType.getName());\r
-    }\r
-\r
-    @Test\r
-    public void testLeafrefInvalidPathResolving() throws URISyntaxException {\r
-        final URI resource = getClass().getResource("/leafref-test-invalid-model/foo.yang").toURI();\r
-        assertNotNull(resource);\r
-\r
-        final SchemaContext context = resolveSchemaContextFromFiles(resource);\r
-        assertNotNull(context);\r
-        assertEquals(1, context.getModules().size());\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        try {\r
-            bindingGen.generateTypes(context);\r
-            fail("Expected IllegalArgumentException caused by invalid leafref path");\r
-        } catch (IllegalArgumentException e) {\r
-            String expected = "Failed to find leafref target: ../id";\r
-            assertEquals(expected, e.getMessage());\r
-        }\r
-    }\r
-\r
+/*
+ * 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.yangtools.sal.binding.generator.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class GeneratedTypesLeafrefTest {
+
+    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
+        final YangModelParser parser = new YangParserImpl();
+
+        final List<File> inputFiles = new ArrayList<File>();
+        for (int i = 0; i < yangFiles.length; ++i) {
+            inputFiles.add(new File(yangFiles[i]));
+        }
+
+        final Set<Module> modules = parser.parseYangModels(inputFiles);
+        return parser.resolveSchemaContext(modules);
+    }
+
+    @Test
+    public void testLeafrefResolving() throws URISyntaxException {
+        final URI topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
+                .toURI();
+        final URI interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
+                .toURI();
+        final URI inetTypesPath = getClass().getResource("/leafref-test-models/ietf-inet-types@2010-09-24.yang")
+                .toURI();
+        final URI yangTypesPath = getClass().getResource("/leafref-test-models/ietf-yang-types@2010-09-24.yang")
+                .toURI();
+
+        assertNotNull(topologyPath);
+        assertNotNull(interfacesPath);
+        assertNotNull(inetTypesPath);
+        assertNotNull(yangTypesPath);
+
+        final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,
+                yangTypesPath);
+        assertNotNull(context);
+        assertEquals(4, context.getModules().size());
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertEquals(54, genTypes.size());
+        assertNotNull(genTypes);
+
+        GeneratedTransferObject gtIfcKey = null;
+        GeneratedType gtIfc = null;
+        GeneratedType gtNetworkLink = null;
+        GeneratedType gtSource = null;
+        GeneratedType gtDest = null;
+        GeneratedType gtTunnel = null;
+        GeneratedTransferObject gtTunnelKey = null;
+        GeneratedType gtTopology = null;
+        for (final Type type : genTypes) {
+            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;
+            } else if ("Topology".equals(name)) {
+                gtTopology = (GeneratedType) type;
+            }
+        }
+
+        assertNotNull(gtIfcKey);
+        assertNotNull(gtIfc);
+        assertNotNull(gtNetworkLink);
+        assertNotNull(gtSource);
+        assertNotNull(gtDest);
+        assertNotNull(gtTunnel);
+        assertNotNull(gtTunnelKey);
+        assertNotNull(gtTopology);
+
+        // Topology
+        final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();
+        assertNotNull(gtTopoMethods);
+        MethodSignature condLeafref = null;
+        for (final MethodSignature method : gtTopoMethods) {
+            if (method.getName().equals("getCondLeafref")) {
+                condLeafref = method;
+            }
+        }
+        assertNotNull(condLeafref);
+        Type condLeafRT = condLeafref.getReturnType();
+        assertNotNull(condLeafRT);
+        assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());
+
+        // 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);
+        assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());
+
+        // Interface
+        final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
+        assertNotNull(gtIfcMethods);
+        MethodSignature getIfcKey = null;
+        MethodSignature getHigherLayerIf = null;
+        for (final MethodSignature method : gtIfcMethods) {
+            if (method.getName().equals("getKey")) {
+                getIfcKey = method;
+            } else if (method.getName().equals("getHigherLayerIf")) {
+                getHigherLayerIf = method;
+            }
+        }
+        assertNotNull(getIfcKey);
+        Type getIfcKeyType = getIfcKey.getReturnType();
+        assertNotNull(getIfcKeyType);
+        assertNotSame("java.lang.Void", getIfcKeyType);
+        assertEquals("InterfaceKey", getIfcKeyType.getName());
+
+        assertNotNull(getHigherLayerIf);
+        Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
+        assertNotNull(getHigherLayerIfType);
+        assertNotSame("java.lang.Void", getHigherLayerIfType);
+        assertEquals("List", getHigherLayerIfType.getName());
+
+        // 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);
+        assertNotSame("java.lang.Void", getIfcType);
+        assertEquals("String", getIfcType.getName());
+
+        // 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);
+        assertNotSame("java.lang.Void", getIdType);
+        assertEquals("Uri", getIdType.getName());
+
+        // 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);
+        assertNotSame("java.lang.Void", getIdDestType);
+        assertEquals("Uri", getIdDestType.getName());
+
+        // Tunnel
+        final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();
+        assertNotNull(gtTunnelMethods);
+        MethodSignature getTunnelKey = null;
+        for (MethodSignature method : gtTunnelMethods) {
+            if (method.getName().equals("getKey")) {
+                getTunnelKey = method;
+            }
+        }
+        assertNotNull(getTunnelKey);
+        Type getTunnelKeyType = getTunnelKey.getReturnType();
+        assertNotNull(getTunnelKeyType);
+        assertNotSame("java.lang.Void", getTunnelKeyType);
+        assertEquals("TunnelKey", getTunnelKeyType.getName());
+
+        // TunnelKey
+        final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();
+        assertNotNull(gtTunnelKeyProps);
+        GeneratedProperty tunnelId = null;
+        for (final GeneratedProperty property : gtTunnelKeyProps) {
+            if (property.getName().equals("tunnelId")) {
+                tunnelId = property;
+            }
+        }
+        assertNotNull(tunnelId);
+        Type tunnelIdType = tunnelId.getReturnType();
+        assertNotNull(tunnelIdType);
+        assertNotSame("java.lang.Void", tunnelIdType);
+        assertEquals("Uri", tunnelIdType.getName());
+    }
+
+    @Test
+    public void testLeafrefInvalidPathResolving() throws URISyntaxException {
+        final URI resource = getClass().getResource("/leafref-test-invalid-model/foo.yang").toURI();
+        assertNotNull(resource);
+
+        final SchemaContext context = resolveSchemaContextFromFiles(resource);
+        assertNotNull(context);
+        assertEquals(1, context.getModules().size());
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        try {
+            bindingGen.generateTypes(context);
+            fail("Expected IllegalArgumentException caused by invalid leafref path");
+        } catch (IllegalArgumentException e) {
+            String expected = "Failed to find leafref target: ../id";
+            assertEquals(expected, e.getMessage());
+        }
+    }
+
 }
\ No newline at end of file
index ad72a050642870d908a565936240a80bf87b245d..e28a31697f68de80f3729515613e3f98ed326762 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.impl;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
-\r
-public class GeneratedTypesTest {\r
-\r
-    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {\r
-        final YangModelParser parser = new YangParserImpl();\r
-\r
-        final List<File> inputFiles = new ArrayList<File>();\r
-        for (int i = 0; i < yangFiles.length; ++i) {\r
-            inputFiles.add(new File(yangFiles[i]));\r
-        }\r
-\r
-        final Set<Module> modules = parser.parseYangModels(inputFiles);\r
-        return parser.resolveSchemaContext(modules);\r
-    }\r
-\r
-    @Test\r
-    public void testMultipleModulesResolving() throws URISyntaxException {\r
-        final URI topologyPath = getClass().getResource("/abstract-topology.yang").toURI();\r
-        final URI typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);\r
-        assertNotNull(context);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull(genTypes);\r
-        assertEquals(29, genTypes.size());\r
-    }\r
-\r
-    @Test\r
-    public void testContainerResolving() throws URISyntaxException {\r
-        final URI filePath = getClass().getResource("/simple-container-demo.yang").toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
-        assert (context != null);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull(genTypes);\r
-        assertEquals(3, genTypes.size());\r
-\r
-        GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);\r
-        GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);\r
-        for (Type t : genTypes) {\r
-            if ("SimpleContainer".equals(t.getName())) {\r
-                simpleContainer = (GeneratedType)t;\r
-            } else if ("NestedContainer".equals(t.getName())) {\r
-                nestedContainer = (GeneratedType)t;\r
-            }\r
-        }\r
-        assertNotNull(simpleContainer);\r
-        assertNotNull(nestedContainer);\r
-        assertEquals(3, simpleContainer.getMethodDefinitions().size());\r
-        assertEquals(2, nestedContainer.getMethodDefinitions().size());\r
-\r
-        int getFooMethodCounter = 0;\r
-        int getBarMethodCounter = 0;\r
-        int getNestedContainerCounter = 0;\r
-\r
-        String getFooMethodReturnTypeName = "";\r
-        String getBarMethodReturnTypeName = "";\r
-        String getNestedContainerReturnTypeName = "";\r
-        for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {\r
-            if (method.getName().equals("getFoo")) {\r
-                getFooMethodCounter++;\r
-                getFooMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-\r
-            if (method.getName().equals("getBar")) {\r
-                getBarMethodCounter++;\r
-                getBarMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-\r
-            if (method.getName().equals("getNestedContainer")) {\r
-                getNestedContainerCounter++;\r
-                getNestedContainerReturnTypeName = method.getReturnType().getName();\r
-            }\r
-        }\r
-\r
-        assertEquals(1, getFooMethodCounter);\r
-        assertEquals("Integer", getFooMethodReturnTypeName);\r
-\r
-        assertEquals(1, getBarMethodCounter);\r
-        assertEquals("String", getBarMethodReturnTypeName);\r
-\r
-        assertEquals(1, getNestedContainerCounter);\r
-        assertEquals("NestedContainer", getNestedContainerReturnTypeName);\r
-\r
-        getFooMethodCounter = 0;\r
-        getBarMethodCounter = 0;\r
-\r
-        getFooMethodReturnTypeName = "";\r
-        getBarMethodReturnTypeName = "";\r
-\r
-        for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {\r
-\r
-            if (method.getName().equals("getFoo")) {\r
-                getFooMethodCounter++;\r
-                getFooMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-\r
-            if (method.getName().equals("getBar")) {\r
-                getBarMethodCounter++;\r
-                getBarMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-        }\r
-\r
-        assertEquals(1, getFooMethodCounter);\r
-        assertEquals("Short", getFooMethodReturnTypeName);\r
-\r
-        assertEquals(1, getBarMethodCounter);\r
-        assertEquals("String", getBarMethodReturnTypeName);\r
-    }\r
-\r
-    @Test\r
-    public void testLeafListResolving() throws URISyntaxException {\r
-        final URI filePath = getClass().getResource("/simple-leaf-list-demo.yang").toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
-        assertNotNull(context);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull(genTypes);\r
-        assertEquals(3, genTypes.size());\r
-\r
-        GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);\r
-        GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);\r
-        for (Type t : genTypes) {\r
-            if ("SimpleContainer".equals(t.getName())) {\r
-                simpleContainer = (GeneratedType)t;\r
-            } else if ("NestedContainer".equals(t.getName())) {\r
-                nestedContainer = (GeneratedType)t;\r
-            }\r
-        }\r
-        assertNotNull(simpleContainer);\r
-        assertNotNull(nestedContainer);\r
-        assertEquals(3, simpleContainer.getMethodDefinitions().size());\r
-        assertEquals(2, nestedContainer.getMethodDefinitions().size());\r
-\r
-        int getFooMethodCounter = 0;\r
-        int getBarMethodCounter = 0;\r
-        int getNestedContainerCounter = 0;\r
-\r
-        String getFooMethodReturnTypeName = "";\r
-        String getBarMethodReturnTypeName = "";\r
-        String getNestedContainerReturnTypeName = "";\r
-        for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {\r
-            if (method.getName().equals("getFoo")) {\r
-                getFooMethodCounter++;\r
-                getFooMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-\r
-            if (method.getName().equals("getBar")) {\r
-                getBarMethodCounter++;\r
-                getBarMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-\r
-            if (method.getName().equals("getNestedContainer")) {\r
-                getNestedContainerCounter++;\r
-                getNestedContainerReturnTypeName = method.getReturnType().getName();\r
-            }\r
-        }\r
-\r
-        assertEquals(1, getFooMethodCounter);\r
-        assertEquals("List", getFooMethodReturnTypeName);\r
-\r
-        assertEquals(1, getBarMethodCounter);\r
-        assertEquals("String", getBarMethodReturnTypeName);\r
-\r
-        assertEquals(1, getNestedContainerCounter);\r
-        assertEquals("NestedContainer", getNestedContainerReturnTypeName);\r
-\r
-        getFooMethodCounter = 0;\r
-        getBarMethodCounter = 0;\r
-\r
-        getFooMethodReturnTypeName = "";\r
-        getBarMethodReturnTypeName = "";\r
-\r
-        for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {\r
-            if (method.getName().equals("getFoo")) {\r
-                getFooMethodCounter++;\r
-                getFooMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-\r
-            if (method.getName().equals("getBar")) {\r
-                getBarMethodCounter++;\r
-                getBarMethodReturnTypeName = method.getReturnType().getName();\r
-            }\r
-        }\r
-\r
-        assertEquals(1, getFooMethodCounter);\r
-        assertEquals("Short", getFooMethodReturnTypeName);\r
-\r
-        assertEquals(1, getBarMethodCounter);\r
-        assertEquals("List", getBarMethodReturnTypeName);\r
-    }\r
-\r
-    @Test\r
-    public void testListResolving() throws URISyntaxException {\r
-        final URI filePath = getClass().getResource("/simple-list-demo.yang").toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
-        assertNotNull(context);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull(genTypes);\r
-        assertEquals(5, genTypes.size());\r
-\r
-        int listParentContainerMethodsCount = 0;\r
-        int simpleListMethodsCount = 0;\r
-        int listChildContainerMethodsCount = 0;\r
-        int listKeyClassCount = 0;\r
-\r
-        int getSimpleListKeyMethodCount = 0;\r
-        int getListChildContainerMethodCount = 0;\r
-        int getFooMethodCount = 0;\r
-        int setFooMethodCount = 0;\r
-        int getSimpleLeafListMethodCount = 0;\r
-        int setSimpleLeafListMethodCount = 0;\r
-        int getBarMethodCount = 0;\r
-\r
-        String getSimpleListKeyMethodReturnTypeName = "";\r
-        String getListChildContainerMethodReturnTypeName = "";\r
-\r
-        int listKeyClassPropertyCount = 0;\r
-        String listKeyClassPropertyName = "";\r
-        String listKeyClassPropertyTypeName = "";\r
-        boolean listKeyClassPropertyReadOnly = false;\r
-\r
-        int hashMethodParameterCount = 0;\r
-        String hashMethodParameterName = "";\r
-        String hashMethodParameterReturnTypeName = "";\r
-\r
-        int equalMethodParameterCount = 0;\r
-        String equalMethodParameterName = "";\r
-        String equalMethodParameterReturnTypeName = "";\r
-\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
-                final GeneratedType genType = (GeneratedType) type;\r
-                if (genType.getName().equals("ListParentContainer")) {\r
-                    listParentContainerMethodsCount = genType.getMethodDefinitions().size();\r
-                } else if (genType.getName().equals("SimpleList")) {\r
-                    simpleListMethodsCount = genType.getMethodDefinitions().size();\r
-                    final List<MethodSignature> methods = genType.getMethodDefinitions();\r
-                    for (final MethodSignature method : methods) {\r
-                        if (method.getName().equals("getKey")) {\r
-                            getSimpleListKeyMethodCount++;\r
-                            getSimpleListKeyMethodReturnTypeName = method.getReturnType().getName();\r
-                        } else if (method.getName().equals("getListChildContainer")) {\r
-                            getListChildContainerMethodCount++;\r
-                            getListChildContainerMethodReturnTypeName = method.getReturnType().getName();\r
-                        } else if (method.getName().equals("getFoo")) {\r
-                            getFooMethodCount++;\r
-                        } else if (method.getName().equals("setFoo")) {\r
-                            setFooMethodCount++;\r
-                        } else if (method.getName().equals("getSimpleLeafList")) {\r
-                            getSimpleLeafListMethodCount++;\r
-                        } else if (method.getName().equals("setSimpleLeafList")) {\r
-                            setSimpleLeafListMethodCount++;\r
-                        } else if (method.getName().equals("getBar")) {\r
-                            getBarMethodCount++;\r
-                        }\r
-                    }\r
-                } else if (genType.getName().equals("ListChildContainer")) {\r
-                    listChildContainerMethodsCount = genType.getMethodDefinitions().size();\r
-                }\r
-            } else if (type instanceof GeneratedTransferObject) {\r
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
-                final List<GeneratedProperty> properties = genTO.getProperties();\r
-                final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();\r
-                final List<GeneratedProperty> equalProps = genTO.getEqualsIdentifiers();\r
-\r
-                listKeyClassCount++;\r
-                listKeyClassPropertyCount = properties.size();\r
-                listKeyClassPropertyName = properties.get(0).getName();\r
-                listKeyClassPropertyTypeName = properties.get(0).getReturnType().getName();\r
-                listKeyClassPropertyReadOnly = properties.get(0).isReadOnly();\r
-\r
-                hashMethodParameterCount = hashProps.size();\r
-                hashMethodParameterName = hashProps.get(0).getName();\r
-                hashMethodParameterReturnTypeName = hashProps.get(0).getReturnType().getName();\r
-\r
-                equalMethodParameterCount = equalProps.size();\r
-                equalMethodParameterName = equalProps.get(0).getName();\r
-                equalMethodParameterReturnTypeName = equalProps.get(0).getReturnType().getName();\r
-\r
-            }\r
-        }\r
-\r
-        assertEquals(1, listParentContainerMethodsCount);\r
-        assertEquals(1, listChildContainerMethodsCount);\r
-        assertEquals(1, getSimpleListKeyMethodCount);\r
-        assertEquals(1, listKeyClassCount);\r
-\r
-        assertEquals(1, listKeyClassPropertyCount);\r
-        assertEquals("listKey", listKeyClassPropertyName);\r
-        assertEquals("Byte", listKeyClassPropertyTypeName);\r
-        assertEquals(true, listKeyClassPropertyReadOnly);\r
-        assertEquals(1, hashMethodParameterCount);\r
-        assertEquals("listKey", hashMethodParameterName);\r
-        assertEquals("Byte", hashMethodParameterReturnTypeName);\r
-        assertEquals(1, equalMethodParameterCount);\r
-        assertEquals("listKey", equalMethodParameterName);\r
-        assertEquals("Byte", equalMethodParameterReturnTypeName);\r
-\r
-        assertEquals("SimpleListKey", getSimpleListKeyMethodReturnTypeName);\r
-\r
-        assertEquals(1, getListChildContainerMethodCount);\r
-        assertEquals("ListChildContainer", getListChildContainerMethodReturnTypeName);\r
-        assertEquals(1, getFooMethodCount);\r
-        assertEquals(0, setFooMethodCount);\r
-        assertEquals(1, getSimpleLeafListMethodCount);\r
-        assertEquals(0, setSimpleLeafListMethodCount);\r
-        assertEquals(1, getBarMethodCount);\r
-\r
-        assertEquals(6, simpleListMethodsCount);\r
-    }\r
-\r
-    @Test\r
-    public void testListCompositeKeyResolving() throws URISyntaxException {\r
-        final URI filePath = getClass().getResource("/list-composite-key.yang").toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
-\r
-        assertNotNull(context);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull(genTypes);\r
-        assertEquals(7, genTypes.size());\r
-\r
-        int genTypesCount = 0;\r
-        int genTOsCount = 0;\r
-\r
-        int compositeKeyListKeyPropertyCount = 0;\r
-        int compositeKeyListKeyCount = 0;\r
-        int innerListKeyPropertyCount = 0;\r
-\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
-                genTypesCount++;\r
-            } else if (type instanceof GeneratedTransferObject) {\r
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
-\r
-                if (genTO.getName().equals("CompositeKeyListKey")) {\r
-                    compositeKeyListKeyCount++;\r
-                    final List<GeneratedProperty> properties = genTO.getProperties();\r
-                    for (final GeneratedProperty prop : properties) {\r
-                        if (prop.getName().equals("key1")) {\r
-                            compositeKeyListKeyPropertyCount++;\r
-                        } else if (prop.getName().equals("key2")) {\r
-                            compositeKeyListKeyPropertyCount++;\r
-                        }\r
-                    }\r
-                    genTOsCount++;\r
-                } else if (genTO.getName().equals("InnerListKey")) {\r
-                    final List<GeneratedProperty> properties = genTO.getProperties();\r
-                    innerListKeyPropertyCount = properties.size();\r
-                    genTOsCount++;\r
-                }\r
-            }\r
-        }\r
-        assertEquals(1, compositeKeyListKeyCount);\r
-        assertEquals(2, compositeKeyListKeyPropertyCount);\r
-\r
-        assertEquals(1, innerListKeyPropertyCount);\r
-\r
-        assertEquals(5, genTypesCount);\r
-        assertEquals(2, genTOsCount);\r
-    }\r
-\r
-    @Test\r
-    public void testGeneratedTypes() throws URISyntaxException {\r
-        final URI filePath = getClass().getResource("/demo-topology.yang").toURI();\r
-        final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
-        assertNotNull(context);\r
-\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertNotNull(genTypes);\r
-        assertEquals(14, genTypes.size());\r
-\r
-        int genTypesCount = 0;\r
-        int genTOsCount = 0;\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
-                genTypesCount++;\r
-            } else if (type instanceof GeneratedTransferObject) {\r
-                genTOsCount++;\r
-            }\r
-        }\r
-\r
-        assertEquals(11, genTypesCount);\r
-        assertEquals(3, genTOsCount);\r
-    }\r
-}\r
+/*
+ * 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.yangtools.sal.binding.generator.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class GeneratedTypesTest {
+
+    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
+        final YangModelParser parser = new YangParserImpl();
+
+        final List<File> inputFiles = new ArrayList<File>();
+        for (int i = 0; i < yangFiles.length; ++i) {
+            inputFiles.add(new File(yangFiles[i]));
+        }
+
+        final Set<Module> modules = parser.parseYangModels(inputFiles);
+        return parser.resolveSchemaContext(modules);
+    }
+
+    @Test
+    public void testMultipleModulesResolving() throws URISyntaxException {
+        final URI topologyPath = getClass().getResource("/abstract-topology.yang").toURI();
+        final URI typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
+        assertNotNull(context);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertEquals(29, genTypes.size());
+    }
+
+    @Test
+    public void testContainerResolving() throws URISyntaxException {
+        final URI filePath = getClass().getResource("/simple-container-demo.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assert (context != null);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertEquals(3, genTypes.size());
+
+        GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
+        GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
+        for (Type t : genTypes) {
+            if ("SimpleContainer".equals(t.getName())) {
+                simpleContainer = (GeneratedType)t;
+            } else if ("NestedContainer".equals(t.getName())) {
+                nestedContainer = (GeneratedType)t;
+            }
+        }
+        assertNotNull(simpleContainer);
+        assertNotNull(nestedContainer);
+        assertEquals(3, simpleContainer.getMethodDefinitions().size());
+        assertEquals(2, nestedContainer.getMethodDefinitions().size());
+
+        int getFooMethodCounter = 0;
+        int getBarMethodCounter = 0;
+        int getNestedContainerCounter = 0;
+
+        String getFooMethodReturnTypeName = "";
+        String getBarMethodReturnTypeName = "";
+        String getNestedContainerReturnTypeName = "";
+        for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
+            }
+
+            if (method.getName().equals("getBar")) {
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
+            }
+
+            if (method.getName().equals("getNestedContainer")) {
+                getNestedContainerCounter++;
+                getNestedContainerReturnTypeName = method.getReturnType().getName();
+            }
+        }
+
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("Integer", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("String", getBarMethodReturnTypeName);
+
+        assertEquals(1, getNestedContainerCounter);
+        assertEquals("NestedContainer", getNestedContainerReturnTypeName);
+
+        getFooMethodCounter = 0;
+        getBarMethodCounter = 0;
+
+        getFooMethodReturnTypeName = "";
+        getBarMethodReturnTypeName = "";
+
+        for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
+
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
+            }
+
+            if (method.getName().equals("getBar")) {
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
+            }
+        }
+
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("Short", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("String", getBarMethodReturnTypeName);
+    }
+
+    @Test
+    public void testLeafListResolving() throws URISyntaxException {
+        final URI filePath = getClass().getResource("/simple-leaf-list-demo.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertNotNull(context);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertEquals(3, genTypes.size());
+
+        GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
+        GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
+        for (Type t : genTypes) {
+            if ("SimpleContainer".equals(t.getName())) {
+                simpleContainer = (GeneratedType)t;
+            } else if ("NestedContainer".equals(t.getName())) {
+                nestedContainer = (GeneratedType)t;
+            }
+        }
+        assertNotNull(simpleContainer);
+        assertNotNull(nestedContainer);
+        assertEquals(3, simpleContainer.getMethodDefinitions().size());
+        assertEquals(2, nestedContainer.getMethodDefinitions().size());
+
+        int getFooMethodCounter = 0;
+        int getBarMethodCounter = 0;
+        int getNestedContainerCounter = 0;
+
+        String getFooMethodReturnTypeName = "";
+        String getBarMethodReturnTypeName = "";
+        String getNestedContainerReturnTypeName = "";
+        for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
+            }
+
+            if (method.getName().equals("getBar")) {
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
+            }
+
+            if (method.getName().equals("getNestedContainer")) {
+                getNestedContainerCounter++;
+                getNestedContainerReturnTypeName = method.getReturnType().getName();
+            }
+        }
+
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("List", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("String", getBarMethodReturnTypeName);
+
+        assertEquals(1, getNestedContainerCounter);
+        assertEquals("NestedContainer", getNestedContainerReturnTypeName);
+
+        getFooMethodCounter = 0;
+        getBarMethodCounter = 0;
+
+        getFooMethodReturnTypeName = "";
+        getBarMethodReturnTypeName = "";
+
+        for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
+            }
+
+            if (method.getName().equals("getBar")) {
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
+            }
+        }
+
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("Short", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("List", getBarMethodReturnTypeName);
+    }
+
+    @Test
+    public void testListResolving() throws URISyntaxException {
+        final URI filePath = getClass().getResource("/simple-list-demo.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertNotNull(context);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertEquals(5, genTypes.size());
+
+        int listParentContainerMethodsCount = 0;
+        int simpleListMethodsCount = 0;
+        int listChildContainerMethodsCount = 0;
+        int listKeyClassCount = 0;
+
+        int getSimpleListKeyMethodCount = 0;
+        int getListChildContainerMethodCount = 0;
+        int getFooMethodCount = 0;
+        int setFooMethodCount = 0;
+        int getSimpleLeafListMethodCount = 0;
+        int setSimpleLeafListMethodCount = 0;
+        int getBarMethodCount = 0;
+
+        String getSimpleListKeyMethodReturnTypeName = "";
+        String getListChildContainerMethodReturnTypeName = "";
+
+        int listKeyClassPropertyCount = 0;
+        String listKeyClassPropertyName = "";
+        String listKeyClassPropertyTypeName = "";
+        boolean listKeyClassPropertyReadOnly = false;
+
+        int hashMethodParameterCount = 0;
+        String hashMethodParameterName = "";
+        String hashMethodParameterReturnTypeName = "";
+
+        int equalMethodParameterCount = 0;
+        String equalMethodParameterName = "";
+        String equalMethodParameterReturnTypeName = "";
+
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+                final GeneratedType genType = (GeneratedType) type;
+                if (genType.getName().equals("ListParentContainer")) {
+                    listParentContainerMethodsCount = genType.getMethodDefinitions().size();
+                } else if (genType.getName().equals("SimpleList")) {
+                    simpleListMethodsCount = genType.getMethodDefinitions().size();
+                    final List<MethodSignature> methods = genType.getMethodDefinitions();
+                    for (final MethodSignature method : methods) {
+                        if (method.getName().equals("getKey")) {
+                            getSimpleListKeyMethodCount++;
+                            getSimpleListKeyMethodReturnTypeName = method.getReturnType().getName();
+                        } else if (method.getName().equals("getListChildContainer")) {
+                            getListChildContainerMethodCount++;
+                            getListChildContainerMethodReturnTypeName = method.getReturnType().getName();
+                        } else if (method.getName().equals("getFoo")) {
+                            getFooMethodCount++;
+                        } else if (method.getName().equals("setFoo")) {
+                            setFooMethodCount++;
+                        } else if (method.getName().equals("getSimpleLeafList")) {
+                            getSimpleLeafListMethodCount++;
+                        } else if (method.getName().equals("setSimpleLeafList")) {
+                            setSimpleLeafListMethodCount++;
+                        } else if (method.getName().equals("getBar")) {
+                            getBarMethodCount++;
+                        }
+                    }
+                } else if (genType.getName().equals("ListChildContainer")) {
+                    listChildContainerMethodsCount = genType.getMethodDefinitions().size();
+                }
+            } else if (type instanceof GeneratedTransferObject) {
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+                final List<GeneratedProperty> properties = genTO.getProperties();
+                final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();
+                final List<GeneratedProperty> equalProps = genTO.getEqualsIdentifiers();
+
+                listKeyClassCount++;
+                listKeyClassPropertyCount = properties.size();
+                listKeyClassPropertyName = properties.get(0).getName();
+                listKeyClassPropertyTypeName = properties.get(0).getReturnType().getName();
+                listKeyClassPropertyReadOnly = properties.get(0).isReadOnly();
+
+                hashMethodParameterCount = hashProps.size();
+                hashMethodParameterName = hashProps.get(0).getName();
+                hashMethodParameterReturnTypeName = hashProps.get(0).getReturnType().getName();
+
+                equalMethodParameterCount = equalProps.size();
+                equalMethodParameterName = equalProps.get(0).getName();
+                equalMethodParameterReturnTypeName = equalProps.get(0).getReturnType().getName();
+
+            }
+        }
+
+        assertEquals(1, listParentContainerMethodsCount);
+        assertEquals(1, listChildContainerMethodsCount);
+        assertEquals(1, getSimpleListKeyMethodCount);
+        assertEquals(1, listKeyClassCount);
+
+        assertEquals(1, listKeyClassPropertyCount);
+        assertEquals("listKey", listKeyClassPropertyName);
+        assertEquals("Byte", listKeyClassPropertyTypeName);
+        assertEquals(true, listKeyClassPropertyReadOnly);
+        assertEquals(1, hashMethodParameterCount);
+        assertEquals("listKey", hashMethodParameterName);
+        assertEquals("Byte", hashMethodParameterReturnTypeName);
+        assertEquals(1, equalMethodParameterCount);
+        assertEquals("listKey", equalMethodParameterName);
+        assertEquals("Byte", equalMethodParameterReturnTypeName);
+
+        assertEquals("SimpleListKey", getSimpleListKeyMethodReturnTypeName);
+
+        assertEquals(1, getListChildContainerMethodCount);
+        assertEquals("ListChildContainer", getListChildContainerMethodReturnTypeName);
+        assertEquals(1, getFooMethodCount);
+        assertEquals(0, setFooMethodCount);
+        assertEquals(1, getSimpleLeafListMethodCount);
+        assertEquals(0, setSimpleLeafListMethodCount);
+        assertEquals(1, getBarMethodCount);
+
+        assertEquals(6, simpleListMethodsCount);
+    }
+
+    @Test
+    public void testListCompositeKeyResolving() throws URISyntaxException {
+        final URI filePath = getClass().getResource("/list-composite-key.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+
+        assertNotNull(context);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertEquals(7, genTypes.size());
+
+        int genTypesCount = 0;
+        int genTOsCount = 0;
+
+        int compositeKeyListKeyPropertyCount = 0;
+        int compositeKeyListKeyCount = 0;
+        int innerListKeyPropertyCount = 0;
+
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+                genTypesCount++;
+            } else if (type instanceof GeneratedTransferObject) {
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+
+                if (genTO.getName().equals("CompositeKeyListKey")) {
+                    compositeKeyListKeyCount++;
+                    final List<GeneratedProperty> properties = genTO.getProperties();
+                    for (final GeneratedProperty prop : properties) {
+                        if (prop.getName().equals("key1")) {
+                            compositeKeyListKeyPropertyCount++;
+                        } else if (prop.getName().equals("key2")) {
+                            compositeKeyListKeyPropertyCount++;
+                        }
+                    }
+                    genTOsCount++;
+                } else if (genTO.getName().equals("InnerListKey")) {
+                    final List<GeneratedProperty> properties = genTO.getProperties();
+                    innerListKeyPropertyCount = properties.size();
+                    genTOsCount++;
+                }
+            }
+        }
+        assertEquals(1, compositeKeyListKeyCount);
+        assertEquals(2, compositeKeyListKeyPropertyCount);
+
+        assertEquals(1, innerListKeyPropertyCount);
+
+        assertEquals(5, genTypesCount);
+        assertEquals(2, genTOsCount);
+    }
+
+    @Test
+    public void testGeneratedTypes() throws URISyntaxException {
+        final URI filePath = getClass().getResource("/demo-topology.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertNotNull(context);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertEquals(14, genTypes.size());
+
+        int genTypesCount = 0;
+        int genTOsCount = 0;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+                genTypesCount++;
+            } else if (type instanceof GeneratedTransferObject) {
+                genTOsCount++;
+            }
+        }
+
+        assertEquals(11, genTypesCount);
+        assertEquals(3, genTOsCount);
+    }
+}
index e2d6b71241234ba7e233ce24398d7f240dd44328..89d7a8cc76bb7919d772b2f9895384b94221ee67 100644 (file)
@@ -1,53 +1,53 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.spi;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
-\r
-public interface TypeProvider {\r
-\r
-    @Deprecated\r
-    Type javaTypeForYangType(String type);\r
-\r
-    /**\r
-     * Resolve of yang Type Definition to it's java counter part.\r
-     * If the Type Definition contains one of yang primitive types the method\r
-     * will return java.lang. counterpart. (For example if yang type is int32\r
-     * the java counterpart is java.lang.Integer). In case that Type\r
-     * Definition contains extended type defined via yang typedef statement\r
-     * the method SHOULD return Generated Type or Generated Transfer Object\r
-     * if that Type is correctly referenced to resolved imported yang module.\r
-     * The method will return <code>null</code> value in situations that\r
-     * TypeDefinition can't be resolved (either due missing yang import or\r
-     * incorrectly specified type).\r
-     *\r
-     *\r
-     * @param type Type Definition to resolve from\r
-     * @return Resolved Type\r
-     */\r
-    Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode);\r
-\r
-    Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode, final Restrictions restrictions);\r
-\r
-    /**\r
-     * Returns string containing code for creation of new type instance.\r
-     *\r
-     * @param node\r
-     * @return\r
-     */\r
-    String getTypeDefaultConstruction(LeafSchemaNode node);\r
-\r
-    String getConstructorPropertyName(SchemaNode node);\r
-\r
-    String getParamNameFromType(TypeDefinition<?> type);\r
-\r
-}\r
+/*
+ * 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.yangtools.sal.binding.generator.spi;
+
+import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+
+public interface TypeProvider {
+
+    @Deprecated
+    Type javaTypeForYangType(String type);
+
+    /**
+     * Resolve of yang Type Definition to it's java counter part.
+     * If the Type Definition contains one of yang primitive types the method
+     * will return java.lang. counterpart. (For example if yang type is int32
+     * the java counterpart is java.lang.Integer). In case that Type
+     * Definition contains extended type defined via yang typedef statement
+     * the method SHOULD return Generated Type or Generated Transfer Object
+     * if that Type is correctly referenced to resolved imported yang module.
+     * The method will return <code>null</code> value in situations that
+     * TypeDefinition can't be resolved (either due missing yang import or
+     * incorrectly specified type).
+     *
+     *
+     * @param type Type Definition to resolve from
+     * @return Resolved Type
+     */
+    Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode);
+
+    Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode, final Restrictions restrictions);
+
+    /**
+     * Returns string containing code for creation of new type instance.
+     *
+     * @param node
+     * @return
+     */
+    String getTypeDefaultConstruction(LeafSchemaNode node);
+
+    String getConstructorPropertyName(SchemaNode node);
+
+    String getParamNameFromType(TypeDefinition<?> type);
+
+}
index 4b91743f854e1f6d7c2b4938c822a7e70b3047f8..65b4db26c4ca5110afe1be7e6f139a2f93d396ee 100644 (file)
@@ -1,8 +1,8 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+/*
+ * 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.yangtools.sal.binding.generator.spi;
\ No newline at end of file
index 2b2e0b3f738205730fc61bbd6b1e6f52f81edee0..51721882883201c377ddb8e51c1a2e237aef3928 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;\r
-\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;\r
-import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.sal.binding.model.api.TypeMember;\r
-\r
-abstract class AbstractTypeMember implements TypeMember {\r
-\r
-    private final String name;\r
-    private final String comment;\r
-    private final Type definingType;\r
-    private final Type returnType;\r
-    private final List<AnnotationType> annotations;\r
-    private final boolean isFinal;\r
-    private final boolean isStatic;\r
-    private final AccessModifier accessModifier;\r
-\r
-    public AbstractTypeMember(final Type definingType, final String name,  final List<AnnotationType> annotations,\r
-                              final String comment, final AccessModifier accessModifier, final Type returnType,\r
-                              boolean isFinal, boolean isStatic) {\r
-        super();\r
-        this.definingType = definingType;\r
-        this.name = name;\r
-        this.annotations = Collections.unmodifiableList(annotations);\r
-        this.comment = comment;\r
-        this.accessModifier = accessModifier;\r
-        this.returnType = returnType;\r
-        this.isFinal = isFinal;\r
-        this.isStatic = isStatic;\r
-    }\r
-\r
-    @Override\r
-    public List<AnnotationType> getAnnotations() {\r
-        return annotations;\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public String getComment() {\r
-        return comment;\r
-    }\r
-\r
-    @Override\r
-    public Type getDefiningType() {\r
-        return definingType;\r
-    }\r
-\r
-    @Override\r
-    public AccessModifier getAccessModifier() {\r
-        return accessModifier;\r
-    }\r
-\r
-    @Override\r
-    public Type getReturnType() {\r
-        return returnType;\r
-    }\r
-\r
-    @Override\r
-    public boolean isFinal() {\r
-        return isFinal;\r
-    }\r
-\r
-    @Override\r
-    public boolean isStatic() {\r
-        return isStatic;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());\r
-        result = prime * result\r
-                + ((getReturnType() == null) ? 0 : getReturnType().hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj == null) {\r
-            return false;\r
-        }\r
-        if (getClass() != obj.getClass()) {\r
-            return false;\r
-        }\r
-        AbstractTypeMember other = (AbstractTypeMember) obj;\r
-        if (getName() == null) {\r
-            if (other.getName() != null) {\r
-                return false;\r
-            }\r
-        } else if (!getName().equals(other.getName())) {\r
-            return false;\r
-        }\r
-        if (getReturnType() == null) {\r
-            if (other.getReturnType() != null) {\r
-                return false;\r
-            }\r
-        } else if (!getReturnType().equals(other.getReturnType())) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append("MethodSignatureImpl [name=");\r
-        builder.append(getName());\r
-        builder.append(", comment=");\r
-        builder.append(getComment());\r
-        if (getDefiningType() != null) {\r
-            builder.append(", definingType=");\r
-            builder.append(getDefiningType().getPackageName());\r
-            builder.append(".");\r
-            builder.append(getDefiningType().getName());\r
-        } else {\r
-            builder.append(", definingType= null");\r
-        }\r
-        builder.append(", returnType=");\r
-        builder.append(getReturnType());\r
-        builder.append(", annotations=");\r
-        builder.append(getAnnotations());\r
-        builder.append("]");\r
-        return builder.toString();\r
-    }\r
-}\r
+/*
+ * 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.yangtools.binding.generator.util.generated.type.builder;
+
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
+import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.sal.binding.model.api.TypeMember;
+
+abstract class AbstractTypeMember implements TypeMember {
+
+    private final String name;
+    private final String comment;
+    private final Type definingType;
+    private final Type returnType;
+    private final List<AnnotationType> annotations;
+    private final boolean isFinal;
+    private final boolean isStatic;
+    private final AccessModifier accessModifier;
+
+    public AbstractTypeMember(final Type definingType, final String name,  final List<AnnotationType> annotations,
+                              final String comment, final AccessModifier accessModifier, final Type returnType,
+                              boolean isFinal, boolean isStatic) {
+        super();
+        this.definingType = definingType;
+        this.name = name;
+        this.annotations = Collections.unmodifiableList(annotations);
+        this.comment = comment;
+        this.accessModifier = accessModifier;
+        this.returnType = returnType;
+        this.isFinal = isFinal;
+        this.isStatic = isStatic;
+    }
+
+    @Override
+    public List<AnnotationType> getAnnotations() {
+        return annotations;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getComment() {
+        return comment;
+    }
+
+    @Override
+    public Type getDefiningType() {
+        return definingType;
+    }
+
+    @Override
+    public AccessModifier getAccessModifier() {
+        return accessModifier;
+    }
+
+    @Override
+    public Type getReturnType() {
+        return returnType;
+    }
+
+    @Override
+    public boolean isFinal() {
+        return isFinal;
+    }
+
+    @Override
+    public boolean isStatic() {
+        return isStatic;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result
+                + ((getReturnType() == null) ? 0 : getReturnType().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;
+        }
+        AbstractTypeMember other = (AbstractTypeMember) obj;
+        if (getName() == null) {
+            if (other.getName() != null) {
+                return false;
+            }
+        } else if (!getName().equals(other.getName())) {
+            return false;
+        }
+        if (getReturnType() == null) {
+            if (other.getReturnType() != null) {
+                return false;
+            }
+        } else if (!getReturnType().equals(other.getReturnType())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureImpl [name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", definingType=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append("]");
+        return builder.toString();
+    }
+}
index ea7550f98db99f3e93902a859d4cef9c6d913878..e2ca93bbe49db64bf874195c08d584a4edd4c40f 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;\r
-\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToClassName;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Constant;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.AnnotationTypeBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.EnumBuilder;\r
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;\r
-\r
-public final class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuilder {\r
-    private final String packageName;\r
-    private final String name;\r
-    private final List<Enumeration.Pair> values;\r
-    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<>();\r
-\r
-    public EnumerationBuilderImpl(final String packageName, final String name) {\r
-        super(packageName, name);\r
-        this.packageName = packageName;\r
-        this.name = name;\r
-        values = new ArrayList<>();\r
-    }\r
-\r
-    @Override\r
-    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {\r
-        if (packageName != null && name != null) {\r
-            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);\r
-            if (annotationBuilders.add(builder)) {\r
-                return builder;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public void addValue(final String name, final Integer value) {\r
-        values.add(new EnumPairImpl(name, value));\r
-    }\r
-\r
-    @Override\r
-    public Enumeration toInstance(final Type definingType) {\r
-        return new EnumerationImpl(definingType, annotationBuilders, packageName, name, values);\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * \r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-        result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());\r
-        return result;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * \r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj == null) {\r
-            return false;\r
-        }\r
-        if (getClass() != obj.getClass()) {\r
-            return false;\r
-        }\r
-        EnumerationBuilderImpl other = (EnumerationBuilderImpl) obj;\r
-        if (name == null) {\r
-            if (other.name != null) {\r
-                return false;\r
-            }\r
-        } else if (!name.equals(other.name)) {\r
-            return false;\r
-        }\r
-        if (packageName == null) {\r
-            if (other.packageName != null) {\r
-                return false;\r
-            }\r
-        } else if (!packageName.equals(other.packageName)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * \r
-     * @see java.lang.Object#toString()\r
-     */\r
-    @Override\r
-    public String toString() {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append("EnumerationBuilderImpl [packageName=");\r
-        builder.append(packageName);\r
-        builder.append(", name=");\r
-        builder.append(name);\r
-        builder.append(", values=");\r
-        builder.append(values);\r
-        builder.append("]");\r
-        return builder.toString();\r
-    }\r
-\r
-    @Override\r
-    public void updateEnumPairsFromEnumTypeDef(final EnumTypeDefinition enumTypeDef) {\r
-        final List<EnumPair> enums = enumTypeDef.getValues();\r
-        if (enums != null) {\r
-            int listIndex = 0;\r
-            for (final EnumPair enumPair : enums) {\r
-                if (enumPair != null) {\r
-                    final String enumPairName = parseToClassName(enumPair.getName());\r
-                    Integer enumPairValue = enumPair.getValue();\r
-\r
-                    if (enumPairValue == null) {\r
-                        enumPairValue = listIndex;\r
-                    }\r
-                    this.addValue(enumPairName, enumPairValue);\r
-                    listIndex++;\r
-                }\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    private static final class EnumPairImpl implements Enumeration.Pair {\r
-\r
-        private final String name;\r
-        private final Integer value;\r
-\r
-        public EnumPairImpl(String name, Integer value) {\r
-            super();\r
-            this.name = name;\r
-            this.value = value;\r
-        }\r
-\r
-        @Override\r
-        public String getName() {\r
-            return name;\r
-        }\r
-\r
-        @Override\r
-        public Integer getValue() {\r
-            return value;\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#hashCode()\r
-         */\r
-        @Override\r
-        public int hashCode() {\r
-            final int prime = 31;\r
-            int result = 1;\r
-            result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-            result = prime * result + ((value == null) ? 0 : value.hashCode());\r
-            return result;\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#equals(java.lang.Object)\r
-         */\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (getClass() != obj.getClass()) {\r
-                return false;\r
-            }\r
-            EnumPairImpl other = (EnumPairImpl) obj;\r
-            if (name == null) {\r
-                if (other.name != null) {\r
-                    return false;\r
-                }\r
-            } else if (!name.equals(other.name)) {\r
-                return false;\r
-            }\r
-            if (value == null) {\r
-                if (other.value != null) {\r
-                    return false;\r
-                }\r
-            } else if (!value.equals(other.value)) {\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#toString()\r
-         */\r
-        @Override\r
-        public String toString() {\r
-            StringBuilder builder = new StringBuilder();\r
-            builder.append("EnumPair [name=");\r
-            builder.append(name);\r
-            builder.append(", value=");\r
-            builder.append(value);\r
-            builder.append("]");\r
-            return builder.toString();\r
-        }\r
-    }\r
-\r
-    private static final class EnumerationImpl implements Enumeration {\r
-\r
-        private final Type definingType;\r
-        private final String packageName;\r
-        private final String name;\r
-        private final List<Pair> values;\r
-        private List<AnnotationType> annotations = new ArrayList<>();\r
-\r
-        public EnumerationImpl(final Type definingType, final List<AnnotationTypeBuilder> annotationBuilders,\r
-                final String packageName, final String name, final List<Pair> values) {\r
-            super();\r
-            this.definingType = definingType;\r
-            for (final AnnotationTypeBuilder builder : annotationBuilders) {\r
-                annotations.add(builder.toInstance());\r
-            }\r
-            this.annotations = Collections.unmodifiableList(annotations);\r
-            this.packageName = packageName;\r
-            this.name = name;\r
-            this.values = Collections.unmodifiableList(values);\r
-        }\r
-\r
-        @Override\r
-        public Type getParentType() {\r
-            return definingType;\r
-        }\r
-\r
-        @Override\r
-        public String getPackageName() {\r
-            return packageName;\r
-        }\r
-\r
-        @Override\r
-        public String getName() {\r
-            return name;\r
-        }\r
-\r
-        @Override\r
-        public String getFullyQualifiedName() {\r
-            return packageName + "." + name;\r
-        }\r
-\r
-        @Override\r
-        public List<Pair> getValues() {\r
-            return values;\r
-        }\r
-\r
-        @Override\r
-        public List<AnnotationType> getAnnotations() {\r
-            return annotations;\r
-        }\r
-\r
-        @Override\r
-        public String toFormattedString() {\r
-            StringBuilder builder = new StringBuilder();\r
-            builder.append("public enum");\r
-            builder.append(" ");\r
-            builder.append(name);\r
-            builder.append(" {");\r
-            builder.append("\n");\r
-\r
-            int i = 0;\r
-            for (final Enumeration.Pair valPair : values) {\r
-                builder.append("\t");\r
-                builder.append(" ");\r
-                builder.append(valPair.getName());\r
-                builder.append(" (");\r
-                builder.append(valPair.getValue());\r
-\r
-                if (i == (values.size() - 1)) {\r
-                    builder.append(" );");\r
-                } else {\r
-                    builder.append(" ),");\r
-                }\r
-                ++i;\r
-            }\r
-            builder.append("\n}");\r
-            return builder.toString();\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#hashCode()\r
-         */\r
-        @Override\r
-        public int hashCode() {\r
-            final int prime = 31;\r
-            int result = 1;\r
-            result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-            result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());\r
-            result = prime * result + ((values == null) ? 0 : values.hashCode());\r
-\r
-            return result;\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#equals(java.lang.Object)\r
-         */\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (getClass() != obj.getClass()) {\r
-                return false;\r
-            }\r
-            EnumerationImpl other = (EnumerationImpl) obj;\r
-            if (name == null) {\r
-                if (other.name != null) {\r
-                    return false;\r
-                }\r
-            } else if (!name.equals(other.name)) {\r
-                return false;\r
-            }\r
-            if (packageName == null) {\r
-                if (other.packageName != null) {\r
-                    return false;\r
-                }\r
-            } else if (!packageName.equals(other.packageName)) {\r
-                return false;\r
-            }\r
-            if (values == null) {\r
-                if (other.values != null) {\r
-                    return false;\r
-                }\r
-            } else if (!values.equals(other.values)) {\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#toString()\r
-         */\r
-        @Override\r
-        public String toString() {\r
-            StringBuilder builder = new StringBuilder();\r
-            builder.append("Enumeration [packageName=");\r
-            builder.append(packageName);\r
-            if (definingType != null) {\r
-                builder.append(", definingType=");\r
-                builder.append(definingType.getPackageName());\r
-                builder.append(".");\r
-                builder.append(definingType.getName());\r
-            } else {\r
-                builder.append(", definingType= null");\r
-            }\r
-            builder.append(", name=");\r
-            builder.append(name);\r
-            builder.append(", values=");\r
-            builder.append(values);\r
-            builder.append("]");\r
-            return builder.toString();\r
-        }\r
-\r
-        @Override\r
-        public String getComment() {\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public boolean isAbstract() {\r
-            return false;\r
-        }\r
-\r
-        @Override\r
-        public List<Type> getImplements() {\r
-            return Collections.emptyList();\r
-        }\r
-\r
-        @Override\r
-        public List<GeneratedType> getEnclosedTypes() {\r
-            return Collections.emptyList();\r
-        }\r
-\r
-        @Override\r
-        public List<Enumeration> getEnumerations() {\r
-            return Collections.emptyList();\r
-        }\r
-\r
-        @Override\r
-        public List<Constant> getConstantDefinitions() {\r
-            return Collections.emptyList();\r
-        }\r
-\r
-        @Override\r
-        public List<MethodSignature> getMethodDefinitions() {\r
-            // TODO Auto-generated method stub\r
-            return Collections.emptyList();\r
-        }\r
-        \r
-        @Override\r
-        public List<GeneratedProperty> getProperties() {\r
-            return Collections.emptyList();\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.yangtools.binding.generator.util.generated.type.builder;
+
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToClassName;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;
+import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
+import org.opendaylight.yangtools.sal.binding.model.api.Constant;
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.EnumBuilder;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+
+public final class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuilder {
+    private final String packageName;
+    private final String name;
+    private final List<Enumeration.Pair> values;
+    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<>();
+
+    public EnumerationBuilderImpl(final String packageName, final String name) {
+        super(packageName, name);
+        this.packageName = packageName;
+        this.name = name;
+        values = new ArrayList<>();
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+        if (packageName != null && name != null) {
+            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+            if (annotationBuilders.add(builder)) {
+                return builder;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void addValue(final String name, final Integer value) {
+        values.add(new EnumPairImpl(name, value));
+    }
+
+    @Override
+    public Enumeration toInstance(final Type definingType) {
+        return new EnumerationImpl(definingType, annotationBuilders, packageName, name, values);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        EnumerationBuilderImpl other = (EnumerationBuilderImpl) obj;
+        if (name == null) {
+            if (other.name != null) {
+                return false;
+            }
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+        if (packageName == null) {
+            if (other.packageName != null) {
+                return false;
+            }
+        } else if (!packageName.equals(other.packageName)) {
+            return false;
+        }
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("EnumerationBuilderImpl [packageName=");
+        builder.append(packageName);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append(", values=");
+        builder.append(values);
+        builder.append("]");
+        return builder.toString();
+    }
+
+    @Override
+    public void updateEnumPairsFromEnumTypeDef(final EnumTypeDefinition enumTypeDef) {
+        final List<EnumPair> enums = enumTypeDef.getValues();
+        if (enums != null) {
+            int listIndex = 0;
+            for (final EnumPair enumPair : enums) {
+                if (enumPair != null) {
+                    final String enumPairName = parseToClassName(enumPair.getName());
+                    Integer enumPairValue = enumPair.getValue();
+
+                    if (enumPairValue == null) {
+                        enumPairValue = listIndex;
+                    }
+                    this.addValue(enumPairName, enumPairValue);
+                    listIndex++;
+                }
+            }
+        }
+
+    }
+
+    private static final class EnumPairImpl implements Enumeration.Pair {
+
+        private final String name;
+        private final Integer value;
+
+        public EnumPairImpl(String name, Integer value) {
+            super();
+            this.name = name;
+            this.value = value;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public Integer getValue() {
+            return value;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.lang.Object#hashCode()
+         */
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((name == null) ? 0 : name.hashCode());
+            result = prime * result + ((value == null) ? 0 : value.hashCode());
+            return result;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            EnumPairImpl other = (EnumPairImpl) obj;
+            if (name == null) {
+                if (other.name != null) {
+                    return false;
+                }
+            } else if (!name.equals(other.name)) {
+                return false;
+            }
+            if (value == null) {
+                if (other.value != null) {
+                    return false;
+                }
+            } else if (!value.equals(other.value)) {
+                return false;
+            }
+            return true;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.lang.Object#toString()
+         */
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("EnumPair [name=");
+            builder.append(name);
+            builder.append(", value=");
+            builder.append(value);
+            builder.append("]");
+            return builder.toString();
+        }
+    }
+
+    private static final class EnumerationImpl implements Enumeration {
+
+        private final Type definingType;
+        private final String packageName;
+        private final String name;
+        private final List<Pair> values;
+        private List<AnnotationType> annotations = new ArrayList<>();
+
+        public EnumerationImpl(final Type definingType, final List<AnnotationTypeBuilder> annotationBuilders,
+                final String packageName, final String name, final List<Pair> values) {
+            super();
+            this.definingType = definingType;
+            for (final AnnotationTypeBuilder builder : annotationBuilders) {
+                annotations.add(builder.toInstance());
+            }
+            this.annotations = Collections.unmodifiableList(annotations);
+            this.packageName = packageName;
+            this.name = name;
+            this.values = Collections.unmodifiableList(values);
+        }
+
+        @Override
+        public Type getParentType() {
+            return definingType;
+        }
+
+        @Override
+        public String getPackageName() {
+            return packageName;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getFullyQualifiedName() {
+            return packageName + "." + name;
+        }
+
+        @Override
+        public List<Pair> getValues() {
+            return values;
+        }
+
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+
+        @Override
+        public String toFormattedString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("public enum");
+            builder.append(" ");
+            builder.append(name);
+            builder.append(" {");
+            builder.append("\n");
+
+            int i = 0;
+            for (final Enumeration.Pair valPair : values) {
+                builder.append("\t");
+                builder.append(" ");
+                builder.append(valPair.getName());
+                builder.append(" (");
+                builder.append(valPair.getValue());
+
+                if (i == (values.size() - 1)) {
+                    builder.append(" );");
+                } else {
+                    builder.append(" ),");
+                }
+                ++i;
+            }
+            builder.append("\n}");
+            return builder.toString();
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.lang.Object#hashCode()
+         */
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((name == null) ? 0 : name.hashCode());
+            result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
+            result = prime * result + ((values == null) ? 0 : values.hashCode());
+
+            return result;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            EnumerationImpl other = (EnumerationImpl) obj;
+            if (name == null) {
+                if (other.name != null) {
+                    return false;
+                }
+            } else if (!name.equals(other.name)) {
+                return false;
+            }
+            if (packageName == null) {
+                if (other.packageName != null) {
+                    return false;
+                }
+            } else if (!packageName.equals(other.packageName)) {
+                return false;
+            }
+            if (values == null) {
+                if (other.values != null) {
+                    return false;
+                }
+            } else if (!values.equals(other.values)) {
+                return false;
+            }
+            return true;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.lang.Object#toString()
+         */
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("Enumeration [packageName=");
+            builder.append(packageName);
+            if (definingType != null) {
+                builder.append(", definingType=");
+                builder.append(definingType.getPackageName());
+                builder.append(".");
+                builder.append(definingType.getName());
+            } else {
+                builder.append(", definingType= null");
+            }
+            builder.append(", name=");
+            builder.append(name);
+            builder.append(", values=");
+            builder.append(values);
+            builder.append("]");
+            return builder.toString();
+        }
+
+        @Override
+        public String getComment() {
+            return null;
+        }
+
+        @Override
+        public boolean isAbstract() {
+            return false;
+        }
+
+        @Override
+        public List<Type> getImplements() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<GeneratedType> getEnclosedTypes() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<Enumeration> getEnumerations() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<Constant> getConstantDefinitions() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<MethodSignature> getMethodDefinitions() {
+            // TODO Auto-generated method stub
+            return Collections.emptyList();
+        }
+        
+        @Override
+        public List<GeneratedProperty> getProperties() {
+            return Collections.emptyList();
+        }
+    }
+}
index 202b16b2f207812dcb6aed5685e987a515b8018f..a2ecc1018d1d765fba3a1c5a5ae67baf47bf7d2a 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;\r
-\r
-public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTOBuilder> implements\r
-        GeneratedTOBuilder {\r
-\r
-    private GeneratedTransferObject extendsType;\r
-    private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<>();\r
-    private final List<GeneratedPropertyBuilder> hashProperties = new ArrayList<>();\r
-    private final List<GeneratedPropertyBuilder> toStringProperties = new ArrayList<>();\r
-    private boolean isTypedef = false;\r
-    private boolean isUnionType = false;\r
-    private boolean isUnionTypeBuilder = false;\r
-    private Restrictions restrictions;\r
-    private GeneratedPropertyBuilder SUID;\r
-\r
-    public GeneratedTOBuilderImpl(String packageName, String name) {\r
-        super(packageName, name);\r
-        setAbstract(false);\r
-    }\r
-\r
-    @Override\r
-    public GeneratedTOBuilder setExtendsType(final GeneratedTransferObject genTransObj) {\r
-        if (genTransObj == null) {\r
-            throw new IllegalArgumentException("Generated Transfer Object cannot be null!");\r
-        }\r
-        extendsType = genTransObj;\r
-        return this;\r
-    }\r
-\r
-    /**\r
-     * Add new Method Signature definition for Generated Type Builder and\r
-     * returns Method Signature Builder for specifying all Method parameters. <br>\r
-     * Name of Method cannot be <code>null</code>, if it is <code>null</code>\r
-     * the method SHOULD throw {@link IllegalArgumentException} <br>\r
-     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as\r
-     * {@link MethodSignatureBuilder#setAbstract(boolean)},\r
-     * {TypeMemberBuilder#setFinal(boolean)} and\r
-     * {TypeMemberBuilder#setAccessModifier(boolean)}\r
-     *\r
-     * @param name\r
-     *            Name of Method\r
-     * @return <code>new</code> instance of Method Signature Builder.\r
-     */\r
-    @Override\r
-    public MethodSignatureBuilder addMethod(String name) {\r
-        final MethodSignatureBuilder builder = super.addMethod(name);\r
-        builder.setAbstract(false);\r
-        return builder;\r
-    }\r
-\r
-    @Override\r
-    public GeneratedTOBuilder addEqualsIdentity(GeneratedPropertyBuilder property) {\r
-        equalsProperties.add(property);\r
-        return this;\r
-    }\r
-\r
-    @Override\r
-    public GeneratedTOBuilder addHashIdentity(GeneratedPropertyBuilder property) {\r
-        hashProperties.add(property);\r
-        return this;\r
-    }\r
-\r
-    @Override\r
-    public GeneratedTOBuilder addToStringProperty(GeneratedPropertyBuilder property) {\r
-        toStringProperties.add(property);\r
-        return this;\r
-    }\r
-\r
-    @Override\r
-    protected GeneratedTOBuilder thisInstance() {\r
-        return this;\r
-    }\r
-\r
-    @Override\r
-    public void setRestrictions(Restrictions restrictions) {\r
-        this.restrictions = restrictions;\r
-    }\r
-\r
-    @Override\r
-    public void setSUID(GeneratedPropertyBuilder suid) {\r
-        this.SUID = suid;\r
-    }\r
-\r
-    @Override\r
-    public GeneratedTransferObject toInstance() {\r
-        return new GeneratedTransferObjectImpl(this);\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append("GeneratedTransferObject [packageName=");\r
-        builder.append(getPackageName());\r
-        builder.append(", name=");\r
-        builder.append(getName());\r
-        builder.append(", comment=");\r
-        builder.append(getComment());\r
-        builder.append(", constants=");\r
-        builder.append(getConstants());\r
-        builder.append(", enumerations=");\r
-        builder.append(getEnumerations());\r
-        builder.append(", equalsProperties=");\r
-        builder.append(equalsProperties);\r
-        builder.append(", hashCodeProperties=");\r
-        builder.append(hashProperties);\r
-        builder.append(", stringProperties=");\r
-        builder.append(toStringProperties);\r
-        builder.append(", annotations=");\r
-        builder.append(getAnnotations());\r
-        builder.append(", methods=");\r
-        builder.append(getMethodDefinitions());\r
-        builder.append("]");\r
-        return builder.toString();\r
-    }\r
-\r
-    @Override\r
-    public void setTypedef(boolean isTypedef) {\r
-        this.isTypedef = isTypedef;\r
-    }\r
-\r
-    @Override\r
-    public void setIsUnion(boolean isUnion) {\r
-        this.isUnionType = isUnion;\r
-    }\r
-\r
-    @Override\r
-    public void setIsUnionBuilder(boolean isUnionTypeBuilder) {\r
-        this.isUnionTypeBuilder = isUnionTypeBuilder;\r
-    }\r
-\r
-    private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements\r
-            GeneratedTransferObject {\r
-\r
-        private final List<GeneratedProperty> equalsProperties;\r
-        private final List<GeneratedProperty> hashCodeProperties;\r
-        private final List<GeneratedProperty> stringProperties;\r
-        private final GeneratedTransferObject extendsType;\r
-        private final boolean isTypedef;\r
-        private final boolean isUnionType;\r
-        private final boolean isUnionTypeBuilder;\r
-        private final Restrictions restrictions;\r
-        private final GeneratedProperty SUID;\r
-\r
-        public GeneratedTransferObjectImpl(GeneratedTOBuilderImpl builder) {\r
-            super(builder);\r
-            this.extendsType = builder.extendsType;\r
-            this.equalsProperties = toUnmodifiableProperties(builder.equalsProperties);\r
-            this.hashCodeProperties = toUnmodifiableProperties(builder.hashProperties);\r
-            this.stringProperties = toUnmodifiableProperties(builder.toStringProperties);\r
-            this.isTypedef = builder.isTypedef;\r
-            this.isUnionType = builder.isUnionType;\r
-            this.isUnionTypeBuilder = builder.isUnionTypeBuilder;\r
-            this.restrictions = builder.restrictions;\r
-            if (builder.SUID == null) {\r
-                this.SUID = null;\r
-            } else {\r
-                this.SUID = builder.SUID.toInstance(GeneratedTransferObjectImpl.this);\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public boolean isTypedef() {\r
-            return isTypedef;\r
-        }\r
-\r
-        @Override\r
-        public boolean isUnionType() {\r
-            return isUnionType;\r
-        }\r
-\r
-        @Override\r
-        public boolean isUnionTypeBuilder() {\r
-            return isUnionTypeBuilder;\r
-        }\r
-\r
-        @Override\r
-        public GeneratedTransferObject getSuperType() {\r
-            return extendsType;\r
-        }\r
-\r
-        @Override\r
-        public List<GeneratedProperty> getEqualsIdentifiers() {\r
-            return equalsProperties;\r
-        }\r
-\r
-        @Override\r
-        public List<GeneratedProperty> getHashCodeIdentifiers() {\r
-            return hashCodeProperties;\r
-        }\r
-\r
-        @Override\r
-        public List<GeneratedProperty> getToStringIdentifiers() {\r
-            return stringProperties;\r
-        }\r
-\r
-        @Override\r
-        public Restrictions getRestrictions() {\r
-            return restrictions;\r
-        }\r
-\r
-        @Override\r
-        public GeneratedProperty getSUID() {\r
-            return SUID;\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            if(isTypedef) {\r
-                return serializeTypedef(this);\r
-            }\r
-            StringBuilder builder = new StringBuilder();\r
-            builder.append("GeneratedTransferObject [packageName=");\r
-            builder.append(getPackageName());\r
-            builder.append(", name=");\r
-            builder.append(getName());\r
-            builder.append(", comment=");\r
-            builder.append(", annotations=");\r
-            builder.append(getAnnotations());\r
-            builder.append(getComment());\r
-            builder.append(", extends=");\r
-            builder.append(getSuperType());\r
-            builder.append(", implements=");\r
-            builder.append(getImplements());\r
-            builder.append(", enclosedTypes=");\r
-            builder.append(getEnclosedTypes());\r
-            builder.append(", constants=");\r
-            builder.append(getConstantDefinitions());\r
-            builder.append(", enumerations=");\r
-            builder.append(getEnumerations());\r
-            builder.append(", properties=");\r
-            builder.append(getProperties());\r
-            builder.append(", equalsProperties=");\r
-            builder.append(equalsProperties);\r
-            builder.append(", hashCodeProperties=");\r
-            builder.append(hashCodeProperties);\r
-            builder.append(", stringProperties=");\r
-            builder.append(stringProperties);\r
-            builder.append(", methods=");\r
-            builder.append(getMethodDefinitions());\r
-            builder.append("]");\r
-            return builder.toString();\r
-        }\r
-\r
-        public String serializeTypedef(Type type) {\r
-            if (type instanceof ParameterizedType) {\r
-                ParameterizedType parameterizedType = (ParameterizedType) type;\r
-                StringBuffer sb = new StringBuffer();\r
-                sb.append(parameterizedType.getRawType().getFullyQualifiedName());\r
-                sb.append("<");\r
-                boolean first = true;\r
-                for (Type parameter : parameterizedType.getActualTypeArguments()) {\r
-                    if (first) {\r
-                        first = false;\r
-                    } else {\r
-                        sb.append(",");\r
-                    }\r
-                    sb.append(serializeTypedef(parameter));\r
-                }\r
-                sb.append(">");\r
-                return sb.toString();\r
-            } else {\r
-                return type.getFullyQualifiedName();\r
-            }\r
-        }\r
-\r
-    }\r
-}\r
+/*
+ * 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.yangtools.binding.generator.util.generated.type.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
+import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
+
+public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTOBuilder> implements
+        GeneratedTOBuilder {
+
+    private GeneratedTransferObject extendsType;
+    private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<>();
+    private final List<GeneratedPropertyBuilder> hashProperties = new ArrayList<>();
+    private final List<GeneratedPropertyBuilder> toStringProperties = new ArrayList<>();
+    private boolean isTypedef = false;
+    private boolean isUnionType = false;
+    private boolean isUnionTypeBuilder = false;
+    private Restrictions restrictions;
+    private GeneratedPropertyBuilder SUID;
+
+    public GeneratedTOBuilderImpl(String packageName, String name) {
+        super(packageName, name);
+        setAbstract(false);
+    }
+
+    @Override
+    public GeneratedTOBuilder setExtendsType(final GeneratedTransferObject genTransObj) {
+        if (genTransObj == null) {
+            throw new IllegalArgumentException("Generated Transfer Object cannot be null!");
+        }
+        extendsType = genTransObj;
+        return this;
+    }
+
+    /**
+     * Add new Method Signature definition for Generated Type Builder and
+     * returns Method Signature Builder for specifying all Method parameters. <br>
+     * Name of Method cannot be <code>null</code>, if it is <code>null</code>
+     * the method SHOULD throw {@link IllegalArgumentException} <br>
+     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
+     * {@link MethodSignatureBuilder#setAbstract(boolean)},
+     * {TypeMemberBuilder#setFinal(boolean)} and
+     * {TypeMemberBuilder#setAccessModifier(boolean)}
+     *
+     * @param name
+     *            Name of Method
+     * @return <code>new</code> instance of Method Signature Builder.
+     */
+    @Override
+    public MethodSignatureBuilder addMethod(String name) {
+        final MethodSignatureBuilder builder = super.addMethod(name);
+        builder.setAbstract(false);
+        return builder;
+    }
+
+    @Override
+    public GeneratedTOBuilder addEqualsIdentity(GeneratedPropertyBuilder property) {
+        equalsProperties.add(property);
+        return this;
+    }
+
+    @Override
+    public GeneratedTOBuilder addHashIdentity(GeneratedPropertyBuilder property) {
+        hashProperties.add(property);
+        return this;
+    }
+
+    @Override
+    public GeneratedTOBuilder addToStringProperty(GeneratedPropertyBuilder property) {
+        toStringProperties.add(property);
+        return this;
+    }
+
+    @Override
+    protected GeneratedTOBuilder thisInstance() {
+        return this;
+    }
+
+    @Override
+    public void setRestrictions(Restrictions restrictions) {
+        this.restrictions = restrictions;
+    }
+
+    @Override
+    public void setSUID(GeneratedPropertyBuilder suid) {
+        this.SUID = suid;
+    }
+
+    @Override
+    public GeneratedTransferObject toInstance() {
+        return new GeneratedTransferObjectImpl(this);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedTransferObject [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append(", constants=");
+        builder.append(getConstants());
+        builder.append(", enumerations=");
+        builder.append(getEnumerations());
+        builder.append(", equalsProperties=");
+        builder.append(equalsProperties);
+        builder.append(", hashCodeProperties=");
+        builder.append(hashProperties);
+        builder.append(", stringProperties=");
+        builder.append(toStringProperties);
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(", methods=");
+        builder.append(getMethodDefinitions());
+        builder.append("]");
+        return builder.toString();
+    }
+
+    @Override
+    public void setTypedef(boolean isTypedef) {
+        this.isTypedef = isTypedef;
+    }
+
+    @Override
+    public void setIsUnion(boolean isUnion) {
+        this.isUnionType = isUnion;
+    }
+
+    @Override
+    public void setIsUnionBuilder(boolean isUnionTypeBuilder) {
+        this.isUnionTypeBuilder = isUnionTypeBuilder;
+    }
+
+    private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements
+            GeneratedTransferObject {
+
+        private final List<GeneratedProperty> equalsProperties;
+        private final List<GeneratedProperty> hashCodeProperties;
+        private final List<GeneratedProperty> stringProperties;
+        private final GeneratedTransferObject extendsType;
+        private final boolean isTypedef;
+        private final boolean isUnionType;
+        private final boolean isUnionTypeBuilder;
+        private final Restrictions restrictions;
+        private final GeneratedProperty SUID;
+
+        public GeneratedTransferObjectImpl(GeneratedTOBuilderImpl builder) {
+            super(builder);
+            this.extendsType = builder.extendsType;
+            this.equalsProperties = toUnmodifiableProperties(builder.equalsProperties);
+            this.hashCodeProperties = toUnmodifiableProperties(builder.hashProperties);
+            this.stringProperties = toUnmodifiableProperties(builder.toStringProperties);
+            this.isTypedef = builder.isTypedef;
+            this.isUnionType = builder.isUnionType;
+            this.isUnionTypeBuilder = builder.isUnionTypeBuilder;
+            this.restrictions = builder.restrictions;
+            if (builder.SUID == null) {
+                this.SUID = null;
+            } else {
+                this.SUID = builder.SUID.toInstance(GeneratedTransferObjectImpl.this);
+            }
+        }
+
+        @Override
+        public boolean isTypedef() {
+            return isTypedef;
+        }
+
+        @Override
+        public boolean isUnionType() {
+            return isUnionType;
+        }
+
+        @Override
+        public boolean isUnionTypeBuilder() {
+            return isUnionTypeBuilder;
+        }
+
+        @Override
+        public GeneratedTransferObject getSuperType() {
+            return extendsType;
+        }
+
+        @Override
+        public List<GeneratedProperty> getEqualsIdentifiers() {
+            return equalsProperties;
+        }
+
+        @Override
+        public List<GeneratedProperty> getHashCodeIdentifiers() {
+            return hashCodeProperties;
+        }
+
+        @Override
+        public List<GeneratedProperty> getToStringIdentifiers() {
+            return stringProperties;
+        }
+
+        @Override
+        public Restrictions getRestrictions() {
+            return restrictions;
+        }
+
+        @Override
+        public GeneratedProperty getSUID() {
+            return SUID;
+        }
+
+        @Override
+        public String toString() {
+            if(isTypedef) {
+                return serializeTypedef(this);
+            }
+            StringBuilder builder = new StringBuilder();
+            builder.append("GeneratedTransferObject [packageName=");
+            builder.append(getPackageName());
+            builder.append(", name=");
+            builder.append(getName());
+            builder.append(", comment=");
+            builder.append(", annotations=");
+            builder.append(getAnnotations());
+            builder.append(getComment());
+            builder.append(", extends=");
+            builder.append(getSuperType());
+            builder.append(", implements=");
+            builder.append(getImplements());
+            builder.append(", enclosedTypes=");
+            builder.append(getEnclosedTypes());
+            builder.append(", constants=");
+            builder.append(getConstantDefinitions());
+            builder.append(", enumerations=");
+            builder.append(getEnumerations());
+            builder.append(", properties=");
+            builder.append(getProperties());
+            builder.append(", equalsProperties=");
+            builder.append(equalsProperties);
+            builder.append(", hashCodeProperties=");
+            builder.append(hashCodeProperties);
+            builder.append(", stringProperties=");
+            builder.append(stringProperties);
+            builder.append(", methods=");
+            builder.append(getMethodDefinitions());
+            builder.append("]");
+            return builder.toString();
+        }
+
+        public String serializeTypedef(Type type) {
+            if (type instanceof ParameterizedType) {
+                ParameterizedType parameterizedType = (ParameterizedType) type;
+                StringBuffer sb = new StringBuffer();
+                sb.append(parameterizedType.getRawType().getFullyQualifiedName());
+                sb.append("<");
+                boolean first = true;
+                for (Type parameter : parameterizedType.getActualTypeArguments()) {
+                    if (first) {
+                        first = false;
+                    } else {
+                        sb.append(",");
+                    }
+                    sb.append(serializeTypedef(parameter));
+                }
+                sb.append(">");
+                return sb.toString();
+            } else {
+                return type.getFullyQualifiedName();
+            }
+        }
+
+    }
+}
index 22d11e53841c5d1a11c0f4b9f4eb412bf690967f..c4b067e329226ff08beba0d0d99cb5073d4b5ecd 100644 (file)
@@ -1,63 +1,63 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;\r
-\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;\r
-\r
-public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTypeBuilder> implements GeneratedTypeBuilder {\r
-\r
-    public GeneratedTypeBuilderImpl(String packageName, String name) {\r
-        super(packageName, name);\r
-        setAbstract(true);\r
-    }\r
-\r
-    @Override\r
-    public GeneratedType toInstance() {\r
-        return new GeneratedTypeImpl(this);\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append("GeneratedTransferObject [packageName=");\r
-        builder.append(getPackageName());\r
-        builder.append(", name=");\r
-        builder.append(getName());\r
-        builder.append(", comment=");\r
-        builder.append(", annotations=");\r
-        builder.append(getAnnotations());\r
-        builder.append(getComment());\r
-        builder.append(", implements=");\r
-        builder.append(getImplementsTypes());\r
-        builder.append(", enclosedTypes=");\r
-        builder.append(getEnclosedTypes());\r
-        builder.append(", constants=");\r
-        builder.append(getConstants());\r
-        builder.append(", enumerations=");\r
-        builder.append(getEnumerations());\r
-        builder.append(", properties=");\r
-        builder.append(", methods=");\r
-        builder.append(getMethodDefinitions());\r
-        builder.append("]");\r
-        return builder.toString();\r
-    }\r
-    \r
-    @Override\r
-    protected GeneratedTypeBuilderImpl thisInstance() {\r
-        return this;\r
-    }\r
-\r
-    private static final class GeneratedTypeImpl extends AbstractGeneratedType {\r
-\r
-        public GeneratedTypeImpl(GeneratedTypeBuilderImpl builder) {\r
-            super(builder);\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.yangtools.binding.generator.util.generated.type.builder;
+
+
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
+
+public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTypeBuilder> implements GeneratedTypeBuilder {
+
+    public GeneratedTypeBuilderImpl(String packageName, String name) {
+        super(packageName, name);
+        setAbstract(true);
+    }
+
+    @Override
+    public GeneratedType toInstance() {
+        return new GeneratedTypeImpl(this);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedTransferObject [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(getComment());
+        builder.append(", implements=");
+        builder.append(getImplementsTypes());
+        builder.append(", enclosedTypes=");
+        builder.append(getEnclosedTypes());
+        builder.append(", constants=");
+        builder.append(getConstants());
+        builder.append(", enumerations=");
+        builder.append(getEnumerations());
+        builder.append(", properties=");
+        builder.append(", methods=");
+        builder.append(getMethodDefinitions());
+        builder.append("]");
+        return builder.toString();
+    }
+    
+    @Override
+    protected GeneratedTypeBuilderImpl thisInstance() {
+        return this;
+    }
+
+    private static final class GeneratedTypeImpl extends AbstractGeneratedType {
+
+        public GeneratedTypeImpl(GeneratedTypeBuilderImpl builder) {
+            super(builder);
+        }
+    }
+}
index 81a6bc2f4cadc14765d8d588ee05c20f67a7e2f7..2621e2eea42feb127c8cc0acac4e74929ad9dc1f 100644 (file)
@@ -1,8 +1,8 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+/*
+ * 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.yangtools.binding.generator.util;
\ No newline at end of file
index 2f9ba7f1068d48683705facc87f433f3490f3978..a9ef53dce08048e93ae3657dace27e378ef448af 100644 (file)
@@ -5,16 +5,16 @@
  * 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.yangtools.sal.java.api.generator\r
-\r
-import java.util.List\r
-import org.opendaylight.yangtools.binding.generator.util.TypeConstants\r
-import org.opendaylight.yangtools.sal.binding.model.api.Constant\r
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType\r
-import java.util.ArrayList\r
+package org.opendaylight.yangtools.sal.java.api.generator
+
+import java.util.List
+import org.opendaylight.yangtools.binding.generator.util.TypeConstants
+import org.opendaylight.yangtools.sal.binding.model.api.Constant
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
+import java.util.ArrayList
 import java.util.Collections\rimport java.util.Arrays
 import org.opendaylight.yangtools.sal.binding.model.api.Restrictions
 import com.google.common.collect.Range
@@ -23,438 +23,438 @@ import com.google.common.io.BaseEncoding
 import java.beans.ConstructorProperties
 import com.google.common.collect.Lists
 
-/**\r
- * Template for generating JAVA class. \r
- */\r
-class ClassTemplate extends BaseTemplate {\r
-\r
-    protected val List<GeneratedProperty> properties\r
-    protected val List<GeneratedProperty> finalProperties\r
-    protected val List<GeneratedProperty> parentProperties\r
-    protected val Iterable<GeneratedProperty> allProperties;\r
-    protected val Restrictions restrictions\r
-    \r
-    /**\r
-     * List of enumeration which are generated as JAVA enum type.\r
-     */\r
-    protected val List<Enumeration> enums\r
-    \r
-    /**\r
-     * List of constant instances which are generated as JAVA public static final attributes.\r
-     */\r
-    protected val List<Constant> consts\r
-    \r
-    /**\r
-     * List of generated types which are enclosed inside <code>genType</code>\r
-     */\r
-    protected val List<GeneratedType> enclosedGeneratedTypes;\r
-    \r
-    \r
-    protected val GeneratedTransferObject genTO;\r
-\r
-    /**\r
-     * Creates instance of this class with concrete <code>genType</code>.\r
-     * \r
-     * @param genType generated transfer object which will be transformed to JAVA class source code\r
-     */\r
-    new(GeneratedTransferObject genType) {\r
-        super(genType)\r
-        this.genTO = genType\r
-        this.properties = genType.properties\r
-        this.finalProperties = GeneratorUtil.resolveReadOnlyPropertiesFromTO(genTO.properties)\r
-        this.parentProperties = GeneratorUtil.getPropertiesOfAllParents(genTO)\r
-        this.restrictions = genType.restrictions\r
-\r
-        var List<GeneratedProperty> sorted = new ArrayList<GeneratedProperty>();\r
-        sorted.addAll(properties);\r
-        sorted.addAll(parentProperties);\r
-        Collections.sort(sorted, new PropertyComparator());\r
-\r
-        this.allProperties = sorted\r
-        this.enums = genType.enumerations\r
-        this.consts = genType.constantDefinitions\r
-        this.enclosedGeneratedTypes = genType.enclosedTypes\r
-    }\r
-\r
-\r
-    /**\r
-     * Generates JAVA class source code (class body only).\r
-     * \r
-     * @return string with JAVA class body source code\r
-     */\r
-    def CharSequence generateAsInnerClass() {\r
-        return generateBody(true)\r
-    }\r
-\r
-\r
-    override protected body() {\r
-        generateBody(false);\r
-    }\r
-\r
-    /**\r
-     * Template method which generates class body.\r
-     * \r
-     * @param isInnerClass boolean value which specify if generated class is|isn't inner\r
-     * @return string with class source code in JAVA format\r
-     */\r
-    def protected generateBody(boolean isInnerClass) '''\r
-        «type.comment.asJavadoc»\r
-        «generateClassDeclaration(isInnerClass)» {\r
-            «suidDeclaration»\r
-            «innerClassesDeclarations»\r
-            «enumDeclarations»\r
-            «constantsDeclarations»\r
-            «generateFields»\r
-\r
-            «constructors»\r
-            \r
-            «defaultInstance»\r
-\r
-            «FOR field : properties SEPARATOR "\n"»\r
-                «field.getterMethod»\r
-                «IF !field.readOnly»\r
-                    «field.setterMethod»\r
-                «ENDIF»\r
-            «ENDFOR»\r
-\r
-            «generateHashCode»\r
-\r
-            «generateEquals»\r
-\r
-            «generateToString(genTO.toStringIdentifiers)»\r
-\r
-            «generateGetLength»\r
-\r
-            «generateGetRange»\r
-\r
-        }\r
-    '''\r
-\r
-\r
-    /**\r
-     * Template method which generates inner classes inside this interface.\r
-     * \r
-     * @return string with the source code for inner classes in JAVA format\r
-     */\r
-    def protected innerClassesDeclarations() '''\r
-        «IF !enclosedGeneratedTypes.empty»\r
-            «FOR innerClass : enclosedGeneratedTypes SEPARATOR "\n"»\r
-                «IF (innerClass instanceof GeneratedTransferObject)»\r
-                    «val classTemplate = new ClassTemplate(innerClass as GeneratedTransferObject)»\r
-                    «classTemplate.generateAsInnerClass»\r
-                    \r
-                «ENDIF»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-    \r
-    \r
-    def protected constructors() '''\r
-        «IF genTO.unionType»\r
-            «genUnionConstructor»\r
-        «ELSE»\r
-            «allValuesConstructor»\r
-        «ENDIF»\r
-        «IF !allProperties.empty»\r
-            «copyConstructor»\r
-        «ENDIF»\r
-        «IF properties.empty && !parentProperties.empty »\r
-            «parentConstructor»\r
-        «ENDIF»\r
-    '''\r
-    \r
-    def protected allValuesConstructor() '''\r
-    «IF genTO.typedef && !allProperties.empty && allProperties.size == 1 && allProperties.get(0).name.equals("value")»\r
-        @«ConstructorProperties.importedName»("value")\r
-    «ENDIF»\r
-    public «type.name»(«allProperties.asArgumentsDeclaration») {\r
-        «IF false == parentProperties.empty»\r
-            super(«parentProperties.asArguments»);\r
-        «ENDIF»\r
-        «FOR p : allProperties» \r
-            «generateRestrictions(type, p.fieldName.toString, p.returnType)»\r
-        «ENDFOR»\r
-        «FOR p : properties» \r
-            this.«p.fieldName» = «p.fieldName»;\r
-        «ENDFOR»\r
-    }\r
-    '''\r
-\r
-    def protected genUnionConstructor() '''\r
-    «FOR p : allProperties»\r
-        «val List<GeneratedProperty> other = new ArrayList(properties)»\r
-        «val added = other.remove(p)»\r
-        «genConstructor(p, other)»\r
-    «ENDFOR»\r
-\r
-    '''\r
-\r
-    def protected genConstructor(GeneratedProperty property, GeneratedProperty... other) '''\r
-    public «type.name»(«property.returnType.importedName + " " + property.name») {\r
-        «IF false == parentProperties.empty»\r
-            super(«parentProperties.asArguments»);\r
-        «ENDIF»\r
-            «generateRestrictions(type, property.fieldName.toString, property.returnType)»\r
-            this.«property.fieldName» = «property.name»;\r
-            «FOR p : other»\r
-            this.«p.fieldName» = null;\r
-            «ENDFOR»\r
-    }\r
-    '''\r
-\r
-    def protected copyConstructor() '''\r
-    /**\r
-     * Creates a copy from Source Object.\r
-     *\r
-     * @param source Source object\r
-     */\r
-    public «type.name»(«type.name» source) {\r
-        «IF false == parentProperties.empty»\r
-            super(source);\r
-        «ENDIF»\r
-        «FOR p : properties» \r
-            this.«p.fieldName» = source.«p.fieldName»;\r
-        «ENDFOR»\r
-    }\r
-    '''\r
-\r
-    def protected parentConstructor() '''\r
-    /**\r
-     * Creates a new instance from «genTO.superType.importedName»\r
-     *\r
-     * @param source Source object\r
-     */\r
-    public «type.name»(«genTO.superType.importedName» source) {\r
-            super(source);\r
-    }\r
-    '''\r
-\r
-    def protected defaultInstance() '''\r
-        «IF genTO.typedef && !allProperties.empty && !genTO.unionType»\r
-            «val prop = allProperties.get(0)»\r
-            «IF !("org.opendaylight.yangtools.yang.binding.InstanceIdentifier".equals(prop.returnType.fullyQualifiedName))»\r
-            public static «genTO.name» getDefaultInstance(String defaultValue) {\r
-                «IF "byte[]".equals(prop.returnType.name)»\r
-                    «BaseEncoding.importedName» baseEncoding = «BaseEncoding.importedName».base64(); \r
-                    return new «genTO.name»(baseEncoding.decode(defaultValue));\r
-                «ELSEIF "java.lang.String".equals(prop.returnType.fullyQualifiedName)»\r
-                    return new «genTO.name»(defaultValue);\r
-                «ELSEIF allProperties.size > 1»\r
-                    «bitsArgs»\r
-                «ELSE»\r
-                    return new «genTO.name»(new «prop.returnType.importedName»(defaultValue));\r
-                «ENDIF»\r
-            }\r
-            «ENDIF»\r
-        «ENDIF»\r
-    '''\r
-\r
-    def protected bitsArgs() '''\r
-        «List.importedName»<«String.importedName»> properties = «Lists.importedName».newArrayList(«allProperties.propsAsArgs»);\r
-        if (!properties.contains(defaultValue)) {\r
-            throw new «IllegalArgumentException.importedName»("invalid default parameter");\r
-        }\r
-        int i = 0;\r
-        return new «genTO.name»(\r
-        «FOR prop : allProperties SEPARATOR ","»\r
-            properties.get(i++).equals(defaultValue) ? new «Boolean.importedName»("true") : null\r
-        «ENDFOR»\r
-        );\r
-    '''\r
-\r
-    def protected propsAsArgs(Iterable<GeneratedProperty> properties) '''\r
-        «FOR prop : properties SEPARATOR ","»\r
-            "«prop.name»"\r
-        «ENDFOR»\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates JAVA class declaration.\r
-     * \r
-     * @param isInnerClass boolean value which specify if generated class is|isn't inner\r
-     * @return string with class declaration in JAVA format\r
-     */\r
-    def protected generateClassDeclaration(boolean isInnerClass) '''\r
-        public«\r
-        IF (isInnerClass)»«\r
-            " static final "»«\r
-        ELSEIF (type.abstract)»«\r
-            " abstract "»«\r
-        ELSE»«\r
-            " "»«\r
-        ENDIF»class «type.name»«\r
-        IF (genTO.superType != null)»«\r
-            " extends "»«genTO.superType.importedName»«\r
-        ENDIF»\r
-        «IF (!type.implements.empty)»«\r
-            " implements "»«\r
-            FOR type : type.implements SEPARATOR ", "»«\r
-                type.importedName»«\r
-            ENDFOR»«\r
-        ENDIF\r
-    »'''\r
-    \r
-    /**\r
-     * Template method which generates JAVA enum type.\r
-     * \r
-     * @return string with inner enum source code in JAVA format\r
-     */\r
-    def protected enumDeclarations() '''\r
-        «IF !enums.empty»\r
-            «FOR e : enums SEPARATOR "\n"»\r
-                «val enumTemplate = new EnumTemplate(e)»\r
-                «enumTemplate.generateAsInnerClass»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-    def protected suidDeclaration() '''\r
-        «IF genTO.SUID != null»\r
-            private static final long serialVersionUID = «genTO.SUID.value»L; \r
-        «ENDIF»\r
-    '''\r
-\r
-    /**\r
-     * Template method wich generates JAVA constants.\r
-     * \r
-     * @return string with constants in JAVA format \r
-     */\r
-    def protected constantsDeclarations() '''\r
-        «IF !consts.empty»\r
-            «FOR c : consts»\r
-                «IF c.name == TypeConstants.PATTERN_CONSTANT_NAME»\r
-                    «val cValue = c.value»\r
-                    «IF cValue instanceof List<?>»\r
-                        «val cValues = cValue as List<?>»\r
-                        private static final «List.importedName»<«Pattern.importedName»> «Constants.MEMBER_PATTERN_LIST» = new «ArrayList.importedName»<«Pattern.importedName»>();\r
-                        public static final «List.importedName»<String> «TypeConstants.PATTERN_CONSTANT_NAME» = «Arrays.importedName».asList(«\r
-                        FOR v : cValues SEPARATOR ", "»«\r
-                            IF v instanceof String»"«\r
-                                v as String»"«\r
-                            ENDIF»«\r
-                        ENDFOR»);\r
-\r
-                        «generateStaticInicializationBlock»\r
-                    «ENDIF»\r
-                «ELSE»\r
-                    public static final «c.type.importedName» «c.name» = «c.value»;\r
-                «ENDIF»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates JAVA static initialization block.\r
-     *\r
-     * @return string with static initialization block in JAVA format\r
-     */\r
-    def protected generateStaticInicializationBlock() '''\r
-        static {\r
-            for (String regEx : «TypeConstants.PATTERN_CONSTANT_NAME») {\r
-                «Constants.MEMBER_PATTERN_LIST».add(Pattern.compile(regEx));\r
-            }\r
-        }\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates JAVA class attributes.\r
-     *\r
-     * @return string with the class attributes in JAVA format\r
-     */\r
-    def protected generateFields() '''\r
-        «IF !properties.empty»\r
-            «FOR f : properties»\r
-                «IF f.readOnly»final«ENDIF» private «f.returnType.importedName» «f.fieldName»;\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-\r
-    /**\r
-     * Template method which generates the method <code>hashCode()</code>.\r
-     *\r
-     * @return string with the <code>hashCode()</code> method definition in JAVA format\r
-     */\r
-    def protected generateHashCode() '''\r
-        «IF !genTO.hashCodeIdentifiers.empty»\r
-            @Override\r
-            public int hashCode() {\r
-                final int prime = 31;\r
-                int result = 1;\r
-                «FOR property : genTO.hashCodeIdentifiers»\r
-                    «IF property.returnType.name.contains("[")»\r
-                    result = prime * result + ((«property.fieldName» == null) ? 0 : «Arrays.importedName».hashCode(«property.fieldName»));\r
-                    «ELSE»\r
-                    result = prime * result + ((«property.fieldName» == null) ? 0 : «property.fieldName».hashCode());\r
-                    «ENDIF»\r
-                «ENDFOR»\r
-                return result;\r
-            }\r
-        «ENDIF»\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates the method <code>equals()</code>.\r
-     *\r
-     * @return string with the <code>equals()</code> method definition in JAVA format\r
-     */\r
-    def protected generateEquals() '''\r
-        «IF !genTO.equalsIdentifiers.empty»\r
-            @Override\r
-            public boolean equals(java.lang.Object obj) {\r
-                if (this == obj) {\r
-                    return true;\r
-                }\r
-                if (obj == null) {\r
-                    return false;\r
-                }\r
-                if (getClass() != obj.getClass()) {\r
-                    return false;\r
-                }\r
-                «type.name» other = («type.name») obj;\r
-                «FOR property : genTO.equalsIdentifiers»\r
-                    «val fieldName = property.fieldName»\r
-                    if («fieldName» == null) {\r
-                        if (other.«fieldName» != null) {\r
-                            return false;\r
-                        }\r
-                    «IF property.returnType.name.contains("[")»\r
-                    } else if(!«Arrays.importedName».equals(«fieldName», other.«fieldName»)) {\r
-                    «ELSE»\r
-                    } else if(!«fieldName».equals(other.«fieldName»)) {\r
-                    «ENDIF»\r
-                        return false;\r
-                    }\r
-                «ENDFOR»\r
-                return true;\r
-            }\r
-        «ENDIF»\r
-    '''\r
-\r
-    def private generateGetLength() '''\r
-        «IF restrictions != null && !(restrictions.lengthConstraints.empty)»\r
-            «val clazz = restrictions.lengthConstraints.iterator.next.min.class»\r
-            public static «List.importedName»<«Range.importedName»<«clazz.importedName»>> length() {\r
-                final «List.importedName»<«Range.importedName»<«clazz.importedName»>> result = new «ArrayList.importedName»<>();\r
-                «FOR r : restrictions.lengthConstraints»\r
-                    result.add(«Range.importedName».closed(new «clazz.importedName»("«r.min»"), new «clazz.importedName»("«r.max»")));\r
-                «ENDFOR»\r
-                return result;\r
-            }\r
-        «ENDIF»\r
-    '''\r
-\r
-    def private generateGetRange() '''\r
-        «IF restrictions != null && !(restrictions.rangeConstraints.empty)»\r
-            «val clazz = restrictions.rangeConstraints.iterator.next.min.class»\r
-            public static «List.importedName»<«Range.importedName»<«clazz.importedName»>> range() {\r
-                final «List.importedName»<«Range.importedName»<«clazz.importedName»>> result = new «ArrayList.importedName»<>();\r
-                «FOR r : restrictions.rangeConstraints»\r
-                    result.add(«Range.importedName».closed(new «clazz.importedName»("«r.min»"), new «clazz.importedName»("«r.max»")));\r
-                «ENDFOR»\r
-                return result;\r
-            }\r
-        «ENDIF»\r
+/**
+ * Template for generating JAVA class. 
+ */
+class ClassTemplate extends BaseTemplate {
+
+    protected val List<GeneratedProperty> properties
+    protected val List<GeneratedProperty> finalProperties
+    protected val List<GeneratedProperty> parentProperties
+    protected val Iterable<GeneratedProperty> allProperties;
+    protected val Restrictions restrictions
+    
+    /**
+     * List of enumeration which are generated as JAVA enum type.
+     */
+    protected val List<Enumeration> enums
+    
+    /**
+     * List of constant instances which are generated as JAVA public static final attributes.
+     */
+    protected val List<Constant> consts
+    
+    /**
+     * List of generated types which are enclosed inside <code>genType</code>
+     */
+    protected val List<GeneratedType> enclosedGeneratedTypes;
+    
+    
+    protected val GeneratedTransferObject genTO;
+
+    /**
+     * Creates instance of this class with concrete <code>genType</code>.
+     * 
+     * @param genType generated transfer object which will be transformed to JAVA class source code
+     */
+    new(GeneratedTransferObject genType) {
+        super(genType)
+        this.genTO = genType
+        this.properties = genType.properties
+        this.finalProperties = GeneratorUtil.resolveReadOnlyPropertiesFromTO(genTO.properties)
+        this.parentProperties = GeneratorUtil.getPropertiesOfAllParents(genTO)
+        this.restrictions = genType.restrictions
+
+        var List<GeneratedProperty> sorted = new ArrayList<GeneratedProperty>();
+        sorted.addAll(properties);
+        sorted.addAll(parentProperties);
+        Collections.sort(sorted, new PropertyComparator());
+
+        this.allProperties = sorted
+        this.enums = genType.enumerations
+        this.consts = genType.constantDefinitions
+        this.enclosedGeneratedTypes = genType.enclosedTypes
+    }
+
+
+    /**
+     * Generates JAVA class source code (class body only).
+     * 
+     * @return string with JAVA class body source code
+     */
+    def CharSequence generateAsInnerClass() {
+        return generateBody(true)
+    }
+
+
+    override protected body() {
+        generateBody(false);
+    }
+
+    /**
+     * Template method which generates class body.
+     * 
+     * @param isInnerClass boolean value which specify if generated class is|isn't inner
+     * @return string with class source code in JAVA format
+     */
+    def protected generateBody(boolean isInnerClass) '''
+        «type.comment.asJavadoc»
+        «generateClassDeclaration(isInnerClass)» {
+            «suidDeclaration»
+            «innerClassesDeclarations»
+            «enumDeclarations»
+            «constantsDeclarations»
+            «generateFields»
+
+            «constructors»
+            
+            «defaultInstance»
+
+            «FOR field : properties SEPARATOR "\n"»
+                «field.getterMethod»
+                «IF !field.readOnly»
+                    «field.setterMethod»
+                «ENDIF»
+            «ENDFOR»
+
+            «generateHashCode»
+
+            «generateEquals»
+
+            «generateToString(genTO.toStringIdentifiers)»
+
+            «generateGetLength»
+
+            «generateGetRange»
+
+        }
+    '''
+
+
+    /**
+     * Template method which generates inner classes inside this interface.
+     * 
+     * @return string with the source code for inner classes in JAVA format
+     */
+    def protected innerClassesDeclarations() '''
+        «IF !enclosedGeneratedTypes.empty»
+            «FOR innerClass : enclosedGeneratedTypes SEPARATOR "\n"»
+                «IF (innerClass instanceof GeneratedTransferObject)»
+                    «val classTemplate = new ClassTemplate(innerClass as GeneratedTransferObject)»
+                    «classTemplate.generateAsInnerClass»
+                    
+                «ENDIF»
+            «ENDFOR»
+        «ENDIF»
+    '''
+    
+    
+    def protected constructors() '''
+        «IF genTO.unionType»
+            «genUnionConstructor»
+        «ELSE»
+            «allValuesConstructor»
+        «ENDIF»
+        «IF !allProperties.empty»
+            «copyConstructor»
+        «ENDIF»
+        «IF properties.empty && !parentProperties.empty »
+            «parentConstructor»
+        «ENDIF»
+    '''
+    
+    def protected allValuesConstructor() '''
+    «IF genTO.typedef && !allProperties.empty && allProperties.size == 1 && allProperties.get(0).name.equals("value")»
+        @«ConstructorProperties.importedName»("value")
+    «ENDIF»
+    public «type.name»(«allProperties.asArgumentsDeclaration») {
+        «IF false == parentProperties.empty»
+            super(«parentProperties.asArguments»);
+        «ENDIF»
+        «FOR p : allProperties» 
+            «generateRestrictions(type, p.fieldName.toString, p.returnType)»
+        «ENDFOR»
+        «FOR p : properties» 
+            this.«p.fieldName» = «p.fieldName»;
+        «ENDFOR»
+    }
+    '''
+
+    def protected genUnionConstructor() '''
+    «FOR p : allProperties»
+        «val List<GeneratedProperty> other = new ArrayList(properties)»
+        «val added = other.remove(p)»
+        «genConstructor(p, other)»
+    «ENDFOR»
+
+    '''
+
+    def protected genConstructor(GeneratedProperty property, GeneratedProperty... other) '''
+    public «type.name»(«property.returnType.importedName + " " + property.name») {
+        «IF false == parentProperties.empty»
+            super(«parentProperties.asArguments»);
+        «ENDIF»
+            «generateRestrictions(type, property.fieldName.toString, property.returnType)»
+            this.«property.fieldName» = «property.name»;
+            «FOR p : other»
+            this.«p.fieldName» = null;
+            «ENDFOR»
+    }
+    '''
+
+    def protected copyConstructor() '''
+    /**
+     * Creates a copy from Source Object.
+     *
+     * @param source Source object
+     */
+    public «type.name»(«type.name» source) {
+        «IF false == parentProperties.empty»
+            super(source);
+        «ENDIF»
+        «FOR p : properties» 
+            this.«p.fieldName» = source.«p.fieldName»;
+        «ENDFOR»
+    }
+    '''
+
+    def protected parentConstructor() '''
+    /**
+     * Creates a new instance from «genTO.superType.importedName»
+     *
+     * @param source Source object
+     */
+    public «type.name»(«genTO.superType.importedName» source) {
+            super(source);
+    }
+    '''
+
+    def protected defaultInstance() '''
+        «IF genTO.typedef && !allProperties.empty && !genTO.unionType»
+            «val prop = allProperties.get(0)»
+            «IF !("org.opendaylight.yangtools.yang.binding.InstanceIdentifier".equals(prop.returnType.fullyQualifiedName))»
+            public static «genTO.name» getDefaultInstance(String defaultValue) {
+                «IF "byte[]".equals(prop.returnType.name)»
+                    «BaseEncoding.importedName» baseEncoding = «BaseEncoding.importedName».base64(); 
+                    return new «genTO.name»(baseEncoding.decode(defaultValue));
+                «ELSEIF "java.lang.String".equals(prop.returnType.fullyQualifiedName)»
+                    return new «genTO.name»(defaultValue);
+                «ELSEIF allProperties.size > 1»
+                    «bitsArgs»
+                «ELSE»
+                    return new «genTO.name»(new «prop.returnType.importedName»(defaultValue));
+                «ENDIF»
+            }
+            «ENDIF»
+        «ENDIF»
+    '''
+
+    def protected bitsArgs() '''
+        «List.importedName»<«String.importedName»> properties = «Lists.importedName».newArrayList(«allProperties.propsAsArgs»);
+        if (!properties.contains(defaultValue)) {
+            throw new «IllegalArgumentException.importedName»("invalid default parameter");
+        }
+        int i = 0;
+        return new «genTO.name»(
+        «FOR prop : allProperties SEPARATOR ","»
+            properties.get(i++).equals(defaultValue) ? new «Boolean.importedName»("true") : null
+        «ENDFOR»
+        );
+    '''
+
+    def protected propsAsArgs(Iterable<GeneratedProperty> properties) '''
+        «FOR prop : properties SEPARATOR ","»
+            "«prop.name»"
+        «ENDFOR»
+    '''
+
+    /**
+     * Template method which generates JAVA class declaration.
+     * 
+     * @param isInnerClass boolean value which specify if generated class is|isn't inner
+     * @return string with class declaration in JAVA format
+     */
+    def protected generateClassDeclaration(boolean isInnerClass) '''
+        public«
+        IF (isInnerClass)»«
+            " static final "»«
+        ELSEIF (type.abstract)»«
+            " abstract "»«
+        ELSE»«
+            " "»«
+        ENDIF»class «type.name»«
+        IF (genTO.superType != null)»«
+            " extends "»«genTO.superType.importedName»«
+        ENDIF»
+        «IF (!type.implements.empty)»«
+            " implements "»«
+            FOR type : type.implements SEPARATOR ", "»«
+                type.importedName»«
+            ENDFOR»«
+        ENDIF
+    »'''
+    
+    /**
+     * Template method which generates JAVA enum type.
+     * 
+     * @return string with inner enum source code in JAVA format
+     */
+    def protected enumDeclarations() '''
+        «IF !enums.empty»
+            «FOR e : enums SEPARATOR "\n"»
+                «val enumTemplate = new EnumTemplate(e)»
+                «enumTemplate.generateAsInnerClass»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+    def protected suidDeclaration() '''
+        «IF genTO.SUID != null»
+            private static final long serialVersionUID = «genTO.SUID.value»L; 
+        «ENDIF»
+    '''
+
+    /**
+     * Template method wich generates JAVA constants.
+     * 
+     * @return string with constants in JAVA format 
+     */
+    def protected constantsDeclarations() '''
+        «IF !consts.empty»
+            «FOR c : consts»
+                «IF c.name == TypeConstants.PATTERN_CONSTANT_NAME»
+                    «val cValue = c.value»
+                    «IF cValue instanceof List<?>»
+                        «val cValues = cValue as List<?>»
+                        private static final «List.importedName»<«Pattern.importedName»> «Constants.MEMBER_PATTERN_LIST» = new «ArrayList.importedName»<«Pattern.importedName»>();
+                        public static final «List.importedName»<String> «TypeConstants.PATTERN_CONSTANT_NAME» = «Arrays.importedName».asList(«
+                        FOR v : cValues SEPARATOR ", "»«
+                            IF v instanceof String»"«
+                                v as String»"«
+                            ENDIF»«
+                        ENDFOR»);
+
+                        «generateStaticInicializationBlock»
+                    «ENDIF»
+                «ELSE»
+                    public static final «c.type.importedName» «c.name» = «c.value»;
+                «ENDIF»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+    /**
+     * Template method which generates JAVA static initialization block.
+     *
+     * @return string with static initialization block in JAVA format
+     */
+    def protected generateStaticInicializationBlock() '''
+        static {
+            for (String regEx : «TypeConstants.PATTERN_CONSTANT_NAME») {
+                «Constants.MEMBER_PATTERN_LIST».add(Pattern.compile(regEx));
+            }
+        }
+    '''
+
+    /**
+     * Template method which generates JAVA class attributes.
+     *
+     * @return string with the class attributes in JAVA format
+     */
+    def protected generateFields() '''
+        «IF !properties.empty»
+            «FOR f : properties»
+                «IF f.readOnly»final«ENDIF» private «f.returnType.importedName» «f.fieldName»;
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+
+    /**
+     * Template method which generates the method <code>hashCode()</code>.
+     *
+     * @return string with the <code>hashCode()</code> method definition in JAVA format
+     */
+    def protected generateHashCode() '''
+        «IF !genTO.hashCodeIdentifiers.empty»
+            @Override
+            public int hashCode() {
+                final int prime = 31;
+                int result = 1;
+                «FOR property : genTO.hashCodeIdentifiers»
+                    «IF property.returnType.name.contains("[")»
+                    result = prime * result + ((«property.fieldName» == null) ? 0 : «Arrays.importedName».hashCode(«property.fieldName»));
+                    «ELSE»
+                    result = prime * result + ((«property.fieldName» == null) ? 0 : «property.fieldName».hashCode());
+                    «ENDIF»
+                «ENDFOR»
+                return result;
+            }
+        «ENDIF»
     '''
-\r
-}\r
+
+    /**
+     * Template method which generates the method <code>equals()</code>.
+     *
+     * @return string with the <code>equals()</code> method definition in JAVA format
+     */
+    def protected generateEquals() '''
+        «IF !genTO.equalsIdentifiers.empty»
+            @Override
+            public boolean equals(java.lang.Object obj) {
+                if (this == obj) {
+                    return true;
+                }
+                if (obj == null) {
+                    return false;
+                }
+                if (getClass() != obj.getClass()) {
+                    return false;
+                }
+                «type.name» other = («type.name») obj;
+                «FOR property : genTO.equalsIdentifiers»
+                    «val fieldName = property.fieldName»
+                    if («fieldName» == null) {
+                        if (other.«fieldName» != null) {
+                            return false;
+                        }
+                    «IF property.returnType.name.contains("[")»
+                    } else if(!«Arrays.importedName».equals(«fieldName», other.«fieldName»)) {
+                    «ELSE»
+                    } else if(!«fieldName».equals(other.«fieldName»)) {
+                    «ENDIF»
+                        return false;
+                    }
+                «ENDFOR»
+                return true;
+            }
+        «ENDIF»
+    '''
+
+    def private generateGetLength() '''
+        «IF restrictions != null && !(restrictions.lengthConstraints.empty)»
+            «val clazz = restrictions.lengthConstraints.iterator.next.min.class»
+            public static «List.importedName»<«Range.importedName»<«clazz.importedName»>> length() {
+                final «List.importedName»<«Range.importedName»<«clazz.importedName»>> result = new «ArrayList.importedName»<>();
+                «FOR r : restrictions.lengthConstraints»
+                    result.add(«Range.importedName».closed(new «clazz.importedName»("«r.min»"), new «clazz.importedName»("«r.max»")));
+                «ENDFOR»
+                return result;
+            }
+        «ENDIF»
+    '''
+
+    def private generateGetRange() '''
+        «IF restrictions != null && !(restrictions.rangeConstraints.empty)»
+            «val clazz = restrictions.rangeConstraints.iterator.next.min.class»
+            public static «List.importedName»<«Range.importedName»<«clazz.importedName»>> range() {
+                final «List.importedName»<«Range.importedName»<«clazz.importedName»>> result = new «ArrayList.importedName»<>();
+                «FOR r : restrictions.rangeConstraints»
+                    result.add(«Range.importedName».closed(new «clazz.importedName»("«r.min»"), new «clazz.importedName»("«r.max»")));
+                «ENDFOR»
+                return result;
+            }
+        «ENDIF»
+    '''
+
+}
index 15ddd76c50cb1c39a98080aea7602a5fac5f3fc5..fecae3de47dd1b7efa0fea1b694b4deeda3f5941 100644 (file)
@@ -5,82 +5,82 @@
  * 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.yangtools.sal.java.api.generator\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType\r
-\r
-/**\r
- * Template for generating JAVA enumeration type. \r
- */\r
-class EnumTemplate extends BaseTemplate {\r
-\r
-    \r
-    /**\r
-     * Enumeration which will be transformed to JAVA source code for enumeration\r
-     */\r
-    val Enumeration enums\r
-    \r
-    /**\r
-     * Constructs instance of this class with concrete <code>enums</code>.\r
-     * \r
-     * @param enums enumeration which will be transformed to JAVA source code \r
-     */\r
-    new(Enumeration enums) {\r
-        super(enums as GeneratedType )\r
-        this.enums = enums\r
-    }\r
-    \r
-    \r
-    /**\r
-     * Generates only JAVA enumeration source code.\r
-     * \r
-     * @return string with JAVA enumeration source code\r
-     */\r
-    def generateAsInnerClass() {\r
-        return body\r
-    }\r
-    \r
-    /**\r
-     * Template method which generates enumeration body (declaration + enumeration items).\r
-     * \r
-     * @return string with the enumeration body \r
-     */\r
-    override body() '''\r
-        public enum «enums.name» {\r
-        «FOR v : enums.values SEPARATOR ",\n"»\r
-            «"    "»«v.name»(«v.value»)«\r
-        ENDFOR»;\r
-        \r
-            int value;\r
-            static java.util.Map<java.lang.Integer, «enums.name»> valueMap;\r
-\r
-            static {\r
-                valueMap = new java.util.HashMap<>();\r
-                for («enums.name» enumItem : «enums.name».values())\r
-                {\r
-                    valueMap.put(enumItem.value, enumItem);\r
-                }\r
-            }\r
-        \r
-            private «enums.name»(int value) {\r
-                this.value = value;\r
-            }\r
-            \r
-            /**\r
-             * @return integer value\r
-             */\r
-            public int getIntValue() {\r
-                return value;\r
-            }\r
-\r
-            /**\r
-             * @param valueArg\r
-             * @return corresponding «enums.name» item\r
-             */\r
-            public static «enums.name» forValue(int valueArg) {\r
-                return valueMap.get(valueArg);\r
-            }\r
-        }\r
-    '''\r
+package org.opendaylight.yangtools.sal.java.api.generator
+
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
+
+/**
+ * Template for generating JAVA enumeration type. 
+ */
+class EnumTemplate extends BaseTemplate {
+
+    
+    /**
+     * Enumeration which will be transformed to JAVA source code for enumeration
+     */
+    val Enumeration enums
+    
+    /**
+     * Constructs instance of this class with concrete <code>enums</code>.
+     * 
+     * @param enums enumeration which will be transformed to JAVA source code 
+     */
+    new(Enumeration enums) {
+        super(enums as GeneratedType )
+        this.enums = enums
+    }
+    
+    
+    /**
+     * Generates only JAVA enumeration source code.
+     * 
+     * @return string with JAVA enumeration source code
+     */
+    def generateAsInnerClass() {
+        return body
+    }
+    
+    /**
+     * Template method which generates enumeration body (declaration + enumeration items).
+     * 
+     * @return string with the enumeration body 
+     */
+    override body() '''
+        public enum «enums.name» {
+        «FOR v : enums.values SEPARATOR ",\n"»
+            «"    "»«v.name»(«v.value»)«
+        ENDFOR»;
+        
+            int value;
+            static java.util.Map<java.lang.Integer, «enums.name»> valueMap;
+
+            static {
+                valueMap = new java.util.HashMap<>();
+                for («enums.name» enumItem : «enums.name».values())
+                {
+                    valueMap.put(enumItem.value, enumItem);
+                }
+            }
+        
+            private «enums.name»(int value) {
+                this.value = value;
+            }
+            
+            /**
+             * @return integer value
+             */
+            public int getIntValue() {
+                return value;
+            }
+
+            /**
+             * @param valueArg
+             * @return corresponding «enums.name» item
+             */
+            public static «enums.name» forValue(int valueArg) {
+                return valueMap.get(valueArg);
+            }
+        }
+    '''
 }
index f863f3660d12d6a8c197022daa6c3660b7005e4d..329680808073322ee87d9b9ebd29b713bddec487 100644 (file)
  * 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.yangtools.sal.java.api.generator\r
-\r
-import java.util.List\r
-import org.opendaylight.yangtools.binding.generator.util.TypeConstants\r
-import org.opendaylight.yangtools.sal.binding.model.api.Constant\r
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType\r
+package org.opendaylight.yangtools.sal.java.api.generator
+
+import java.util.List
+import org.opendaylight.yangtools.binding.generator.util.TypeConstants
+import org.opendaylight.yangtools.sal.binding.model.api.Constant
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature\rimport org.opendaylight.yangtools.sal.binding.model.api.AnnotationType
 
-/**\r
- * Template for generating JAVA interfaces. \r
- */\r
-class InterfaceTemplate extends BaseTemplate {\r
-    \r
-    /**\r
-     * List of constant instances which are generated as JAVA public static final attributes.\r
-     */\r
-    val List<Constant> consts\r
-    \r
-    /**\r
-     * List of method signatures which are generated as method declarations.\r
-     */\r
-    val List<MethodSignature> methods\r
-    \r
-    /**\r
-     * List of enumeration which are generated as JAVA enum type.\r
-     */\r
-    val List<Enumeration> enums\r
-    \r
-    /**\r
-     * List of generated types which are enclosed inside <code>genType</code>\r
-     */\r
-    val List<GeneratedType> enclosedGeneratedTypes\r
-    \r
-    /**\r
-     * Creates the instance of this class which is used for generating the interface file source \r
-     * code from <code>genType</code>.\r
-     * \r
-     * @throws IllegalArgumentException if <code>genType</code> equals <code>null</code>\r
-     */\r
-    new(GeneratedType genType) {\r
-        super(genType)\r
-        if (genType == null) {\r
-            throw new IllegalArgumentException("Generated type reference cannot be NULL!")\r
-        }\r
-        \r
-        consts = genType.constantDefinitions\r
-        methods = genType.methodDefinitions\r
-        enums = genType.enumerations\r
-        enclosedGeneratedTypes = genType.enclosedTypes\r
-    }\r
-    \r
-\r
-    \r
-    /**\r
-     * Template method which generate the whole body of the interface.\r
-     * \r
-     * @return string with code for interface body in JAVA format\r
-     */\r
-    override body() '''\r
-        «type.comment.asJavadoc»\r
-        public interface «type.name»\r
-            «superInterfaces»\r
-        {\r
-        \r
-            «generateInnerClasses»\r
-        \r
-            «generateEnums»\r
-        \r
-            «generateConstants»\r
-        \r
-            «generateMethods»\r
-        \r
-        }\r
-        \r
-    '''\r
-   \r
-\r
-    def private generateAnnotations(List<AnnotationType> annotations) '''\r
-        «IF annotations != null && !annotations.empty»\r
-            «FOR annotation : annotations»\r
-                @«annotation.name»\r
-                «IF annotation.parameters != null && !annotation.parameters.empty»\r
-                (\r
-                «FOR param : annotation.parameters SEPARATOR ","»\r
-                    «param.name»=«param.value»\r
-                «ENDFOR»\r
-                )\r
-                «ENDIF»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates the interface name declaration.\r
-     * \r
-     * @return string with the code for the interface declaration in JAVA format\r
-     */\r
-    def private superInterfaces() \r
-    '''\r
-    «IF (!type.implements.empty)»\r
-         extends\r
-         «FOR type : type.implements SEPARATOR ","»\r
-             «type.importedName»\r
-         «ENDFOR»\r
-     « ENDIF»\r
-     '''\r
-\r
-    /**\r
-     * Template method which generates inner classes inside this interface.\r
-     * \r
-     * @return string with the source code for inner classes in JAVA format\r
-     */\r
-    def private generateInnerClasses() '''\r
-        «IF !enclosedGeneratedTypes.empty»\r
-            «FOR innerClass : enclosedGeneratedTypes SEPARATOR "\n"»\r
-                «IF (innerClass instanceof GeneratedTransferObject)»\r
-                    «IF (innerClass as GeneratedTransferObject).unionType»\r
-                        «val unionTemplate = new UnionTemplate(innerClass as GeneratedTransferObject)»\r
-                        «unionTemplate.generateAsInnerClass»\r
-                        «this.importMap.putAll(unionTemplate.importMap)»\r
-                    «ELSE»\r
-                        «val classTemplate = new ClassTemplate(innerClass as GeneratedTransferObject)»\r
-                        «classTemplate.generateAsInnerClass»\r
-                        «this.importMap.putAll(classTemplate.importMap)»\r
-                    «ENDIF»\r
-\r
-                «ENDIF»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates JAVA enum type.\r
-     * \r
-     * @return string with inner enum source code in JAVA format\r
-     */    \r
-    def private generateEnums() '''\r
-        «IF !enums.empty»\r
-            «FOR e : enums SEPARATOR "\n"»\r
-                «val enumTemplate = new EnumTemplate(e)»\r
-                «enumTemplate.generateAsInnerClass»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-    \r
-    /**\r
-     * Template method wich generates JAVA constants.\r
-     * \r
-     * @return string with constants in JAVA format \r
-     */    \r
-    def private generateConstants() '''\r
-        «IF !consts.empty»\r
-            «FOR c : consts»\r
-                «IF c.name != TypeConstants.PATTERN_CONSTANT_NAME»\r
-                    public static final «c.type.importedName» «c.name» = «c.value»;\r
-                «ENDIF»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-    /**\r
-     * Template method which generates the declaration of the methods.\r
-     * \r
-     * @return string with the declaration of methods source code in JAVA format \r
-     */    \r
-    def private generateMethods() '''\r
-        «IF !methods.empty»\r
-            «FOR m : methods SEPARATOR "\n"»\r
-                «m.comment.asJavadoc»\r
-                «m.annotations.generateAnnotations»\r
-                «m.returnType.importedName» «m.name»(«m.parameters.generateParameters»);\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-}\r
-\r
+/**
+ * Template for generating JAVA interfaces. 
+ */
+class InterfaceTemplate extends BaseTemplate {
+    
+    /**
+     * List of constant instances which are generated as JAVA public static final attributes.
+     */
+    val List<Constant> consts
+    
+    /**
+     * List of method signatures which are generated as method declarations.
+     */
+    val List<MethodSignature> methods
+    
+    /**
+     * List of enumeration which are generated as JAVA enum type.
+     */
+    val List<Enumeration> enums
+    
+    /**
+     * List of generated types which are enclosed inside <code>genType</code>
+     */
+    val List<GeneratedType> enclosedGeneratedTypes
+    
+    /**
+     * Creates the instance of this class which is used for generating the interface file source 
+     * code from <code>genType</code>.
+     * 
+     * @throws IllegalArgumentException if <code>genType</code> equals <code>null</code>
+     */
+    new(GeneratedType genType) {
+        super(genType)
+        if (genType == null) {
+            throw new IllegalArgumentException("Generated type reference cannot be NULL!")
+        }
+        
+        consts = genType.constantDefinitions
+        methods = genType.methodDefinitions
+        enums = genType.enumerations
+        enclosedGeneratedTypes = genType.enclosedTypes
+    }
+    
+
+    
+    /**
+     * Template method which generate the whole body of the interface.
+     * 
+     * @return string with code for interface body in JAVA format
+     */
+    override body() '''
+        «type.comment.asJavadoc»
+        public interface «type.name»
+            «superInterfaces»
+        {
+        
+            «generateInnerClasses»
+        
+            «generateEnums»
+        
+            «generateConstants»
+        
+            «generateMethods»
+        
+        }
+        
+    '''
+   
+
+    def private generateAnnotations(List<AnnotationType> annotations) '''
+        «IF annotations != null && !annotations.empty»
+            «FOR annotation : annotations»
+                @«annotation.name»
+                «IF annotation.parameters != null && !annotation.parameters.empty»
+                (
+                «FOR param : annotation.parameters SEPARATOR ","»
+                    «param.name»=«param.value»
+                «ENDFOR»
+                )
+                «ENDIF»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+    /**
+     * Template method which generates the interface name declaration.
+     * 
+     * @return string with the code for the interface declaration in JAVA format
+     */
+    def private superInterfaces() 
+    '''
+    «IF (!type.implements.empty)»
+         extends
+         «FOR type : type.implements SEPARATOR ","»
+             «type.importedName»
+         «ENDFOR»
+     « ENDIF»
+     '''
+
+    /**
+     * Template method which generates inner classes inside this interface.
+     * 
+     * @return string with the source code for inner classes in JAVA format
+     */
+    def private generateInnerClasses() '''
+        «IF !enclosedGeneratedTypes.empty»
+            «FOR innerClass : enclosedGeneratedTypes SEPARATOR "\n"»
+                «IF (innerClass instanceof GeneratedTransferObject)»
+                    «IF (innerClass as GeneratedTransferObject).unionType»
+                        «val unionTemplate = new UnionTemplate(innerClass as GeneratedTransferObject)»
+                        «unionTemplate.generateAsInnerClass»
+                        «this.importMap.putAll(unionTemplate.importMap)»
+                    «ELSE»
+                        «val classTemplate = new ClassTemplate(innerClass as GeneratedTransferObject)»
+                        «classTemplate.generateAsInnerClass»
+                        «this.importMap.putAll(classTemplate.importMap)»
+                    «ENDIF»
+
+                «ENDIF»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+    /**
+     * Template method which generates JAVA enum type.
+     * 
+     * @return string with inner enum source code in JAVA format
+     */    
+    def private generateEnums() '''
+        «IF !enums.empty»
+            «FOR e : enums SEPARATOR "\n"»
+                «val enumTemplate = new EnumTemplate(e)»
+                «enumTemplate.generateAsInnerClass»
+            «ENDFOR»
+        «ENDIF»
+    '''
+    
+    /**
+     * Template method wich generates JAVA constants.
+     * 
+     * @return string with constants in JAVA format 
+     */    
+    def private generateConstants() '''
+        «IF !consts.empty»
+            «FOR c : consts»
+                «IF c.name != TypeConstants.PATTERN_CONSTANT_NAME»
+                    public static final «c.type.importedName» «c.name» = «c.value»;
+                «ENDIF»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+    /**
+     * Template method which generates the declaration of the methods.
+     * 
+     * @return string with the declaration of methods source code in JAVA format 
+     */    
+    def private generateMethods() '''
+        «IF !methods.empty»
+            «FOR m : methods SEPARATOR "\n"»
+                «m.comment.asJavadoc»
+                «m.annotations.generateAnnotations»
+                «m.returnType.importedName» «m.name»(«m.parameters.generateParameters»);
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+}
+
index 7cd57f6a82515bba64d5e6f883e42588783124d7..a17927ef9a88d6109a99d023768ad5ac599a52e7 100644 (file)
@@ -1,56 +1,56 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.java.api.generator;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-\r
-/**\r
- *\r
- * Transformator of the data from the virtual form to JAVA source code. The\r
- * result source code represents JAVA class. For generating of the source code\r
- * is used the template written in XTEND language.\r
- *\r
- */\r
-public final class TOGenerator implements CodeGenerator {\r
-\r
-    /**\r
-     * Generates JAVA source code for generated type <code>Type</code>. The code\r
-     * is generated according to the template source code template which is\r
-     * written in XTEND language.\r
-     */\r
-    @Override\r
-    public String generate(Type type) {\r
-        if (type instanceof GeneratedTransferObject) {\r
-            final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
-            if(genTO.isUnionType()) {\r
-                final UnionTemplate template = new UnionTemplate(genTO);\r
-                return template.generate();\r
-            } else if (genTO.isUnionTypeBuilder()) {\r
-                final UnionBuilderTemplate template = new UnionBuilderTemplate(genTO);\r
-                return template.generate();\r
-            } else {\r
-                final ClassTemplate template = new ClassTemplate(genTO);\r
-                return template.generate();\r
-            }\r
-        }\r
-        return "";\r
-    }\r
-\r
-    @Override\r
-    public boolean isAcceptable(Type type) {\r
-        return type instanceof GeneratedTransferObject;\r
-    }\r
-\r
-    @Override\r
-    public String getUnitName(Type type) {\r
-        return type.getName();\r
-    }\r
-\r
-}\r
+/*
+ * 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.yangtools.sal.java.api.generator;
+
+import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+/**
+ *
+ * Transformator of the data from the virtual form to JAVA source code. The
+ * result source code represents JAVA class. For generating of the source code
+ * is used the template written in XTEND language.
+ *
+ */
+public final class TOGenerator implements CodeGenerator {
+
+    /**
+     * Generates JAVA source code for generated type <code>Type</code>. The code
+     * is generated according to the template source code template which is
+     * written in XTEND language.
+     */
+    @Override
+    public String generate(Type type) {
+        if (type instanceof GeneratedTransferObject) {
+            final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+            if(genTO.isUnionType()) {
+                final UnionTemplate template = new UnionTemplate(genTO);
+                return template.generate();
+            } else if (genTO.isUnionTypeBuilder()) {
+                final UnionBuilderTemplate template = new UnionBuilderTemplate(genTO);
+                return template.generate();
+            } else {
+                final ClassTemplate template = new ClassTemplate(genTO);
+                return template.generate();
+            }
+        }
+        return "";
+    }
+
+    @Override
+    public boolean isAcceptable(Type type) {
+        return type instanceof GeneratedTransferObject;
+    }
+
+    @Override
+    public String getUnitName(Type type) {
+        return type.getName();
+    }
+
+}
index e95410eaedae49ddc401f661340b5f0f763fd2c5..edce4bdcffa51bbd3174919dd3e2b4888b34e67b 100644 (file)
@@ -10,35 +10,35 @@ package org.opendaylight.yangtools.sal.java.api.generator
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier
 
-/**\r
- * Template for generating JAVA class.\r
+/**
+ * Template for generating JAVA class.
  */
 class UnionBuilderTemplate extends ClassTemplate {
 
-    /**\r
-     * Creates instance of this class with concrete <code>genType</code>.\r
-     *\r
-     * @param genType generated transfer object which will be transformed to JAVA class source code\r
+    /**
+     * Creates instance of this class with concrete <code>genType</code>.
+     *
+     * @param genType generated transfer object which will be transformed to JAVA class source code
      */
     new(GeneratedTransferObject genType) {
         super(genType)
     }
 
     def override body() '''
-        «type.comment.asJavadoc»\r
-        public class «type.name» {\r
-\r
-            «generateMethods»\r
-\r
-        }\r
+        «type.comment.asJavadoc»
+        public class «type.name» {
+
+            «generateMethods»
+
+        }
     '''
 
     def private generateMethods() '''
         «FOR method : genTO.methodDefinitions»
             «method.accessModifier.accessModifier»«IF method.static»static«ENDIF»«IF method.final» final«ENDIF» «method.
-            returnType.importedName» «method.name»(«method.parameters.generateParameters») {\r
-                throw new «UnsupportedOperationException.importedName»("Not yet implemented");\r
-            }\r
+            returnType.importedName» «method.name»(«method.parameters.generateParameters») {
+                throw new «UnsupportedOperationException.importedName»("Not yet implemented");
+            }
         «ENDFOR»
     '''
 
index 7d6ee7573cb78e1ded6f2e4ac4dc68f7135f3dcf..c952c6c18eaa86b5917c851f5eceb88e5514b005 100644 (file)
@@ -1,8 +1,8 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+/*
+ * 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.yangtools.sal.java.api.generator;
\ No newline at end of file
index c6220c0a6c7b33298d0bc4ad78a8fd98cbe7006e..9a318715275a70362a5dbda35790181a6da37c19 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.java.api.generator.test;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-import java.net.URISyntaxException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Ignore;\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.binding.generator.util.Types;\r
-import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;\r
-import org.opendaylight.yangtools.sal.java.api.generator.TOGenerator;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
-\r
-public class ClassCodeGeneratorTest {\r
-\r
-    private final static List<File> testModels = new ArrayList<File>();\r
-\r
-    @BeforeClass\r
-    public static void loadTestResources() throws URISyntaxException {\r
-        final File listModelFile = new File(ClassCodeGeneratorTest.class\r
-                .getResource("/list-composite-key.yang").toURI());\r
-        testModels.add(listModelFile);\r
-    }\r
-\r
-    @Test\r
-    public void compositeKeyClassTest() {\r
-        final YangModelParser parser = new YangParserImpl();\r
-        final Set<Module> modules = parser.parseYangModels(testModels);\r
-        final SchemaContext context = parser.resolveSchemaContext(modules);\r
-\r
-        assertNotNull(context);\r
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
-        final List<Type> genTypes = bindingGen.generateTypes(context);\r
-\r
-        assertTrue(genTypes != null);\r
-        assertEquals(7, genTypes.size());\r
-\r
-        int genTypesCount = 0;\r
-        int genTOsCount = 0;\r
-        for (final Type type : genTypes) {\r
-            if (type instanceof GeneratedType\r
-                    && !(type instanceof GeneratedTransferObject)) {\r
-                genTypesCount++;\r
-            } else if (type instanceof GeneratedTransferObject) {\r
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
-\r
-                if (genTO.getName().equals("CompositeKeyListKey")) {\r
-                    final List<GeneratedProperty> properties = genTO\r
-                            .getProperties();\r
-                    int propertyCount = 0;\r
-                    for (final GeneratedProperty prop : properties) {\r
-                        if (prop.getName().equals("key1")) {\r
-                            propertyCount++;\r
-                        } else if (prop.getName().equals("key2")) {\r
-                            propertyCount++;\r
-                        }\r
-                    }\r
-\r
-                    final TOGenerator clsGen = new TOGenerator();\r
-                    final String outputStr = clsGen.generate(genTO);\r
-\r
-                    assertNotNull(outputStr);\r
-                    assertTrue(outputStr.contains("public CompositeKeyListKey(Byte _key1, String _key2)"));\r
-\r
-                    assertEquals(2, propertyCount);\r
-                    genTOsCount++;\r
-                } else if (genTO.getName().equals("InnerListKey")) {\r
-                    final List<GeneratedProperty> properties = genTO\r
-                            .getProperties();\r
-                    assertEquals(1, properties.size());\r
-                    genTOsCount++;\r
-                }\r
-            }\r
-        }\r
-\r
-        assertEquals(5, genTypesCount);\r
-        assertEquals(2, genTOsCount);\r
-    }\r
-\r
-    @Ignore\r
-    @Test\r
-    public void defaultConstructorTest() {\r
-        final GeneratedTOBuilder toBuilder = new GeneratedTOBuilderImpl(\r
-                "simple.pack", "DefCtor");\r
-\r
-        GeneratedPropertyBuilder propBuilder = toBuilder.addProperty("foo");\r
-        propBuilder.setReturnType(Types.typeForClass(String.class));\r
-        propBuilder.setReadOnly(false);\r
-\r
-        propBuilder = toBuilder.addProperty("bar");\r
-        propBuilder.setReturnType(Types.typeForClass(Integer.class));\r
-        propBuilder.setReadOnly(false);\r
-\r
-        final GeneratedTransferObject genTO = toBuilder.toInstance();\r
-\r
-        final TOGenerator clsGen = new TOGenerator();\r
-        final String outputStr = clsGen.generate(genTO);\r
-\r
-        assertNotNull(outputStr);\r
-        assertTrue(outputStr.contains("public DefCtor()"));\r
-    }\r
-\r
-    @Test\r
-    public void toStringTest() {\r
-        final GeneratedTOBuilder toBuilder = new GeneratedTOBuilderImpl(\r
-                "simple.pack", "DefCtor");\r
-\r
-        GeneratedPropertyBuilder propBuilder = toBuilder.addProperty("foo");\r
-        propBuilder.setReturnType(Types.typeForClass(String.class));\r
-        propBuilder.setReadOnly(false);\r
-        toBuilder.addToStringProperty(propBuilder);\r
-\r
-        propBuilder = toBuilder.addProperty("bar");\r
-        propBuilder.setReturnType(Types.typeForClass(Integer.class));\r
-        propBuilder.setReadOnly(false);\r
-        toBuilder.addToStringProperty(propBuilder);\r
-        final GeneratedTransferObject genTO = toBuilder.toInstance();\r
-        final TOGenerator clsGen = new TOGenerator();\r
-        assertNotNull(clsGen.generate(genTO));\r
-    }\r
-}\r
+/*
+ * 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.yangtools.sal.java.api.generator.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opendaylight.yangtools.binding.generator.util.Types;
+import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.yangtools.sal.java.api.generator.TOGenerator;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class ClassCodeGeneratorTest {
+
+    private final static List<File> testModels = new ArrayList<File>();
+
+    @BeforeClass
+    public static void loadTestResources() throws URISyntaxException {
+        final File listModelFile = new File(ClassCodeGeneratorTest.class
+                .getResource("/list-composite-key.yang").toURI());
+        testModels.add(listModelFile);
+    }
+
+    @Test
+    public void compositeKeyClassTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(testModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        assertNotNull(context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertTrue(genTypes != null);
+        assertEquals(7, genTypes.size());
+
+        int genTypesCount = 0;
+        int genTOsCount = 0;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
+                genTypesCount++;
+            } else if (type instanceof GeneratedTransferObject) {
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+
+                if (genTO.getName().equals("CompositeKeyListKey")) {
+                    final List<GeneratedProperty> properties = genTO
+                            .getProperties();
+                    int propertyCount = 0;
+                    for (final GeneratedProperty prop : properties) {
+                        if (prop.getName().equals("key1")) {
+                            propertyCount++;
+                        } else if (prop.getName().equals("key2")) {
+                            propertyCount++;
+                        }
+                    }
+
+                    final TOGenerator clsGen = new TOGenerator();
+                    final String outputStr = clsGen.generate(genTO);
+
+                    assertNotNull(outputStr);
+                    assertTrue(outputStr.contains("public CompositeKeyListKey(Byte _key1, String _key2)"));
+
+                    assertEquals(2, propertyCount);
+                    genTOsCount++;
+                } else if (genTO.getName().equals("InnerListKey")) {
+                    final List<GeneratedProperty> properties = genTO
+                            .getProperties();
+                    assertEquals(1, properties.size());
+                    genTOsCount++;
+                }
+            }
+        }
+
+        assertEquals(5, genTypesCount);
+        assertEquals(2, genTOsCount);
+    }
+
+    @Ignore
+    @Test
+    public void defaultConstructorTest() {
+        final GeneratedTOBuilder toBuilder = new GeneratedTOBuilderImpl(
+                "simple.pack", "DefCtor");
+
+        GeneratedPropertyBuilder propBuilder = toBuilder.addProperty("foo");
+        propBuilder.setReturnType(Types.typeForClass(String.class));
+        propBuilder.setReadOnly(false);
+
+        propBuilder = toBuilder.addProperty("bar");
+        propBuilder.setReturnType(Types.typeForClass(Integer.class));
+        propBuilder.setReadOnly(false);
+
+        final GeneratedTransferObject genTO = toBuilder.toInstance();
+
+        final TOGenerator clsGen = new TOGenerator();
+        final String outputStr = clsGen.generate(genTO);
+
+        assertNotNull(outputStr);
+        assertTrue(outputStr.contains("public DefCtor()"));
+    }
+
+    @Test
+    public void toStringTest() {
+        final GeneratedTOBuilder toBuilder = new GeneratedTOBuilderImpl(
+                "simple.pack", "DefCtor");
+
+        GeneratedPropertyBuilder propBuilder = toBuilder.addProperty("foo");
+        propBuilder.setReturnType(Types.typeForClass(String.class));
+        propBuilder.setReadOnly(false);
+        toBuilder.addToStringProperty(propBuilder);
+
+        propBuilder = toBuilder.addProperty("bar");
+        propBuilder.setReturnType(Types.typeForClass(Integer.class));
+        propBuilder.setReadOnly(false);
+        toBuilder.addToStringProperty(propBuilder);
+        final GeneratedTransferObject genTO = toBuilder.toInstance();
+        final TOGenerator clsGen = new TOGenerator();
+        assertNotNull(clsGen.generate(genTO));
+    }
+}
index d5156348c3da71e8ad72cbc3a41373a38faab69d..b7b712b8f9712db18e29215a807f4c7d1fff5a8e 100644 (file)
@@ -1,8 +1,8 @@
-/*\r
-  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
-  *\r
-  * This program and the accompanying materials are made available under the\r
-  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
-  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
-  */\r
+/*
+  * 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.yangtools.sal.java.api.generator.test;
\ No newline at end of file
index 12b7ed52bd834db32d6b33081e8b6546780a904f..13f13ee9dd11934258e9dadc04c9bb28170371d7 100644 (file)
@@ -1,16 +1,16 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.model.api;\r
-\r
-/**\r
- * Enum definition which provides four access modifiers that are described\r
- * in Java programming language (Default, Private, Protected, Public).\r
- */\r
-public enum AccessModifier {\r
-    DEFAULT, PRIVATE, PUBLIC, PROTECTED\r
-}\r
+/*
+ * 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.yangtools.sal.binding.model.api;
+
+/**
+ * Enum definition which provides four access modifiers that are described
+ * in Java programming language (Default, Private, Protected, Public).
+ */
+public enum AccessModifier {
+    DEFAULT, PRIVATE, PUBLIC, PROTECTED
+}
index adf2cbbcdbcba233befd550a0f6b1252a37af1b2..8adabcec949371f2d0f7508d961cf7d79885731c 100644 (file)
@@ -1,37 +1,37 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.model.api;\r
-\r
-/**\r
- * Represents an instance of simple parametrized type such as List<String>.\r
- *\r
- * The parametrized Type is designed to be used to store information of Java\r
- * Generic Type. The array of {@link #getActualTypeArguments()} holds\r
- * information of all generic parameters defined for Parameterized Type.\r
- */\r
-public interface ParameterizedType extends Type {\r
-\r
-    /**\r
-     * Returns array of Types that are defined for Parameterized Type.\r
-     * <br>\r
-     * (for example if ParameterizedType encapsulates java generic Map that\r
-     * specifies two parameters Map<K,V> and the K is java.lang.Integer and V\r
-     * is defined as GeneratedType the array will contain two Types to store\r
-     * the information of generic parameters.)\r
-     *\r
-     * @return array of Types that are defined for Parameterized Type.\r
-     */\r
-    Type[] getActualTypeArguments();\r
-\r
-    /**\r
-     * Returns the Raw Type definition of Parameterized Type.\r
-     *\r
-     * @return the Raw Type definition of Parameterized Type.\r
-     */\r
-    Type getRawType();\r
-}\r
+/*
+ * 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.yangtools.sal.binding.model.api;
+
+/**
+ * Represents an instance of simple parametrized type such as List<String>.
+ *
+ * The parametrized Type is designed to be used to store information of Java
+ * Generic Type. The array of {@link #getActualTypeArguments()} holds
+ * information of all generic parameters defined for Parameterized Type.
+ */
+public interface ParameterizedType extends Type {
+
+    /**
+     * Returns array of Types that are defined for Parameterized Type.
+     * <br>
+     * (for example if ParameterizedType encapsulates java generic Map that
+     * specifies two parameters Map<K,V> and the K is java.lang.Integer and V
+     * is defined as GeneratedType the array will contain two Types to store
+     * the information of generic parameters.)
+     *
+     * @return array of Types that are defined for Parameterized Type.
+     */
+    Type[] getActualTypeArguments();
+
+    /**
+     * Returns the Raw Type definition of Parameterized Type.
+     *
+     * @return the Raw Type definition of Parameterized Type.
+     */
+    Type getRawType();
+}
index f35ec1ff484d5cf24b442cfbd0c43c4da6a27950..e4ac5a8505394da281d914c216445f103ed06e47 100644 (file)
@@ -1,9 +1,9 @@
-/**\r
-\r
- *\r
- * March 2013\r
- *\r
- * Copyright (c) 2013 by Cisco Systems, Inc.\r
- * All rights reserved.\r
- */\r
+/**
+
+ *
+ * March 2013
+ *
+ * Copyright (c) 2013 by Cisco Systems, Inc.
+ * All rights reserved.
+ */
 package org.opendaylight.yangtools.sal.binding.model.api.type.builder;
\ No newline at end of file
index 87f96f5444dba7b5ed04c21d1225496035fd38ce..4763f3931e95efb0c7f35902f3d9c5aa553be28a 100644 (file)
@@ -1,9 +1,9 @@
-/**\r
-\r
- *\r
- * March 2013\r
- *\r
- * Copyright (c) 2013 by Cisco Systems, Inc.\r
- * All rights reserved.\r
- */\r
+/**
+
+ *
+ * March 2013
+ *
+ * Copyright (c) 2013 by Cisco Systems, Inc.
+ * All rights reserved.
+ */
 package org.opendaylight.yangtools.sal.binding.model.api.type.provider;
\ No newline at end of file
index a5c62c4bce5e1317520f1714c6be93f7b27537bd..c9bcc282e04b2036b1436019b10d69ea95ec4828 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.yang.types;\r
-\r
-import java.math.BigDecimal;\r
-import java.math.BigInteger;\r
-import java.util.Collections;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;\r
-import org.opendaylight.yangtools.binding.generator.util.Types;\r
-import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;\r
-import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;\r
-import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;\r
-import org.opendaylight.yangtools.yang.model.util.BaseConstraints;\r
-\r
-public final class BaseYangTypes {\r
-    /**\r
-     * mapping of basic built-in YANG types (keys) to JAVA\r
-     * {@link org.opendaylight.yangtools.sal.binding.model.api.Type Type}. This\r
-     * map is filled with mapping data in static initialization block\r
-     */\r
-    private static Map<String, Type> typeMap = new HashMap<String, Type>();\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>boolean</code> YANG type\r
-     */\r
-    public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>empty</code> YANG type\r
-     */\r
-    public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class);\r
-\r
-    public static final Type ENUM_TYPE = Types.typeForClass(Enum.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>int8</code> YANG type\r
-     */\r
-    public static final Type INT8_TYPE = Types.typeForClass(Byte.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>int16</code> YANG type\r
-     */\r
-    public static final Type INT16_TYPE = Types.typeForClass(Short.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>int32</code> YANG type\r
-     */\r
-    public static final Type INT32_TYPE = Types.typeForClass(Integer.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>int64</code> YANG type\r
-     */\r
-    public static final Type INT64_TYPE = Types.typeForClass(Long.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>string</code> YANG type\r
-     */\r
-    public static final Type STRING_TYPE = Types.typeForClass(String.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>decimal64</code> YANG type\r
-     */\r
-    public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class);\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>uint8</code> YANG type\r
-     */\r
-    public static final Type UINT8_TYPE = Types.typeForClass(Short.class, singleRangeRestrictions(0, 255));\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>uint16</code> YANG type\r
-     */\r
-    public static final Type UINT16_TYPE = Types.typeForClass(Integer.class, singleRangeRestrictions(0, 65535));\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>uint32</code> YANG type\r
-     */\r
-    public static final Type UINT32_TYPE = Types.typeForClass(Long.class, singleRangeRestrictions(0, 4294967295L));\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>uint64</code> YANG type\r
-     */\r
-    public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class,\r
-            singleRangeRestrictions(0, new BigInteger("18446744073709551615")));\r
-\r
-    public static final Type UNION_TYPE = new UnionType();\r
-\r
-    /**\r
-     * <code>Type</code> representation of <code>binary</code> YANG type\r
-     */\r
-    public static final Type BINARY_TYPE = Types.primitiveType("byte[]", null);\r
-\r
-    public static final Type INSTANCE_IDENTIFIER = Types.parameterizedTypeFor(Types\r
-            .typeForClass(InstanceIdentifier.class));\r
-\r
-    /**\r
-     * It is undesirable to create instance of this class.\r
-     */\r
-    private BaseYangTypes() {\r
-    }\r
-\r
-    static {\r
-        typeMap.put("boolean", BOOLEAN_TYPE);\r
-        typeMap.put("empty", EMPTY_TYPE);\r
-        typeMap.put("enumeration", ENUM_TYPE);\r
-        typeMap.put("int8", INT8_TYPE);\r
-        typeMap.put("int16", INT16_TYPE);\r
-        typeMap.put("int32", INT32_TYPE);\r
-        typeMap.put("int64", INT64_TYPE);\r
-        typeMap.put("string", STRING_TYPE);\r
-        typeMap.put("decimal64", DECIMAL64_TYPE);\r
-        typeMap.put("uint8", UINT8_TYPE);\r
-        typeMap.put("uint16", UINT16_TYPE);\r
-        typeMap.put("uint32", UINT32_TYPE);\r
-        typeMap.put("uint64", UINT64_TYPE);\r
-        typeMap.put("union", UNION_TYPE);\r
-        typeMap.put("binary", BINARY_TYPE);\r
-        typeMap.put("instance-identifier", INSTANCE_IDENTIFIER);\r
-    }\r
-\r
-    public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {\r
-        /**\r
-         * Searches <code>Type</code> value to which is YANG <code>type</code>\r
-         * mapped.\r
-         *\r
-         * @param type\r
-         *            string with YANG type name\r
-         * @return java <code>Type</code> representation of <code>type</code>\r
-         */\r
-        @Override\r
-        public Type javaTypeForYangType(String type) {\r
-            return typeMap.get(type);\r
-        }\r
-\r
-        /**\r
-         * Searches <code>Type</code> value to which is YANG <code>type</code>\r
-         * mapped.\r
-         *\r
-         * @param type\r
-         *            type definition representation of YANG type\r
-         * @return java <code>Type</code> representation of <code>type</code>.\r
-         *         If <code>type</code> isn't found then <code>null</code> is\r
-         *         returned.\r
-         */\r
-        @Override\r
-        public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode) {\r
-            if (type != null) {\r
-                return typeMap.get(type.getQName().getLocalName());\r
-            }\r
-\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode,\r
-                Restrictions restrictions) {\r
-            String typeName = type.getQName().getLocalName();\r
-            switch (typeName) {\r
-            case "binary":\r
-                return Types.primitiveType("byte[]", restrictions);\r
-            case "decimal64":\r
-                return Types.typeForClass(BigDecimal.class, restrictions);\r
-            case "enumeration":\r
-                return Types.typeForClass(Enum.class, restrictions);\r
-            case "int8":\r
-                return Types.typeForClass(Byte.class, restrictions);\r
-            case "int16":\r
-                return Types.typeForClass(Short.class, restrictions);\r
-            case "int32":\r
-                return Types.typeForClass(Integer.class, restrictions);\r
-            case "int64":\r
-                return Types.typeForClass(Long.class, restrictions);\r
-            case "string":\r
-                return Types.typeForClass(String.class, restrictions);\r
-            case "uint8":\r
-                return Types.typeForClass(Short.class, restrictions);\r
-            case "uint16":\r
-                return Types.typeForClass(Integer.class, restrictions);\r
-            case "uint32":\r
-                return Types.typeForClass(Long.class, restrictions);\r
-            case "uint64":\r
-                return Types.typeForClass(BigInteger.class, restrictions);\r
-            case "union" :\r
-                return UNION_TYPE;\r
-            default:\r
-                return javaTypeForSchemaDefinitionType(type, parentNode);\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public String getTypeDefaultConstruction(LeafSchemaNode node) {\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public String getConstructorPropertyName(SchemaNode node) {\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public String getParamNameFromType(TypeDefinition<?> type) {\r
-            return "_" + BindingGeneratorUtil.parseToValidParamName(type.getQName().getLocalName());\r
-        }\r
-    };\r
-\r
-    private static Restrictions singleRangeRestrictions(final Number min, final Number max) {\r
-        return new Restrictions() {\r
-            @Override\r
-            public boolean isEmpty() {\r
-                return false;\r
-            }\r
-\r
-            @Override\r
-            public List<RangeConstraint> getRangeConstraints() {\r
-                return Collections.singletonList(BaseConstraints.rangeConstraint(min, max, null, null));\r
-            }\r
-\r
-            @Override\r
-            public List<PatternConstraint> getPatternConstraints() {\r
-                return Collections.emptyList();\r
-            }\r
-\r
-            @Override\r
-            public List<LengthConstraint> getLengthConstraints() {\r
-                return Collections.emptyList();\r
-            }\r
-        };\r
-    }\r
-\r
-    public static final class UnionType implements Type {\r
-        @Override\r
-        public String getPackageName() {\r
-            return null;\r
-        }\r
-        @Override\r
-        public String getName() {\r
-            return "Union";\r
-        }\r
-        @Override\r
-        public String getFullyQualifiedName() {\r
-            return "Union";\r
-        }\r
-    }\r
-\r
-}\r
+/*
+ * 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.yangtools.sal.binding.yang.types;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
+import org.opendaylight.yangtools.binding.generator.util.Types;
+import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
+import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
+
+public final class BaseYangTypes {
+    /**
+     * mapping of basic built-in YANG types (keys) to JAVA
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.Type Type}. This
+     * map is filled with mapping data in static initialization block
+     */
+    private static Map<String, Type> typeMap = new HashMap<String, Type>();
+
+    /**
+     * <code>Type</code> representation of <code>boolean</code> YANG type
+     */
+    public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);
+
+    /**
+     * <code>Type</code> representation of <code>empty</code> YANG type
+     */
+    public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class);
+
+    public static final Type ENUM_TYPE = Types.typeForClass(Enum.class);
+
+    /**
+     * <code>Type</code> representation of <code>int8</code> YANG type
+     */
+    public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
+
+    /**
+     * <code>Type</code> representation of <code>int16</code> YANG type
+     */
+    public static final Type INT16_TYPE = Types.typeForClass(Short.class);
+
+    /**
+     * <code>Type</code> representation of <code>int32</code> YANG type
+     */
+    public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
+
+    /**
+     * <code>Type</code> representation of <code>int64</code> YANG type
+     */
+    public static final Type INT64_TYPE = Types.typeForClass(Long.class);
+
+    /**
+     * <code>Type</code> representation of <code>string</code> YANG type
+     */
+    public static final Type STRING_TYPE = Types.typeForClass(String.class);
+
+    /**
+     * <code>Type</code> representation of <code>decimal64</code> YANG type
+     */
+    public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class);
+
+    /**
+     * <code>Type</code> representation of <code>uint8</code> YANG type
+     */
+    public static final Type UINT8_TYPE = Types.typeForClass(Short.class, singleRangeRestrictions(0, 255));
+
+    /**
+     * <code>Type</code> representation of <code>uint16</code> YANG type
+     */
+    public static final Type UINT16_TYPE = Types.typeForClass(Integer.class, singleRangeRestrictions(0, 65535));
+
+    /**
+     * <code>Type</code> representation of <code>uint32</code> YANG type
+     */
+    public static final Type UINT32_TYPE = Types.typeForClass(Long.class, singleRangeRestrictions(0, 4294967295L));
+
+    /**
+     * <code>Type</code> representation of <code>uint64</code> YANG type
+     */
+    public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class,
+            singleRangeRestrictions(0, new BigInteger("18446744073709551615")));
+
+    public static final Type UNION_TYPE = new UnionType();
+
+    /**
+     * <code>Type</code> representation of <code>binary</code> YANG type
+     */
+    public static final Type BINARY_TYPE = Types.primitiveType("byte[]", null);
+
+    public static final Type INSTANCE_IDENTIFIER = Types.parameterizedTypeFor(Types
+            .typeForClass(InstanceIdentifier.class));
+
+    /**
+     * It is undesirable to create instance of this class.
+     */
+    private BaseYangTypes() {
+    }
+
+    static {
+        typeMap.put("boolean", BOOLEAN_TYPE);
+        typeMap.put("empty", EMPTY_TYPE);
+        typeMap.put("enumeration", ENUM_TYPE);
+        typeMap.put("int8", INT8_TYPE);
+        typeMap.put("int16", INT16_TYPE);
+        typeMap.put("int32", INT32_TYPE);
+        typeMap.put("int64", INT64_TYPE);
+        typeMap.put("string", STRING_TYPE);
+        typeMap.put("decimal64", DECIMAL64_TYPE);
+        typeMap.put("uint8", UINT8_TYPE);
+        typeMap.put("uint16", UINT16_TYPE);
+        typeMap.put("uint32", UINT32_TYPE);
+        typeMap.put("uint64", UINT64_TYPE);
+        typeMap.put("union", UNION_TYPE);
+        typeMap.put("binary", BINARY_TYPE);
+        typeMap.put("instance-identifier", INSTANCE_IDENTIFIER);
+    }
+
+    public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {
+        /**
+         * Searches <code>Type</code> value to which is YANG <code>type</code>
+         * mapped.
+         *
+         * @param type
+         *            string with YANG type name
+         * @return java <code>Type</code> representation of <code>type</code>
+         */
+        @Override
+        public Type javaTypeForYangType(String type) {
+            return typeMap.get(type);
+        }
+
+        /**
+         * Searches <code>Type</code> value to which is YANG <code>type</code>
+         * mapped.
+         *
+         * @param type
+         *            type definition representation of YANG type
+         * @return java <code>Type</code> representation of <code>type</code>.
+         *         If <code>type</code> isn't found then <code>null</code> is
+         *         returned.
+         */
+        @Override
+        public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode) {
+            if (type != null) {
+                return typeMap.get(type.getQName().getLocalName());
+            }
+
+            return null;
+        }
+
+        @Override
+        public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode,
+                Restrictions restrictions) {
+            String typeName = type.getQName().getLocalName();
+            switch (typeName) {
+            case "binary":
+                return Types.primitiveType("byte[]", restrictions);
+            case "decimal64":
+                return Types.typeForClass(BigDecimal.class, restrictions);
+            case "enumeration":
+                return Types.typeForClass(Enum.class, restrictions);
+            case "int8":
+                return Types.typeForClass(Byte.class, restrictions);
+            case "int16":
+                return Types.typeForClass(Short.class, restrictions);
+            case "int32":
+                return Types.typeForClass(Integer.class, restrictions);
+            case "int64":
+                return Types.typeForClass(Long.class, restrictions);
+            case "string":
+                return Types.typeForClass(String.class, restrictions);
+            case "uint8":
+                return Types.typeForClass(Short.class, restrictions);
+            case "uint16":
+                return Types.typeForClass(Integer.class, restrictions);
+            case "uint32":
+                return Types.typeForClass(Long.class, restrictions);
+            case "uint64":
+                return Types.typeForClass(BigInteger.class, restrictions);
+            case "union" :
+                return UNION_TYPE;
+            default:
+                return javaTypeForSchemaDefinitionType(type, parentNode);
+            }
+        }
+
+        @Override
+        public String getTypeDefaultConstruction(LeafSchemaNode node) {
+            return null;
+        }
+
+        @Override
+        public String getConstructorPropertyName(SchemaNode node) {
+            return null;
+        }
+
+        @Override
+        public String getParamNameFromType(TypeDefinition<?> type) {
+            return "_" + BindingGeneratorUtil.parseToValidParamName(type.getQName().getLocalName());
+        }
+    };
+
+    private static Restrictions singleRangeRestrictions(final Number min, final Number max) {
+        return new Restrictions() {
+            @Override
+            public boolean isEmpty() {
+                return false;
+            }
+
+            @Override
+            public List<RangeConstraint> getRangeConstraints() {
+                return Collections.singletonList(BaseConstraints.rangeConstraint(min, max, null, null));
+            }
+
+            @Override
+            public List<PatternConstraint> getPatternConstraints() {
+                return Collections.emptyList();
+            }
+
+            @Override
+            public List<LengthConstraint> getLengthConstraints() {
+                return Collections.emptyList();
+            }
+        };
+    }
+
+    public static final class UnionType implements Type {
+        @Override
+        public String getPackageName() {
+            return null;
+        }
+        @Override
+        public String getName() {
+            return "Union";
+        }
+        @Override
+        public String getFullyQualifiedName() {
+            return "Union";
+        }
+    }
+
+}
index 809503be5a46d2f3520c62852c85ae616e669d3d..85e0dc4ee62907633e5607d046b89e6ff87f27c0 100644 (file)
@@ -1,8 +1,8 @@
-/*\r
-  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
-  *\r
-  * This program and the accompanying materials are made available under the\r
-  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
-  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
-  */\r
+/*
+  * 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.yangtools.sal.binding.yang.types;
\ No newline at end of file
index a0b3554aa604e87db7051359dc19d72eac67e650..2a65150480d3a61c19c017a7a509b5d6479f2c6e 100644 (file)
  * 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.yangtools.yang.unified.doc.generator\r
-\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext\r
-import java.io.File\r
-import java.util.Set\r
-import org.opendaylight.yangtools.yang.model.api.Module\r
-import java.io.IOException\r
-import java.util.HashSet\r
-import java.io.BufferedWriter\r
-import java.io.OutputStreamWriter;\r
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode\r
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode\r
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition\r
-import org.opendaylight.yangtools.yang.model.api.SchemaNode\r
-import org.opendaylight.yangtools.yang.model.util.ExtendedType\r
-import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition\r
-import java.text.SimpleDateFormat\r
-import java.util.Collection\r
-import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint\r
-import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition\r
-import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition\r
-import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint\r
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition\r
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition\r
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition\r
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer\r
-import org.slf4j.LoggerFactory\r
-import org.slf4j.Logger\r
-import java.util.List\r
-import org.opendaylight.yangtools.yang.common.QName\r
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition\r
-import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition\r
-import java.util.ArrayList\r
-import java.util.Map\r
-import org.opendaylight.yangtools.yang.model.api.SchemaPath\r
-\r
-import org.sonatype.plexus.build.incremental.BuildContext;\r
-import org.sonatype.plexus.build.incremental.DefaultBuildContext;\r
-\r
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode\r
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode\r
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode\r
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier\r
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates\r
-import java.util.LinkedHashMap\r
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier\r
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode\r
+package org.opendaylight.yangtools.yang.unified.doc.generator
+
+import org.opendaylight.yangtools.yang.model.api.SchemaContext
+import java.io.File
+import java.util.Set
+import org.opendaylight.yangtools.yang.model.api.Module
+import java.io.IOException
+import java.util.HashSet
+import java.io.BufferedWriter
+import java.io.OutputStreamWriter;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition
+import org.opendaylight.yangtools.yang.model.api.SchemaNode
+import org.opendaylight.yangtools.yang.model.util.ExtendedType
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition
+import java.text.SimpleDateFormat
+import java.util.Collection
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint
+import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition
+import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint
+import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition
+import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
+import org.slf4j.LoggerFactory
+import org.slf4j.Logger
+import java.util.List
+import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition
+import java.util.ArrayList
+import java.util.Map
+import org.opendaylight.yangtools.yang.model.api.SchemaPath
+
+import org.sonatype.plexus.build.incremental.BuildContext;
+import org.sonatype.plexus.build.incremental.DefaultBuildContext;
+
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
+import java.util.LinkedHashMap
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode\rimport java.util.HashMap
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
 
-class GeneratorImpl {\r
-\r
-    File path\r
-    static val REVISION_FORMAT = new SimpleDateFormat("yyyy-MM-dd")\r
-    static val Logger LOG = LoggerFactory.getLogger(GeneratorImpl)\r
-    static val BuildContext CTX = new DefaultBuildContext();\r
-    var Module currentModule;\r
-\r
-\r
-    def generate(SchemaContext context, File targetPath, Set<Module> modulesToGen) throws IOException {\r
-        path = targetPath;\r
-        path.mkdirs();\r
-        val it = new HashSet;\r
-        for (module : modulesToGen) {\r
-            add(generateDocumentation(module, context));\r
-        }\r
-        return it;\r
-    }\r
-\r
-    def generateDocumentation(Module module, SchemaContext ctx) {\r
-        val destination = new File(path, '''«module.name».html''')\r
-        try {\r
-            val fw = new OutputStreamWriter(CTX.newFileOutputStream(destination))\r
-            val bw = new BufferedWriter(fw)\r
-            currentModule = module;\r
-            bw.append(generate(module, ctx));\r
-            bw.close();\r
-            fw.close();\r
-        } catch (IOException e) {\r
-            LOG.error(e.getMessage());\r
-        }\r
-        return destination;\r
-    }\r
-\r
-    def generate(Module module, SchemaContext ctx) '''\r
-        <!DOCTYPE html>\r
-        <html lang="en">\r
-          <head>\r
-            <title>«module.name»</title>\r
-          </head>\r
-          <body>\r
-            «body(module, ctx)»\r
-          </body>\r
-        </html>\r
-    '''\r
-\r
-    def body(Module module, SchemaContext ctx) '''\r
-        «header(module)»\r
-\r
-        «typeDefinitions(module)»\r
-\r
-        «identities(module)»\r
-\r
-        «groupings(module)»\r
-\r
-        «dataStore(module)»\r
-\r
-        «childNodes(module)»\r
-\r
-        «notifications(module)»\r
-\r
-        «augmentations(module, ctx)»\r
-\r
-        «rpcs(module)»\r
-\r
-        «extensions(module)»\r
-\r
-        «features(module)»\r
-\r
-    '''\r
-\r
-\r
-    def typeDefinitions(Module module) {\r
-        val Set<TypeDefinition<?>> typedefs = module.typeDefinitions\r
-        if (typedefs.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Type Definitions</h2>\r
-            <ul>\r
-            «FOR typedef : typedefs»\r
-                <li>\r
-                    «strong("typedef " + typedef.QName.localName)»\r
-                    <ul>\r
-                    «typedef.descAndRefLi»\r
-                    «typedef.restrictions»\r
-                    </ul>\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        '''\r
-    }\r
-\r
-    private def identities(Module module) {\r
-        if (module.identities.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Identities</h2>\r
-            <ul>\r
-            «FOR identity : module.identities»\r
-                <li>\r
-                    «strong("identity " + identity.QName.localName)»\r
-                    <ul>\r
-                    «identity.descAndRefLi»\r
-                    «IF identity.baseIdentity != null»\r
-                        «listItem("base", identity.baseIdentity.QName.localName)»\r
-                    «ENDIF»\r
-                    </ul>\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        '''\r
-    }\r
-\r
-    private def groupings(Module module) {\r
-        if (module.groupings.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Groupings</h2>\r
-            <ul>\r
-            «FOR grouping : module.groupings»\r
-                <li>\r
-                    «strong("grouping " + grouping.QName.localName)»\r
-                    <ul>\r
-                        «grouping.descAndRefLi»\r
-                    </ul>\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        '''\r
-    }\r
-\r
-    def dataStore(Module module) {\r
-        if (module.childNodes.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Datastore Structure</h2>\r
-            «tree(module)»\r
-        '''\r
-    }\r
-\r
-    def augmentations(Module module, SchemaContext context) {\r
-        if (module.augmentations.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Augmentations</h2>\r
-\r
-            <ul>\r
-            «FOR augment : module.augmentations»\r
-                <li>\r
-                    <h3>Target [«schemaPathAsRestconfPath(module, augment.targetPath, context)»]</h3>\r
-                    «augment.description»\r
-                    «IF augment.reference !== null»\r
-                        Reference «augment.reference»\r
-                    «ENDIF»\r
-                    «IF augment.whenCondition !== null»\r
-                        When «augment.whenCondition.toString»\r
-                    «ENDIF»\r
-                    «augment.childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        '''\r
-    }\r
-\r
-    def notifications(Module module) {\r
-        val Set<NotificationDefinition> notificationdefs = module.notifications\r
-        if (notificationdefs.empty) {\r
-            return '';\r
-        }\r
-\r
-        return '''\r
-            <h2>Notifications</h2>\r
-            «FOR notificationdef : notificationdefs»\r
-\r
-                <h3>«notificationdef.nodeName»</h3>\r
-                    «notificationdef.descAndRef»\r
-                    «notificationdef.childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»\r
-            «ENDFOR»\r
-        '''\r
-    }\r
-\r
-    def rpcs(Module module) {\r
-        if (module.rpcs.empty) {\r
-            return '';\r
-        }\r
-\r
-        return '''\r
-            <h2>RPC Definitions</h2>\r
-            «FOR rpc : module.rpcs»\r
-                <h3>«rpc.nodeName»</h3>\r
-                    «rpc.rpcInfo(InstanceIdentifier.builder().node(rpc.QName).toInstance())»\r
-            «ENDFOR»\r
-            </ul>\r
-        '''\r
-    }\r
-\r
-    def extensions(Module module) {\r
-        if (module.extensionSchemaNodes.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Extensions</h2>\r
-            «FOR ext : module.extensionSchemaNodes»\r
-                <li>\r
-                    <h3>«ext.nodeName»</h3>\r
-                </li>\r
-                «extensionInfo(ext)»\r
-            «ENDFOR»\r
-        '''\r
-    }\r
-\r
-    def features(Module module) {\r
-        if (module.features.empty) {\r
-            return '';\r
-        }\r
-        return '''\r
-            <h2>Features</h2>\r
-\r
-            <ul>\r
-            «FOR feature : module.features»\r
-                <li>\r
-                    «strong("feature " + feature.QName.localName)»\r
-                    <ul>\r
-                        «feature.descAndRefLi»\r
-                    </ul>\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        '''\r
-    }\r
-\r
-    def header(Module module) '''\r
-        <h1>«module.name»</h1>\r
-\r
-        <h2>Base Information</h2>\r
-        <dl>\r
-            <dt>Prefix</dt>\r
-            <dd>«pre(module.prefix)»</dd>\r
-            <dt>Namespace</dt>\r
-            <dd>«pre(module.namespace.toString)»</dd>\r
-            <dt>Revision</dt>\r
-            <dd>«pre(REVISION_FORMAT.format(module.revision))»</dd>\r
-\r
-            «FOR imp : module.imports BEFORE "<dt>Imports</dt>" »\r
-                <dd>«code(imp.prefix)» = «code(imp.moduleName)»</dd>\r
-            «ENDFOR»\r
-        </dl>\r
-    '''\r
-\r
-    def code(String string) '''<code>«string»</code>'''\r
-\r
-    def process(Module module) {\r
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")\r
-    }\r
-\r
-    def CharSequence tree(Module module) '''\r
-        «strong("module " + module.name)»\r
-        «module.childNodes.treeSet(InstanceIdentifier.builder.toInstance())»\r
-    '''\r
-\r
-    private def dispatch CharSequence tree(ChoiceNode node,InstanceIdentifier path) '''\r
-        «node.nodeName» (choice)\r
-        «casesTree(node.cases,path)»\r
-    '''\r
-\r
-    def casesTree(Set<ChoiceCaseNode> nodes,InstanceIdentifier path) '''\r
-        <ul>\r
-        «FOR node : nodes»\r
-            <li>\r
-            «node.nodeName»\r
-            «node.childNodes.treeSet(path)»\r
-            </li>\r
-        «ENDFOR»\r
-        </ul>\r
-    '''\r
-\r
-    private def dispatch CharSequence tree(DataSchemaNode node,InstanceIdentifier path) '''\r
-        «node.nodeName»\r
-    '''\r
-\r
-    private def dispatch CharSequence tree(ListSchemaNode node,InstanceIdentifier path) '''\r
-        «val newPath = path.append(node)»\r
-        «localLink(newPath,node.nodeName)»\r
-        «node.childNodes.treeSet(newPath)»\r
-    '''\r
-\r
-    private def dispatch CharSequence tree(ContainerSchemaNode node,InstanceIdentifier path) '''\r
-        «val newPath = path.append(node)»\r
-        «localLink(newPath,node.nodeName)»\r
-        «node.childNodes.treeSet(newPath)»\r
-    '''\r
-\r
-    def CharSequence childNodes(Module module) '''\r
-        «val childNodes = module.childNodes»\r
-        «IF childNodes !== null && !childNodes.empty»\r
-            <h2>Child nodes</h2>\r
-\r
-            «childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»\r
-        «ENDIF»\r
-    '''\r
-\r
-    def CharSequence printChildren(Set<DataSchemaNode> nodes, int level, InstanceIdentifier path) {\r
-    val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)\r
-    val leafNodes = nodes.filter(LeafSchemaNode)\r
-    val leafListNodes = nodes.filter(LeafListSchemaNode)\r
-    val choices = nodes.filter(ChoiceNode)\r
-    val cases = nodes.filter(ChoiceCaseNode)\r
-    val containers = nodes.filter(ContainerSchemaNode)\r
-    val lists = nodes.filter(ListSchemaNode)\r
-    return '''\r
-        «IF ((anyxmlNodes.size + leafNodes.size + leafListNodes.size + containers.size + lists.size) > 0)»\r
-        <h3>Direct children</h3>\r
-        <ul>\r
-        «FOR childNode : anyxmlNodes»\r
-            «childNode.printShortInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : leafNodes»\r
-            «childNode.printShortInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : leafListNodes»\r
-            «childNode.printShortInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : containers»\r
-            «childNode.printShortInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : lists»\r
-            «childNode.printShortInfo(level,path)»\r
-        «ENDFOR»\r
-        </ul>\r
-        «ENDIF»\r
-\r
-        «IF !path.path.empty»\r
-        <h3>XML example</h3>\r
-        «nodes.xmlExample(path.path.last.nodeType,path)»\r
-        </h3>\r
-        «ENDIF»\r
-        «FOR childNode : containers»\r
-            «childNode.printInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : lists»\r
-            «childNode.printInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : choices»\r
-            «childNode.printInfo(level,path)»\r
-        «ENDFOR»\r
-        «FOR childNode : cases»\r
-            «childNode.printInfo(level,path)»\r
-        «ENDFOR»\r
-        \r
-    '''\r
-    }\r
-\r
-    def CharSequence xmlExample(Set<DataSchemaNode> nodes, QName name,InstanceIdentifier path) '''\r
-    <pre>\r
-        «xmlExampleTag(name,nodes.xmplExampleTags(path))»\r
-    </pre>\r
-    '''\r
-\r
-    def CharSequence xmplExampleTags(Set<DataSchemaNode> nodes, InstanceIdentifier identifier) '''\r
-        <!-- Child nodes -->\r
-        «FOR node : nodes»\r
-        <!-- «node.QName.localName» -->\r
-            «node.asXmlExampleTag(identifier)»\r
-        «ENDFOR»\r
-\r
-    '''\r
-\r
-    private def dispatch CharSequence asXmlExampleTag(LeafSchemaNode node, InstanceIdentifier identifier) '''\r
-        «node.QName.xmlExampleTag("...")»\r
-    '''\r
-\r
-    private def dispatch CharSequence asXmlExampleTag(LeafListSchemaNode node, InstanceIdentifier identifier) '''\r
-        &lt!-- This node could appear multiple times --&gt\r
-        «node.QName.xmlExampleTag("...")»\r
-    '''\r
-\r
-    private def dispatch CharSequence asXmlExampleTag(ContainerSchemaNode node, InstanceIdentifier identifier) '''\r
-        &lt!-- See «localLink(identifier.append(node),"definition")» for child nodes.  --&gt\r
-        «node.QName.xmlExampleTag("...")»\r
-    '''\r
-\r
-\r
-    private def dispatch CharSequence asXmlExampleTag(ListSchemaNode node, InstanceIdentifier identifier) '''\r
-        &lt!-- See «localLink(identifier.append(node),"definition")» for child nodes.  --&gt\r
-        &lt!-- This node could appear multiple times --&gt\r
-        «node.QName.xmlExampleTag("...")»\r
-    '''\r
-\r
-\r
-    private def dispatch CharSequence asXmlExampleTag(DataSchemaNode node, InstanceIdentifier identifier) '''\r
-        <!-- noop -->\r
-    '''\r
-\r
-\r
-    def xmlExampleTag(QName name, CharSequence data) {\r
-        return '''&lt;«name.localName» xmlns="«name.namespace»"&gt;«data»&lt;/«name.localName»&gt;'''\r
-    }\r
-\r
-    def header(int level,QName name) '''<h«level»>«name.localName»</h«level»>'''\r
-\r
-\r
-    def header(int level,InstanceIdentifier name) '''\r
-        <h«level» id="«FOR cmp : name.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»">\r
-            «FOR cmp : name.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»\r
-        </h«level»>\r
-    '''\r
-\r
-\r
-\r
-    private def dispatch CharSequence printInfo(DataSchemaNode node, int level, InstanceIdentifier path) '''\r
-        «header(level+1,node.QName)»\r
-    '''\r
-\r
-    private def dispatch CharSequence printInfo(ContainerSchemaNode node, int level, InstanceIdentifier path) '''\r
-        «val newPath = path.append(node)»\r
-        «header(level,newPath)»\r
-        <dl>\r
-          <dt>XML Path</dt>\r
-          <dd>«newPath.asXmlPath»</dd>\r
-          <dt>Restconf path</dt>\r
-          <dd>«code(newPath.asRestconfPath)»</dd>\r
-        </dl>\r
-        «node.childNodes.printChildren(level,newPath)»\r
-    '''\r
-\r
-    private def dispatch CharSequence printInfo(ListSchemaNode node, int level, InstanceIdentifier path) '''\r
-        «val newPath = path.append(node)»\r
-        «header(level,newPath)»\r
-        <dl>\r
-          <dt>XML Path</dt>\r
-          <dd>«newPath.asXmlPath»</dd>\r
-          <dt>Restconf path</dt>\r
-          <dd>«code(newPath.asRestconfPath)»</dd>\r
-        </dl>\r
-        «node.childNodes.printChildren(level,newPath)»\r
-    '''\r
-\r
-    private def dispatch CharSequence printInfo(ChoiceNode node, int level, InstanceIdentifier path) '''\r
-        «val Set<DataSchemaNode> choiceCases = new HashSet(node.cases)»\r
-        «choiceCases.printChildren(level,path)»\r
-    '''\r
-\r
-    private def dispatch CharSequence printInfo(ChoiceCaseNode node, int level, InstanceIdentifier path) '''\r
-        «node.childNodes.printChildren(level,path)»\r
-    '''\r
-\r
-\r
-\r
-    def CharSequence printShortInfo(ContainerSchemaNode node, int level, InstanceIdentifier path) {\r
-        val newPath = path.append(node);\r
-        return '''\r
-            <li>«strong(localLink(newPath,node.QName.localName))» (container)</li>\r
-        '''\r
-    }\r
-\r
-    def CharSequence printShortInfo(ListSchemaNode node, int level, InstanceIdentifier path) {\r
-        val newPath = path.append(node);\r
-        return '''\r
-            <li>«strong(localLink(newPath,node.QName.localName))» (list)</li>\r
-        '''\r
-    }\r
-\r
-    def CharSequence printShortInfo(AnyXmlSchemaNode node, int level, InstanceIdentifier path) {\r
-        return '''\r
-            <li>«strong((node.QName.localName))» (anyxml)</li>\r
-        '''\r
-    }\r
-\r
-    def CharSequence printShortInfo(LeafSchemaNode node, int level, InstanceIdentifier path) {\r
-        return '''\r
-            <li>«strong((node.QName.localName))» (leaf)</li>\r
-        '''\r
-    }\r
-\r
-    def CharSequence printShortInfo(LeafListSchemaNode node, int level, InstanceIdentifier path) {\r
-        return '''\r
-            <li>«strong((node.QName.localName))» (leaf-list)</li>\r
-        '''\r
-    }\r
-\r
-    def CharSequence localLink(InstanceIdentifier identifier, CharSequence text) '''\r
-        <a href="#«FOR cmp : identifier.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»">«text»</a>\r
-    '''\r
-\r
-\r
-    private def dispatch InstanceIdentifier append(InstanceIdentifier identifier, ContainerSchemaNode node) {\r
-        val pathArguments = new ArrayList(identifier.path)\r
-        pathArguments.add(new NodeIdentifier(node.QName));\r
-        return new InstanceIdentifier(pathArguments);\r
-    }\r
-\r
-    private def dispatch InstanceIdentifier append(InstanceIdentifier identifier, ListSchemaNode node) {\r
-        val pathArguments = new ArrayList(identifier.path)\r
-        val keyValues = new LinkedHashMap<QName,Object>();\r
-        if(node.keyDefinition != null) {\r
-            for(definition : node.keyDefinition) {\r
-                keyValues.put(definition,new Object);\r
-            }\r
-        }\r
-        pathArguments.add(new NodeIdentifierWithPredicates(node.QName,keyValues));\r
-        return new InstanceIdentifier(pathArguments);\r
-    }\r
-\r
-\r
-    def asXmlPath(InstanceIdentifier identifier) {\r
-        return "";\r
-    }\r
-\r
-    def asRestconfPath(InstanceIdentifier identifier) {\r
-        val it = new StringBuilder();\r
-        append(currentModule.name)\r
-        append(":")\r
-        var previous = false;\r
-        for(arg : identifier.path) {\r
-            if(previous) append("/")\r
-            append(arg.nodeType.localName);\r
-            previous = true;\r
-            if(arg instanceof NodeIdentifierWithPredicates) {\r
-                val nodeIdentifier = arg as NodeIdentifierWithPredicates;\r
-                for(qname : nodeIdentifier.keyValues.keySet) {\r
-                    append("/{");\r
-                    append(qname.localName)\r
-                    append("}")\r
-                }\r
-            }\r
-        }\r
-\r
-        return it.toString;\r
-    }\r
-\r
-    private def String schemaPathAsRestconfPath(Module module, SchemaPath schemaPath, SchemaContext ctx) {\r
-        val Map<String, String> imports = new HashMap();\r
-        for (mImport : module.imports) {\r
-            imports.put(mImport.prefix, mImport.moduleName)\r
-        }\r
-\r
-        val List<QName> path = schemaPath.path\r
-        val StringBuilder pathString = new StringBuilder()\r
-        if (schemaPath.absolute) {\r
-            pathString.append("/")\r
-        }\r
-\r
-        val QName qname = path.get(0)\r
-        var Object parent = ctx.findModuleByNamespaceAndRevision(qname.namespace, qname.revision)\r
-\r
-        for (name : path) {\r
-            if (parent instanceof DataNodeContainer) {\r
-                var SchemaNode node = (parent as DataNodeContainer).getDataChildByName(name)\r
-                if (node == null && (parent instanceof Module)) {\r
-                    val notifications = (parent as Module).notifications;\r
-                    for (notification : notifications) {\r
-                        if (notification.QName.equals(name)) {\r
-                            node = notification\r
-                        }\r
-                    }\r
-                }\r
+class GeneratorImpl {
+
+    File path
+    static val REVISION_FORMAT = new SimpleDateFormat("yyyy-MM-dd")
+    static val Logger LOG = LoggerFactory.getLogger(GeneratorImpl)
+    static val BuildContext CTX = new DefaultBuildContext();
+    var Module currentModule;
+
+
+    def generate(SchemaContext context, File targetPath, Set<Module> modulesToGen) throws IOException {
+        path = targetPath;
+        path.mkdirs();
+        val it = new HashSet;
+        for (module : modulesToGen) {
+            add(generateDocumentation(module, context));
+        }
+        return it;
+    }
+
+    def generateDocumentation(Module module, SchemaContext ctx) {
+        val destination = new File(path, '''«module.name».html''')
+        try {
+            val fw = new OutputStreamWriter(CTX.newFileOutputStream(destination))
+            val bw = new BufferedWriter(fw)
+            currentModule = module;
+            bw.append(generate(module, ctx));
+            bw.close();
+            fw.close();
+        } catch (IOException e) {
+            LOG.error(e.getMessage());
+        }
+        return destination;
+    }
+
+    def generate(Module module, SchemaContext ctx) '''
+        <!DOCTYPE html>
+        <html lang="en">
+          <head>
+            <title>«module.name»</title>
+          </head>
+          <body>
+            «body(module, ctx)»
+          </body>
+        </html>
+    '''
+
+    def body(Module module, SchemaContext ctx) '''
+        «header(module)»
+
+        «typeDefinitions(module)»
+
+        «identities(module)»
+
+        «groupings(module)»
+
+        «dataStore(module)»
+
+        «childNodes(module)»
+
+        «notifications(module)»
+
+        «augmentations(module, ctx)»
+
+        «rpcs(module)»
+
+        «extensions(module)»
+
+        «features(module)»
+
+    '''
+
+
+    def typeDefinitions(Module module) {
+        val Set<TypeDefinition<?>> typedefs = module.typeDefinitions
+        if (typedefs.empty) {
+            return '';
+        }
+        return '''
+            <h2>Type Definitions</h2>
+            <ul>
+            «FOR typedef : typedefs»
+                <li>
+                    «strong("typedef " + typedef.QName.localName)»
+                    <ul>
+                    «typedef.descAndRefLi»
+                    «typedef.restrictions»
+                    </ul>
+                </li>
+            «ENDFOR»
+            </ul>
+        '''
+    }
+
+    private def identities(Module module) {
+        if (module.identities.empty) {
+            return '';
+        }
+        return '''
+            <h2>Identities</h2>
+            <ul>
+            «FOR identity : module.identities»
+                <li>
+                    «strong("identity " + identity.QName.localName)»
+                    <ul>
+                    «identity.descAndRefLi»
+                    «IF identity.baseIdentity != null»
+                        «listItem("base", identity.baseIdentity.QName.localName)»
+                    «ENDIF»
+                    </ul>
+                </li>
+            «ENDFOR»
+            </ul>
+        '''
+    }
+
+    private def groupings(Module module) {
+        if (module.groupings.empty) {
+            return '';
+        }
+        return '''
+            <h2>Groupings</h2>
+            <ul>
+            «FOR grouping : module.groupings»
+                <li>
+                    «strong("grouping " + grouping.QName.localName)»
+                    <ul>
+                        «grouping.descAndRefLi»
+                    </ul>
+                </li>
+            «ENDFOR»
+            </ul>
+        '''
+    }
+
+    def dataStore(Module module) {
+        if (module.childNodes.empty) {
+            return '';
+        }
+        return '''
+            <h2>Datastore Structure</h2>
+            «tree(module)»
+        '''
+    }
+
+    def augmentations(Module module, SchemaContext context) {
+        if (module.augmentations.empty) {
+            return '';
+        }
+        return '''
+            <h2>Augmentations</h2>
+
+            <ul>
+            «FOR augment : module.augmentations»
+                <li>
+                    <h3>Target [«schemaPathAsRestconfPath(module, augment.targetPath, context)»]</h3>
+                    «augment.description»
+                    «IF augment.reference !== null»
+                        Reference «augment.reference»
+                    «ENDIF»
+                    «IF augment.whenCondition !== null»
+                        When «augment.whenCondition.toString»
+                    «ENDIF»
+                    «augment.childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»
+                </li>
+            «ENDFOR»
+            </ul>
+        '''
+    }
+
+    def notifications(Module module) {
+        val Set<NotificationDefinition> notificationdefs = module.notifications
+        if (notificationdefs.empty) {
+            return '';
+        }
+
+        return '''
+            <h2>Notifications</h2>
+            «FOR notificationdef : notificationdefs»
+
+                <h3>«notificationdef.nodeName»</h3>
+                    «notificationdef.descAndRef»
+                    «notificationdef.childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»
+            «ENDFOR»
+        '''
+    }
+
+    def rpcs(Module module) {
+        if (module.rpcs.empty) {
+            return '';
+        }
+
+        return '''
+            <h2>RPC Definitions</h2>
+            «FOR rpc : module.rpcs»
+                <h3>«rpc.nodeName»</h3>
+                    «rpc.rpcInfo(InstanceIdentifier.builder().node(rpc.QName).toInstance())»
+            «ENDFOR»
+            </ul>
+        '''
+    }
+
+    def extensions(Module module) {
+        if (module.extensionSchemaNodes.empty) {
+            return '';
+        }
+        return '''
+            <h2>Extensions</h2>
+            «FOR ext : module.extensionSchemaNodes»
+                <li>
+                    <h3>«ext.nodeName»</h3>
+                </li>
+                «extensionInfo(ext)»
+            «ENDFOR»
+        '''
+    }
+
+    def features(Module module) {
+        if (module.features.empty) {
+            return '';
+        }
+        return '''
+            <h2>Features</h2>
+
+            <ul>
+            «FOR feature : module.features»
+                <li>
+                    «strong("feature " + feature.QName.localName)»
+                    <ul>
+                        «feature.descAndRefLi»
+                    </ul>
+                </li>
+            «ENDFOR»
+            </ul>
+        '''
+    }
+
+    def header(Module module) '''
+        <h1>«module.name»</h1>
+
+        <h2>Base Information</h2>
+        <dl>
+            <dt>Prefix</dt>
+            <dd>«pre(module.prefix)»</dd>
+            <dt>Namespace</dt>
+            <dd>«pre(module.namespace.toString)»</dd>
+            <dt>Revision</dt>
+            <dd>«pre(REVISION_FORMAT.format(module.revision))»</dd>
+
+            «FOR imp : module.imports BEFORE "<dt>Imports</dt>" »
+                <dd>«code(imp.prefix)» = «code(imp.moduleName)»</dd>
+            «ENDFOR»
+        </dl>
+    '''
+
+    def code(String string) '''<code>«string»</code>'''
+
+    def process(Module module) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    def CharSequence tree(Module module) '''
+        «strong("module " + module.name)»
+        «module.childNodes.treeSet(InstanceIdentifier.builder.toInstance())»
+    '''
+
+    private def dispatch CharSequence tree(ChoiceNode node,InstanceIdentifier path) '''
+        «node.nodeName» (choice)
+        «casesTree(node.cases,path)»
+    '''
+
+    def casesTree(Set<ChoiceCaseNode> nodes,InstanceIdentifier path) '''
+        <ul>
+        «FOR node : nodes»
+            <li>
+            «node.nodeName»
+            «node.childNodes.treeSet(path)»
+            </li>
+        «ENDFOR»
+        </ul>
+    '''
+
+    private def dispatch CharSequence tree(DataSchemaNode node,InstanceIdentifier path) '''
+        «node.nodeName»
+    '''
+
+    private def dispatch CharSequence tree(ListSchemaNode node,InstanceIdentifier path) '''
+        «val newPath = path.append(node)»
+        «localLink(newPath,node.nodeName)»
+        «node.childNodes.treeSet(newPath)»
+    '''
+
+    private def dispatch CharSequence tree(ContainerSchemaNode node,InstanceIdentifier path) '''
+        «val newPath = path.append(node)»
+        «localLink(newPath,node.nodeName)»
+        «node.childNodes.treeSet(newPath)»
+    '''
+
+    def CharSequence childNodes(Module module) '''
+        «val childNodes = module.childNodes»
+        «IF childNodes !== null && !childNodes.empty»
+            <h2>Child nodes</h2>
+
+            «childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»
+        «ENDIF»
+    '''
+
+    def CharSequence printChildren(Set<DataSchemaNode> nodes, int level, InstanceIdentifier path) {
+    val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)
+    val leafNodes = nodes.filter(LeafSchemaNode)
+    val leafListNodes = nodes.filter(LeafListSchemaNode)
+    val choices = nodes.filter(ChoiceNode)
+    val cases = nodes.filter(ChoiceCaseNode)
+    val containers = nodes.filter(ContainerSchemaNode)
+    val lists = nodes.filter(ListSchemaNode)
+    return '''
+        «IF ((anyxmlNodes.size + leafNodes.size + leafListNodes.size + containers.size + lists.size) > 0)»
+        <h3>Direct children</h3>
+        <ul>
+        «FOR childNode : anyxmlNodes»
+            «childNode.printShortInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : leafNodes»
+            «childNode.printShortInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : leafListNodes»
+            «childNode.printShortInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : containers»
+            «childNode.printShortInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : lists»
+            «childNode.printShortInfo(level,path)»
+        «ENDFOR»
+        </ul>
+        «ENDIF»
+
+        «IF !path.path.empty»
+        <h3>XML example</h3>
+        «nodes.xmlExample(path.path.last.nodeType,path)»
+        </h3>
+        «ENDIF»
+        «FOR childNode : containers»
+            «childNode.printInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : lists»
+            «childNode.printInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : choices»
+            «childNode.printInfo(level,path)»
+        «ENDFOR»
+        «FOR childNode : cases»
+            «childNode.printInfo(level,path)»
+        «ENDFOR»
+        
+    '''
+    }
+
+    def CharSequence xmlExample(Set<DataSchemaNode> nodes, QName name,InstanceIdentifier path) '''
+    <pre>
+        «xmlExampleTag(name,nodes.xmplExampleTags(path))»
+    </pre>
+    '''
+
+    def CharSequence xmplExampleTags(Set<DataSchemaNode> nodes, InstanceIdentifier identifier) '''
+        <!-- Child nodes -->
+        «FOR node : nodes»
+        <!-- «node.QName.localName» -->
+            «node.asXmlExampleTag(identifier)»
+        «ENDFOR»
+
+    '''
+
+    private def dispatch CharSequence asXmlExampleTag(LeafSchemaNode node, InstanceIdentifier identifier) '''
+        «node.QName.xmlExampleTag("...")»
+    '''
+
+    private def dispatch CharSequence asXmlExampleTag(LeafListSchemaNode node, InstanceIdentifier identifier) '''
+        &lt!-- This node could appear multiple times --&gt
+        «node.QName.xmlExampleTag("...")»
+    '''
+
+    private def dispatch CharSequence asXmlExampleTag(ContainerSchemaNode node, InstanceIdentifier identifier) '''
+        &lt!-- See «localLink(identifier.append(node),"definition")» for child nodes.  --&gt
+        «node.QName.xmlExampleTag("...")»
+    '''
+
+
+    private def dispatch CharSequence asXmlExampleTag(ListSchemaNode node, InstanceIdentifier identifier) '''
+        &lt!-- See «localLink(identifier.append(node),"definition")» for child nodes.  --&gt
+        &lt!-- This node could appear multiple times --&gt
+        «node.QName.xmlExampleTag("...")»
+    '''
+
+
+    private def dispatch CharSequence asXmlExampleTag(DataSchemaNode node, InstanceIdentifier identifier) '''
+        <!-- noop -->
+    '''
+
+
+    def xmlExampleTag(QName name, CharSequence data) {
+        return '''&lt;«name.localName» xmlns="«name.namespace»"&gt;«data»&lt;/«name.localName»&gt;'''
+    }
+
+    def header(int level,QName name) '''<h«level»>«name.localName»</h«level»>'''
+
+
+    def header(int level,InstanceIdentifier name) '''
+        <h«level» id="«FOR cmp : name.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»">
+            «FOR cmp : name.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»
+        </h«level»>
+    '''
+
+
+
+    private def dispatch CharSequence printInfo(DataSchemaNode node, int level, InstanceIdentifier path) '''
+        «header(level+1,node.QName)»
+    '''
+
+    private def dispatch CharSequence printInfo(ContainerSchemaNode node, int level, InstanceIdentifier path) '''
+        «val newPath = path.append(node)»
+        «header(level,newPath)»
+        <dl>
+          <dt>XML Path</dt>
+          <dd>«newPath.asXmlPath»</dd>
+          <dt>Restconf path</dt>
+          <dd>«code(newPath.asRestconfPath)»</dd>
+        </dl>
+        «node.childNodes.printChildren(level,newPath)»
+    '''
+
+    private def dispatch CharSequence printInfo(ListSchemaNode node, int level, InstanceIdentifier path) '''
+        «val newPath = path.append(node)»
+        «header(level,newPath)»
+        <dl>
+          <dt>XML Path</dt>
+          <dd>«newPath.asXmlPath»</dd>
+          <dt>Restconf path</dt>
+          <dd>«code(newPath.asRestconfPath)»</dd>
+        </dl>
+        «node.childNodes.printChildren(level,newPath)»
+    '''
+
+    private def dispatch CharSequence printInfo(ChoiceNode node, int level, InstanceIdentifier path) '''
+        «val Set<DataSchemaNode> choiceCases = new HashSet(node.cases)»
+        «choiceCases.printChildren(level,path)»
+    '''
+
+    private def dispatch CharSequence printInfo(ChoiceCaseNode node, int level, InstanceIdentifier path) '''
+        «node.childNodes.printChildren(level,path)»
+    '''
+
+
+
+    def CharSequence printShortInfo(ContainerSchemaNode node, int level, InstanceIdentifier path) {
+        val newPath = path.append(node);
+        return '''
+            <li>«strong(localLink(newPath,node.QName.localName))» (container)</li>
+        '''
+    }
+
+    def CharSequence printShortInfo(ListSchemaNode node, int level, InstanceIdentifier path) {
+        val newPath = path.append(node);
+        return '''
+            <li>«strong(localLink(newPath,node.QName.localName))» (list)</li>
+        '''
+    }
+
+    def CharSequence printShortInfo(AnyXmlSchemaNode node, int level, InstanceIdentifier path) {
+        return '''
+            <li>«strong((node.QName.localName))» (anyxml)</li>
+        '''
+    }
+
+    def CharSequence printShortInfo(LeafSchemaNode node, int level, InstanceIdentifier path) {
+        return '''
+            <li>«strong((node.QName.localName))» (leaf)</li>
+        '''
+    }
+
+    def CharSequence printShortInfo(LeafListSchemaNode node, int level, InstanceIdentifier path) {
+        return '''
+            <li>«strong((node.QName.localName))» (leaf-list)</li>
+        '''
+    }
+
+    def CharSequence localLink(InstanceIdentifier identifier, CharSequence text) '''
+        <a href="#«FOR cmp : identifier.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»">«text»</a>
+    '''
+
+
+    private def dispatch InstanceIdentifier append(InstanceIdentifier identifier, ContainerSchemaNode node) {
+        val pathArguments = new ArrayList(identifier.path)
+        pathArguments.add(new NodeIdentifier(node.QName));
+        return new InstanceIdentifier(pathArguments);
+    }
+
+    private def dispatch InstanceIdentifier append(InstanceIdentifier identifier, ListSchemaNode node) {
+        val pathArguments = new ArrayList(identifier.path)
+        val keyValues = new LinkedHashMap<QName,Object>();
+        if(node.keyDefinition != null) {
+            for(definition : node.keyDefinition) {
+                keyValues.put(definition,new Object);
+            }
+        }
+        pathArguments.add(new NodeIdentifierWithPredicates(node.QName,keyValues));
+        return new InstanceIdentifier(pathArguments);
+    }
+
+
+    def asXmlPath(InstanceIdentifier identifier) {
+        return "";
+    }
+
+    def asRestconfPath(InstanceIdentifier identifier) {
+        val it = new StringBuilder();
+        append(currentModule.name)
+        append(":")
+        var previous = false;
+        for(arg : identifier.path) {
+            if(previous) append("/")
+            append(arg.nodeType.localName);
+            previous = true;
+            if(arg instanceof NodeIdentifierWithPredicates) {
+                val nodeIdentifier = arg as NodeIdentifierWithPredicates;
+                for(qname : nodeIdentifier.keyValues.keySet) {
+                    append("/{");
+                    append(qname.localName)
+                    append("}")
+                }
+            }
+        }
+
+        return it.toString;
+    }
+
+    private def String schemaPathAsRestconfPath(Module module, SchemaPath schemaPath, SchemaContext ctx) {
+        val Map<String, String> imports = new HashMap();
+        for (mImport : module.imports) {
+            imports.put(mImport.prefix, mImport.moduleName)
+        }
+
+        val List<QName> path = schemaPath.path
+        val StringBuilder pathString = new StringBuilder()
+        if (schemaPath.absolute) {
+            pathString.append("/")
+        }
+
+        val QName qname = path.get(0)
+        var Object parent = ctx.findModuleByNamespaceAndRevision(qname.namespace, qname.revision)
+
+        for (name : path) {
+            if (parent instanceof DataNodeContainer) {
+                var SchemaNode node = (parent as DataNodeContainer).getDataChildByName(name)
+                if (node == null && (parent instanceof Module)) {
+                    val notifications = (parent as Module).notifications;
+                    for (notification : notifications) {
+                        if (notification.QName.equals(name)) {
+                            node = notification
+                        }
+                    }
+                }
                 if (node == null && (parent instanceof Module)) {
                     val rpcs = (parent as Module).rpcs;
                     for (rpc : rpcs) {
@@ -624,284 +624,284 @@ class GeneratorImpl {
                         }
                     }
                 }
-\r
-                if (!(node instanceof ChoiceNode) && !(node instanceof ChoiceCaseNode)) {\r
-                    var String prefix = name.prefix\r
-                    var String moduleName\r
-                    if (prefix == null || "".equals(prefix) || prefix.equals(module.prefix)) {\r
-                        moduleName = module.name\r
-                    } else {\r
-                        moduleName = imports.get(prefix)\r
-                    }\r
-                    pathString.append(moduleName)\r
-                    pathString.append(":")\r
-                    pathString.append(name.localName)\r
-                    pathString.append("/")\r
-                }\r
-                parent = node\r
-            } else if (parent instanceof ChoiceNode) {\r
-                parent = (parent as ChoiceNode).getCaseNodeByName(qname.localName)\r
-            }\r
-        }\r
-        return pathString.toString;\r
-    }\r
-\r
-\r
-    def CharSequence childNodesInfoTree(Map<SchemaPath, DataSchemaNode> childNodes) '''\r
-        «IF childNodes !== null && !childNodes.empty»\r
-            «FOR child : childNodes.values»\r
-                «childInfo(child, childNodes)»\r
-            «ENDFOR»\r
-        «ENDIF»\r
-    '''\r
-\r
-    def CharSequence childInfo(DataSchemaNode node, Map<SchemaPath, DataSchemaNode> childNodes) '''\r
-        «val String path = nodeSchemaPathToPath(node, childNodes)»\r
-        «IF path != null»\r
-            «code(path)»\r
-                «IF node !== null»\r
-                <ul>\r
-                «node.descAndRefLi»\r
-                </ul>\r
-            «ENDIF»\r
-        «ENDIF»\r
-    '''\r
-\r
-    private def CharSequence treeSet(Collection<DataSchemaNode> childNodes, InstanceIdentifier path) '''\r
-        «IF childNodes !== null && !childNodes.empty»\r
-            <ul>\r
-            «FOR child : childNodes»\r
-                <li>\r
-                    «child.tree(path)»\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        «ENDIF»\r
-    '''\r
-\r
-    def listKeys(ListSchemaNode node) '''\r
-        [«FOR key : node.keyDefinition SEPARATOR " "»«key.localName»«ENDFOR»]\r
-    '''\r
-\r
-    private def CharSequence rpcInfo(RpcDefinition rpc,InstanceIdentifier path) '''\r
-        <ul>\r
-            «rpc.descAndRefLi»\r
-            <li>\r
-                «rpc.input.tree(path)»\r
-            </li>\r
-            <li>\r
-                «rpc.output.tree(path)»\r
-            </li>\r
-        </ul>\r
-    '''\r
-\r
-    private def CharSequence extensionInfo(ExtensionDefinition ext) '''\r
-        <ul>\r
-            «ext.descAndRefLi»\r
-            «listItem("Argument", ext.argument)»\r
-        </ul>\r
-    '''\r
-\r
-    private def dispatch CharSequence tree(Void obj, InstanceIdentifier path) '''\r
-    '''\r
-\r
-\r
-\r
-    /* #################### RESTRICTIONS #################### */\r
-    private def restrictions(TypeDefinition<?> type) '''\r
-        «type.toLength»\r
-        «type.toRange»\r
-    '''\r
-\r
-    private def dispatch toLength(TypeDefinition<?> type) {\r
-    }\r
-\r
-    private def dispatch toLength(BinaryTypeDefinition type) '''\r
-        «type.lengthConstraints.toLengthStmt»\r
-    '''\r
-\r
-    private def dispatch toLength(StringTypeDefinition type) '''\r
-        «type.lengthConstraints.toLengthStmt»\r
-    '''\r
-\r
-    private def dispatch toLength(ExtendedType type) '''\r
-        «type.lengthConstraints.toLengthStmt»\r
-    '''\r
-\r
-    private def dispatch toRange(TypeDefinition<?> type) {\r
-    }\r
-\r
-    private def dispatch toRange(DecimalTypeDefinition type) '''\r
-        «type.rangeConstraints.toRangeStmt»\r
-    '''\r
-\r
-    private def dispatch toRange(IntegerTypeDefinition type) '''\r
-        «type.rangeConstraints.toRangeStmt»\r
-    '''\r
-\r
-    private def dispatch toRange(UnsignedIntegerTypeDefinition type) '''\r
-        «type.rangeConstraints.toRangeStmt»\r
-    '''\r
-\r
-    private def dispatch toRange(ExtendedType type) '''\r
-        «type.rangeConstraints.toRangeStmt»\r
-    '''\r
-\r
-    def toLengthStmt(Collection<LengthConstraint> lengths) '''\r
-        «IF lengths != null && !lengths.empty»\r
-            «listItem("Length restrictions")»\r
-            <ul>\r
-            «FOR length : lengths»\r
-                <li>\r
-                «IF length.min == length.max»\r
-                    «length.min»\r
-                «ELSE»\r
-                    &lt;«length.min», «length.max»&gt;\r
-                «ENDIF»\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        «ENDIF»\r
-    '''\r
-\r
-    def toRangeStmt(Collection<RangeConstraint> ranges) '''\r
-        «IF ranges != null && !ranges.empty»\r
-            «listItem("Range restrictions")»\r
-            <ul>\r
-            «FOR range : ranges»\r
-                <li>\r
-                «IF range.min == range.max»\r
-                    «range.min»\r
-                «ELSE»\r
-                    &lt;«range.min», «range.max»&gt;\r
-                «ENDIF»\r
-                </li>\r
-            «ENDFOR»\r
-            </ul>\r
-        «ENDIF»\r
-    '''\r
-\r
-\r
-\r
-    /* #################### UTILITY #################### */\r
-    private def String strong(CharSequence str) '''<strong>«str»</strong>'''\r
-    private def italic(CharSequence str) '''<i>«str»</i>'''\r
-    private def pre(CharSequence str) '''<pre>«str»</pre>'''\r
-\r
-    def CharSequence descAndRefLi(SchemaNode node) '''\r
-        «listItem(node.description)»\r
-        «listItem("Reference", node.reference)»\r
-    '''\r
-\r
-    def CharSequence descAndRef(SchemaNode node) '''\r
-        «node.description»\r
-        «IF node.reference !== null»\r
-            Reference «node.reference»\r
-        «ENDIF»\r
-    '''\r
-\r
-    private def listItem(String value) '''\r
-        «IF value !== null && !value.empty»\r
-            <li>\r
-                «value»\r
-            </li>\r
-        «ENDIF»\r
-    '''\r
-\r
-    private def listItem(String name, String value) '''\r
-        «IF value !== null && !value.empty»\r
-            <li>\r
-                «name»: «value»\r
-            </li>\r
-        «ENDIF»\r
-    '''\r
-\r
-    private def String nodeSchemaPathToPath(DataSchemaNode node, Map<SchemaPath, DataSchemaNode> childNodes) {\r
-        if (node instanceof ChoiceNode || node instanceof ChoiceCaseNode) {\r
-            return null\r
-        }\r
-\r
-        val path = node.path.path\r
-        val absolute = node.path.absolute;\r
-        var StringBuilder result = new StringBuilder\r
-        if (absolute) {\r
-            result.append("/")\r
-        }\r
-        if (path !== null && !path.empty) {\r
-            val List<QName> actual = new ArrayList()\r
-            var i = 0;\r
-            for (pathElement : path) {\r
-                actual.add(pathElement)\r
-                val DataSchemaNode nodeByPath = childNodes.get(new SchemaPath(actual, absolute)) \r
-                if (!(nodeByPath instanceof ChoiceNode) && !(nodeByPath instanceof ChoiceCaseNode)) {\r
-                    result.append(pathElement.localName)\r
-                    if (i != path.size - 1) {\r
-                        result.append("/")\r
-                    }\r
-                }\r
-                i = i + 1\r
-            }\r
-        }\r
-        return result.toString\r
-    }\r
-\r
-    private def void collectChildNodes(Collection<DataSchemaNode> source, Map<SchemaPath, DataSchemaNode> destination) {\r
-        for (node : source) {\r
-            destination.put(node.path, node)\r
-            if (node instanceof DataNodeContainer) {\r
-                collectChildNodes((node as DataNodeContainer).childNodes, destination)\r
-            }\r
-            if (node instanceof ChoiceNode) {\r
-                val List<DataSchemaNode> choiceCases = new ArrayList()\r
-                for (caseNode : (node as ChoiceNode).cases) {\r
-                    choiceCases.add(caseNode)\r
-                }\r
-                collectChildNodes(choiceCases, destination)\r
-            }\r
-        }\r
-    }\r
-\r
-    private def dispatch addedByInfo(SchemaNode node) '''\r
-    '''\r
-\r
-    private def dispatch addedByInfo(DataSchemaNode node) '''\r
-        «IF node.augmenting»(A)«ENDIF»«IF node.addedByUses»(U)«ENDIF»\r
-    '''\r
-\r
-    private def dispatch isAddedBy(SchemaNode node) {\r
-        return false;\r
-    }\r
-\r
-    private def dispatch isAddedBy(DataSchemaNode node) {\r
-        if (node.augmenting || node.addedByUses) {\r
-            return true\r
-        } else {\r
-            return false;\r
-        }\r
-    }\r
-\r
-    private def dispatch nodeName(SchemaNode node) '''\r
-        «IF node.isAddedBy»\r
-            «italic(node.QName.localName)»«node.addedByInfo»\r
-        «ELSE»\r
-            «node.QName.localName»«node.addedByInfo»\r
-        «ENDIF»\r
-    '''\r
-    \r
-    private def dispatch nodeName(ContainerSchemaNode node) '''\r
-        «IF node.isAddedBy»\r
-            «strong(italic(node.QName.localName))»«node.addedByInfo»\r
-        «ELSE»\r
-            «strong(node.QName.localName)»«node.addedByInfo»\r
-        «ENDIF»\r
-    '''\r
-\r
-    private def dispatch nodeName(ListSchemaNode node) '''\r
-        «IF node.isAddedBy»\r
-            «strong(italic(node.QName.localName))» «IF node.keyDefinition !== null && !node.keyDefinition.empty»«node.listKeys»«ENDIF»«node.addedByInfo»\r
-        «ELSE»\r
-            «strong(node.QName.localName)» «IF node.keyDefinition !== null && !node.keyDefinition.empty»«node.listKeys»«ENDIF»\r
-        «ENDIF»\r
-    '''\r
-\r
-}\r
+
+                if (!(node instanceof ChoiceNode) && !(node instanceof ChoiceCaseNode)) {
+                    var String prefix = name.prefix
+                    var String moduleName
+                    if (prefix == null || "".equals(prefix) || prefix.equals(module.prefix)) {
+                        moduleName = module.name
+                    } else {
+                        moduleName = imports.get(prefix)
+                    }
+                    pathString.append(moduleName)
+                    pathString.append(":")
+                    pathString.append(name.localName)
+                    pathString.append("/")
+                }
+                parent = node
+            } else if (parent instanceof ChoiceNode) {
+                parent = (parent as ChoiceNode).getCaseNodeByName(qname.localName)
+            }
+        }
+        return pathString.toString;
+    }
+
+
+    def CharSequence childNodesInfoTree(Map<SchemaPath, DataSchemaNode> childNodes) '''
+        «IF childNodes !== null && !childNodes.empty»
+            «FOR child : childNodes.values»
+                «childInfo(child, childNodes)»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
+    def CharSequence childInfo(DataSchemaNode node, Map<SchemaPath, DataSchemaNode> childNodes) '''
+        «val String path = nodeSchemaPathToPath(node, childNodes)»
+        «IF path != null»
+            «code(path)»
+                «IF node !== null»
+                <ul>
+                «node.descAndRefLi»
+                </ul>
+            «ENDIF»
+        «ENDIF»
+    '''
+
+    private def CharSequence treeSet(Collection<DataSchemaNode> childNodes, InstanceIdentifier path) '''
+        «IF childNodes !== null && !childNodes.empty»
+            <ul>
+            «FOR child : childNodes»
+                <li>
+                    «child.tree(path)»
+                </li>
+            «ENDFOR»
+            </ul>
+        «ENDIF»
+    '''
+
+    def listKeys(ListSchemaNode node) '''
+        [«FOR key : node.keyDefinition SEPARATOR " "»«key.localName»«ENDFOR»]
+    '''
+
+    private def CharSequence rpcInfo(RpcDefinition rpc,InstanceIdentifier path) '''
+        <ul>
+            «rpc.descAndRefLi»
+            <li>
+                «rpc.input.tree(path)»
+            </li>
+            <li>
+                «rpc.output.tree(path)»
+            </li>
+        </ul>
+    '''
+
+    private def CharSequence extensionInfo(ExtensionDefinition ext) '''
+        <ul>
+            «ext.descAndRefLi»
+            «listItem("Argument", ext.argument)»
+        </ul>
+    '''
+
+    private def dispatch CharSequence tree(Void obj, InstanceIdentifier path) '''
+    '''
+
+
+
+    /* #################### RESTRICTIONS #################### */
+    private def restrictions(TypeDefinition<?> type) '''
+        «type.toLength»
+        «type.toRange»
+    '''
+
+    private def dispatch toLength(TypeDefinition<?> type) {
+    }
+
+    private def dispatch toLength(BinaryTypeDefinition type) '''
+        «type.lengthConstraints.toLengthStmt»
+    '''
+
+    private def dispatch toLength(StringTypeDefinition type) '''
+        «type.lengthConstraints.toLengthStmt»
+    '''
+
+    private def dispatch toLength(ExtendedType type) '''
+        «type.lengthConstraints.toLengthStmt»
+    '''
+
+    private def dispatch toRange(TypeDefinition<?> type) {
+    }
+
+    private def dispatch toRange(DecimalTypeDefinition type) '''
+        «type.rangeConstraints.toRangeStmt»
+    '''
+
+    private def dispatch toRange(IntegerTypeDefinition type) '''
+        «type.rangeConstraints.toRangeStmt»
+    '''
+
+    private def dispatch toRange(UnsignedIntegerTypeDefinition type) '''
+        «type.rangeConstraints.toRangeStmt»
+    '''
+
+    private def dispatch toRange(ExtendedType type) '''
+        «type.rangeConstraints.toRangeStmt»
+    '''
+
+    def toLengthStmt(Collection<LengthConstraint> lengths) '''
+        «IF lengths != null && !lengths.empty»
+            «listItem("Length restrictions")»
+            <ul>
+            «FOR length : lengths»
+                <li>
+                «IF length.min == length.max»
+                    «length.min»
+                «ELSE»
+                    &lt;«length.min», «length.max»&gt;
+                «ENDIF»
+                </li>
+            «ENDFOR»
+            </ul>
+        «ENDIF»
+    '''
+
+    def toRangeStmt(Collection<RangeConstraint> ranges) '''
+        «IF ranges != null && !ranges.empty»
+            «listItem("Range restrictions")»
+            <ul>
+            «FOR range : ranges»
+                <li>
+                «IF range.min == range.max»
+                    «range.min»
+                «ELSE»
+                    &lt;«range.min», «range.max»&gt;
+                «ENDIF»
+                </li>
+            «ENDFOR»
+            </ul>
+        «ENDIF»
+    '''
+
+
+
+    /* #################### UTILITY #################### */
+    private def String strong(CharSequence str) '''<strong>«str»</strong>'''
+    private def italic(CharSequence str) '''<i>«str»</i>'''
+    private def pre(CharSequence str) '''<pre>«str»</pre>'''
+
+    def CharSequence descAndRefLi(SchemaNode node) '''
+        «listItem(node.description)»
+        «listItem("Reference", node.reference)»
+    '''
+
+    def CharSequence descAndRef(SchemaNode node) '''
+        «node.description»
+        «IF node.reference !== null»
+            Reference «node.reference»
+        «ENDIF»
+    '''
+
+    private def listItem(String value) '''
+        «IF value !== null && !value.empty»
+            <li>
+                «value»
+            </li>
+        «ENDIF»
+    '''
+
+    private def listItem(String name, String value) '''
+        «IF value !== null && !value.empty»
+            <li>
+                «name»: «value»
+            </li>
+        «ENDIF»
+    '''
+
+    private def String nodeSchemaPathToPath(DataSchemaNode node, Map<SchemaPath, DataSchemaNode> childNodes) {
+        if (node instanceof ChoiceNode || node instanceof ChoiceCaseNode) {
+            return null
+        }
+
+        val path = node.path.path
+        val absolute = node.path.absolute;
+        var StringBuilder result = new StringBuilder
+        if (absolute) {
+            result.append("/")
+        }
+        if (path !== null && !path.empty) {
+            val List<QName> actual = new ArrayList()
+            var i = 0;
+            for (pathElement : path) {
+                actual.add(pathElement)
+                val DataSchemaNode nodeByPath = childNodes.get(new SchemaPath(actual, absolute)) 
+                if (!(nodeByPath instanceof ChoiceNode) && !(nodeByPath instanceof ChoiceCaseNode)) {
+                    result.append(pathElement.localName)
+                    if (i != path.size - 1) {
+                        result.append("/")
+                    }
+                }
+                i = i + 1
+            }
+        }
+        return result.toString
+    }
+
+    private def void collectChildNodes(Collection<DataSchemaNode> source, Map<SchemaPath, DataSchemaNode> destination) {
+        for (node : source) {
+            destination.put(node.path, node)
+            if (node instanceof DataNodeContainer) {
+                collectChildNodes((node as DataNodeContainer).childNodes, destination)
+            }
+            if (node instanceof ChoiceNode) {
+                val List<DataSchemaNode> choiceCases = new ArrayList()
+                for (caseNode : (node as ChoiceNode).cases) {
+                    choiceCases.add(caseNode)
+                }
+                collectChildNodes(choiceCases, destination)
+            }
+        }
+    }
+
+    private def dispatch addedByInfo(SchemaNode node) '''
+    '''
+
+    private def dispatch addedByInfo(DataSchemaNode node) '''
+        «IF node.augmenting»(A)«ENDIF»«IF node.addedByUses»(U)«ENDIF»
+    '''
+
+    private def dispatch isAddedBy(SchemaNode node) {
+        return false;
+    }
+
+    private def dispatch isAddedBy(DataSchemaNode node) {
+        if (node.augmenting || node.addedByUses) {
+            return true
+        } else {
+            return false;
+        }
+    }
+
+    private def dispatch nodeName(SchemaNode node) '''
+        «IF node.isAddedBy»
+            «italic(node.QName.localName)»«node.addedByInfo»
+        «ELSE»
+            «node.QName.localName»«node.addedByInfo»
+        «ENDIF»
+    '''
+    
+    private def dispatch nodeName(ContainerSchemaNode node) '''
+        «IF node.isAddedBy»
+            «strong(italic(node.QName.localName))»«node.addedByInfo»
+        «ELSE»
+            «strong(node.QName.localName)»«node.addedByInfo»
+        «ENDIF»
+    '''
+
+    private def dispatch nodeName(ListSchemaNode node) '''
+        «IF node.isAddedBy»
+            «strong(italic(node.QName.localName))» «IF node.keyDefinition !== null && !node.keyDefinition.empty»«node.listKeys»«ENDIF»«node.addedByInfo»
+        «ELSE»
+            «strong(node.QName.localName)» «IF node.keyDefinition !== null && !node.keyDefinition.empty»«node.listKeys»«ENDIF»
+        «ENDIF»
+    '''
+
+}