Add ability to get yang sources from SchemaContext. 79/5579/4
authorTomas Olvecky <tolvecky@cisco.com>
Mon, 10 Mar 2014 12:17:05 +0000 (13:17 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 12 Mar 2014 10:18:42 +0000 (10:18 +0000)
SchemaContext should provide yang source code of parsed module files.
To identify modules, move YANGModuleIdentifier from binding-generator-spi
to yang-model-api: ModuleIdentifier. This interface can represent
both modules and submodules in SchemaContext. Add methods to SchemaContext
to iterate ove ModuleIdentifiers and get their source.
In order to maintain backwards compatibility no new parsing method was created,
so submodules cannot be supported now in new methods.
Adding this functionality removes need for most methods defined in
org.opendaylight.yangtools.yang.model.parser.api.YangModelParser .
It is advised that after this change parser api would be refactored to
have a method taking collection of input streams as input
and returning SchemaContext.
Other small changes:
Externalize SimpleDateFormat wrapped in ThreadLocal
Add toString to AbstractObjectRegistration
Add guava dependency to yang-model-api for Optional goodness
Add ModuleIdentifierImpl convenience class allowing users to seach source by
 module name.

Change-Id: I8a46fa699bbd829e5d4a488ebc99012a66fc196d
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
26 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.xtend
code-generator/binding-generator-spi/src/main/java/org/opendaylight/yangtools/sal/binding/generator/spi/TypeProviderFactory.java
code-generator/binding-generator-spi/src/main/java/org/opendaylight/yangtools/sal/binding/generator/spi/YANGModuleIdentifier.java [deleted file]
concepts/pom.xml
concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractObjectRegistration.java
pom.xml
restconf/pom.xml
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QName.java
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/SimpleDateFormatUtil.java [new file with mode: 0644]
yang/yang-maven-plugin/pom.xml
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java
yang/yang-model-api/pom.xml
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleIdentifier.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SourceStreamAware.java
yang/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/model/parser/api/YangModelParser.java
yang/yang-parser-impl/pom.xml
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleIdentifierImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/SchemaContextImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedByteArrayInputStream.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedFileInputStream.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedInputStream.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangParserTest.java

index 81ed99e6c142f145fee924296780614ed6867ca4..94d4812cd039f3c5e72b6f46d85f503d51f761fb 100644 (file)
@@ -1,25 +1,25 @@
-/*\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
+/*
+ * 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;
-\r
-import static com.google.common.base.Preconditions.*;\r
-import static extension org.opendaylight.yangtools.binding.generator.util.Types.*;\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.*;\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.*;\r
-import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;\r
+
+import static com.google.common.base.Preconditions.*;
+import static extension org.opendaylight.yangtools.binding.generator.util.Types.*;
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.*;
+import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.*;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;\r
-import java.util.Iterator\r
+import java.util.Set;
+import java.util.Iterator
 import java.util.Collection
 import org.opendaylight.yangtools.binding.generator.util.BindingTypes;
 import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
@@ -75,7 +75,8 @@ import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil
 import org.opendaylight.yangtools.sal.binding.model.api.Restrictions
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder
 import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl
-import org.opendaylight.yangtools.yang.common.QName\rimport org.opendaylight.yangtools.yang.binding.BindingMapping
+import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.binding.BindingMapping
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilderBase
 
 import com.google.common.collect.Sets
@@ -86,52 +87,52 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
     private final Map<Module, ModuleContext> genCtx = new HashMap()
 
-    /**\r
-     * Outer key represents the package name. Outer value represents map of\r
-     * all builders in the same package. Inner key represents the schema node\r
-     * name (in JAVA class/interface name format). Inner value represents\r
-     * instance of builder for schema node specified in key part.\r
+    /**
+     * Outer key represents the package name. Outer value represents map of
+     * all builders in the same package. Inner key represents the schema node
+     * name (in JAVA class/interface name format). Inner value represents
+     * instance of builder for schema node specified in key part.
      */
     private Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders;
 
-    /**\r
-     * Provide methods for converting YANG types to JAVA types.\r
+    /**
+     * Provide methods for converting YANG types to JAVA types.
      */
     private var TypeProvider typeProvider;
 
-    /**\r
-     * Holds reference to schema context to resolve data of augmented element\r
-     * when creating augmentation builder\r
+    /**
+     * Holds reference to schema context to resolve data of augmented element
+     * when creating augmentation builder
      */
     private var SchemaContext schemaContext;
 
-    /**\r
-     * Constant with the concrete name of namespace.\r
+    /**
+     * Constant with the concrete name of namespace.
      */
     private val static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";
 
-    /**\r
-     * Constant with the concrete name of identifier.\r
+    /**
+     * Constant with the concrete name of identifier.
      */
     private val static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";
 
-    /**\r
-     * Resolves generated types from <code>context</code> schema nodes of all\r
-     * modules.\r
-     *\r
-     * Generated types are created for modules, groupings, types, containers,\r
-     * lists, choices, augments, rpcs, notification, identities.\r
-     *\r
-     * @param context\r
-     *            schema context which contains data about all schema nodes\r
-     *            saved in modules\r
-     * @return list of types (usually <code>GeneratedType</code>\r
-     *         <code>GeneratedTransferObject</code>which are generated from\r
-     *         <code>context</code> data.\r
-     * @throws IllegalArgumentException\r
-     *             if param <code>context</code> is null\r
-     * @throws IllegalStateException\r
-     *             if <code>context</code> contain no modules\r
+    /**
+     * Resolves generated types from <code>context</code> schema nodes of all
+     * modules.
+     *
+     * Generated types are created for modules, groupings, types, containers,
+     * lists, choices, augments, rpcs, notification, identities.
+     *
+     * @param context
+     *            schema context which contains data about all schema nodes
+     *            saved in modules
+     * @return list of types (usually <code>GeneratedType</code>
+     *         <code>GeneratedTransferObject</code>which are generated from
+     *         <code>context</code> data.
+     * @throws IllegalArgumentException
+     *             if param <code>context</code> is null
+     * @throws IllegalStateException
+     *             if <code>context</code> contain no modules
      */
     override generateTypes(SchemaContext context) {
         checkArgument(context !== null, "Schema Context reference cannot be NULL.");
@@ -142,33 +143,33 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return generateTypes(context, modules);
     }
 
-    /**\r
-     * Resolves generated types from <code>context</code> schema nodes only for\r
-     * modules specified in <code>modules</code>\r
-     *\r
-     * Generated types are created for modules, groupings, types, containers,\r
-     * lists, choices, augments, rpcs, notification, identities.\r
-     *\r
-     * @param context\r
-     *            schema context which contains data about all schema nodes\r
-     *            saved in modules\r
-     * @param modules\r
-     *            set of modules for which schema nodes should be generated\r
-     *            types\r
-     * @return list of types (usually <code>GeneratedType</code> or\r
-     *         <code>GeneratedTransferObject</code>) which:\r
-     *         <ul>\r
-     *         <li>are generated from <code>context</code> schema nodes and</li>\r
-     *         <li>are also part of some of the module in <code>modules</code>\r
-     *         set</li>.\r
-     *         </ul>\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if param <code>context</code> is null or</li>\r
-     *             <li>if param <code>modules</code> is null</li>\r
-     *             </ul>\r
-     * @throws IllegalStateException\r
-     *             if <code>context</code> contain no modules\r
+    /**
+     * Resolves generated types from <code>context</code> schema nodes only for
+     * modules specified in <code>modules</code>
+     *
+     * Generated types are created for modules, groupings, types, containers,
+     * lists, choices, augments, rpcs, notification, identities.
+     *
+     * @param context
+     *            schema context which contains data about all schema nodes
+     *            saved in modules
+     * @param modules
+     *            set of modules for which schema nodes should be generated
+     *            types
+     * @return list of types (usually <code>GeneratedType</code> or
+     *         <code>GeneratedTransferObject</code>) which:
+     *         <ul>
+     *         <li>are generated from <code>context</code> schema nodes and</li>
+     *         <li>are also part of some of the module in <code>modules</code>
+     *         set</li>.
+     *         </ul>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if param <code>context</code> is null or</li>
+     *             <li>if param <code>modules</code> is null</li>
+     *             </ul>
+     * @throws IllegalStateException
+     *             if <code>context</code> contain no modules
      */
     override generateTypes(SchemaContext context, Set<Module> modules) {
         checkArgument(context !== null, "Schema Context reference cannot be NULL.");
@@ -189,12 +190,13 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         val List<Type> filteredGenTypes = new ArrayList();
         for (Module m : modules) {
-            filteredGenTypes.addAll(genCtx.get(m).generatedTypes);\r
-            val Set<Type> additionalTypes = (typeProvider as TypeProviderImpl).additionalTypes.get(m)\r
-            if (additionalTypes != null) {\r
-                filteredGenTypes.addAll(additionalTypes)\r
+            val ctx = checkNotNull(genCtx.get(m), "Module context not found for module %s", m)
+            filteredGenTypes.addAll(ctx.generatedTypes);
+            val Set<Type> additionalTypes = (typeProvider as TypeProviderImpl).additionalTypes.get(m)
+            if (additionalTypes != null) {
+                filteredGenTypes.addAll(additionalTypes)
             }
-        }\r
+        }
 
         return filteredGenTypes;
     }
@@ -215,19 +217,19 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Converts all extended type definitions of module to the list of\r
-     * <code>Type</code> objects.\r
-     *\r
-     * @param module\r
-     *            module from which is obtained set of type definitions\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if module equals null</li>\r
-     *             <li>if name of module equals null</li>\r
-     *             <li>if type definitions of module equal null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Converts all extended type definitions of module to the list of
+     * <code>Type</code> objects.
+     *
+     * @param module
+     *            module from which is obtained set of type definitions
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if module equals null</li>
+     *             <li>if name of module equals null</li>
+     *             <li>if type definitions of module equal null</li>
+     *             </ul>
+     *
      */
     private def void allTypeDefinitionsToGenTypes(Module module) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -244,8 +246,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 }
             }
         }
-    }\r
-\r
+    }
+
     private def GeneratedTypeBuilder processDataSchemaNode(Module module, String basePackageName,
         GeneratedTypeBuilder parent, GeneratedTypeBuilder childOf, DataSchemaNode node) {
         if (node.augmenting || node.addedByUses) {
@@ -292,7 +294,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 }
             }
 
-            // serialVersionUID\r
+            // serialVersionUID
             if (genTOBuilder !== null) {
                 val GeneratedPropertyBuilder prop = new GeneratedPropertyBuilderImpl("serialVersionUID");
                 prop.setValue(Long.toString(computeDefaultSUID(genTOBuilder as GeneratedTOBuilderImpl)));
@@ -313,20 +315,20 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Converts all <b>augmentation</b> of the module to the list\r
-     * <code>Type</code> objects.\r
-     *\r
-     * @param module\r
-     *            module from which is obtained list of all augmentation objects\r
-     *            to iterate over them\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if the module equals null</li>\r
-     *             <li>if the name of module equals null</li>\r
-     *             <li>if the set of child nodes equals null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Converts all <b>augmentation</b> of the module to the list
+     * <code>Type</code> objects.
+     *
+     * @param module
+     *            module from which is obtained list of all augmentation objects
+     *            to iterate over them
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the module equals null</li>
+     *             <li>if the name of module equals null</li>
+     *             <li>if the set of child nodes equals null</li>
+     *             </ul>
+     *
      */
     private def void allAugmentsToGenTypes(Module module) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -343,21 +345,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Returns list of <code>AugmentationSchema</code> objects. The objects are\r
-     * sorted according to the length of their target path from the shortest to\r
-     * the longest.\r
-     *\r
-     * @param module\r
-     *            module from which is obtained list of all augmentation objects\r
-     * @return list of sorted <code>AugmentationSchema</code> objects obtained\r
-     *         from <code>module</code>\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if the module equals null</li>\r
-     *             <li>if the set of augmentation equals null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Returns list of <code>AugmentationSchema</code> objects. The objects are
+     * sorted according to the length of their target path from the shortest to
+     * the longest.
+     *
+     * @param module
+     *            module from which is obtained list of all augmentation objects
+     * @return list of sorted <code>AugmentationSchema</code> objects obtained
+     *         from <code>module</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the module equals null</li>
+     *             <li>if the set of augmentation equals null</li>
+     *             </ul>
+     *
      */
     private def List<AugmentationSchema> resolveAugmentations(Module module) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -377,19 +379,19 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return sortedAugmentations;
     }
 
-    /**\r
-     * Converts whole <b>module</b> to <code>GeneratedType</code> object.\r
-     * Firstly is created the module builder object from which is vally\r
-     * obtained reference to <code>GeneratedType</code> object.\r
-     *\r
-     * @param module\r
-     *            module from which are obtained the module name, child nodes,\r
-     *            uses and is derived package name\r
-     * @return <code>GeneratedType</code> which is internal representation of\r
-     *         the module\r
-     * @throws IllegalArgumentException\r
-     *             if the module equals null\r
-     *\r
+    /**
+     * Converts whole <b>module</b> to <code>GeneratedType</code> object.
+     * Firstly is created the module builder object from which is vally
+     * obtained reference to <code>GeneratedType</code> object.
+     *
+     * @param module
+     *            module from which are obtained the module name, child nodes,
+     *            uses and is derived package name
+     * @return <code>GeneratedType</code> which is internal representation of
+     *         the module
+     * @throws IllegalArgumentException
+     *             if the module equals null
+     *
      */
     private def GeneratedTypeBuilder moduleToDataType(Module module) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -400,21 +402,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return moduleDataTypeBuilder;
     }
 
-    /**\r
-     * Converts all <b>rpcs</b> inputs and outputs substatements of the module\r
-     * to the list of <code>Type</code> objects. In addition are to containers\r
-     * and lists which belong to input or output also part of returning list.\r
-     *\r
-     * @param module\r
-     *            module from which is obtained set of all rpc objects to\r
-     *            iterate over them\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if the module equals null</li>\r
-     *             <li>if the name of module equals null</li>\r
-     *             <li>if the set of child nodes equals null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Converts all <b>rpcs</b> inputs and outputs substatements of the module
+     * to the list of <code>Type</code> objects. In addition are to containers
+     * and lists which belong to input or output also part of returning list.
+     *
+     * @param module
+     *            module from which is obtained set of all rpc objects to
+     *            iterate over them
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the module equals null</li>
+     *             <li>if the name of module equals null</li>
+     *             <li>if the set of child nodes equals null</li>
+     *             </ul>
+     *
      */
     private def void rpcMethodsToGenType(Module module) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -468,21 +470,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
         genCtx.get(module).addTopLevelNodeType(interfaceBuilder)
     }
 
-    /**\r
-     * Converts all <b>notifications</b> of the module to the list of\r
-     * <code>Type</code> objects. In addition are to this list added containers\r
-     * and lists which are part of this notification.\r
-     *\r
-     * @param module\r
-     *            module from which is obtained set of all notification objects\r
-     *            to iterate over them\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if the module equals null</li>\r
-     *             <li>if the name of module equals null</li>\r
-     *             <li>if the set of child nodes equals null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Converts all <b>notifications</b> of the module to the list of
+     * <code>Type</code> objects. In addition are to this list added containers
+     * and lists which are part of this notification.
+     *
+     * @param module
+     *            module from which is obtained set of all notification objects
+     *            to iterate over them
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the module equals null</li>
+     *             <li>if the name of module equals null</li>
+     *             <li>if the set of child nodes equals null</li>
+     *             </ul>
+     *
      */
     private def void notificationsToGenType(Module module) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -508,11 +510,11 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 notificationInterface.addImplementsType(NOTIFICATION);
                 genCtx.get(module).addChildNodeType(notification.path, notificationInterface)
 
-                // Notification object\r
+                // Notification object
                 resolveDataSchemaNodes(module, basePackageName, notificationInterface, notificationInterface,
                     notification.childNodes);
 
-                listenerInterface.addMethod("on" + notificationInterface.name) //\r
+                listenerInterface.addMethod("on" + notificationInterface.name) //
                 .setAccessModifier(AccessModifier.PUBLIC).addParameter(notificationInterface, "notification").
                     setReturnType(Types.VOID);
             }
@@ -521,17 +523,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
         genCtx.get(module).addTopLevelNodeType(listenerInterface)
     }
 
-    /**\r
-     * Converts all <b>identities</b> of the module to the list of\r
-     * <code>Type</code> objects.\r
-     *\r
-     * @param module\r
-     *            module from which is obtained set of all identity objects to\r
-     *            iterate over them\r
-     * @param context\r
-     *            schema context only used as input parameter for method\r
-     *            {@link identityToGenType}\r
-     *\r
+    /**
+     * Converts all <b>identities</b> of the module to the list of
+     * <code>Type</code> objects.
+     *
+     * @param module
+     *            module from which is obtained set of all identity objects to
+     *            iterate over them
+     * @param context
+     *            schema context only used as input parameter for method
+     *            {@link identityToGenType}
+     *
      */
     private def void allIdentitiesToGenTypes(Module module, SchemaContext context) {
         val Set<IdentitySchemaNode> schemaIdentities = module.identities;
@@ -544,23 +546,23 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Converts the <b>identity</b> object to GeneratedType. Firstly it is\r
-     * created transport object builder. If identity contains base identity then\r
-     * reference to base identity is added to superior identity as its extend.\r
-     * If identity doesn't contain base identity then only reference to abstract\r
-     * class {@link org.opendaylight.yangtools.yang.model.api.BaseIdentity\r
-     * BaseIdentity} is added\r
-     *\r
-     * @param module current module\r
-     * @param basePackageName\r
-     *            string contains the module package name\r
-     * @param identity\r
-     *            IdentitySchemaNode which contains data about identity\r
-     * @param context\r
-     *            SchemaContext which is used to get package and name\r
-     *            information about base of identity\r
-     *\r
+    /**
+     * Converts the <b>identity</b> object to GeneratedType. Firstly it is
+     * created transport object builder. If identity contains base identity then
+     * reference to base identity is added to superior identity as its extend.
+     * If identity doesn't contain base identity then only reference to abstract
+     * class {@link org.opendaylight.yangtools.yang.model.api.BaseIdentity
+     * BaseIdentity} is added
+     *
+     * @param module current module
+     * @param basePackageName
+     *            string contains the module package name
+     * @param identity
+     *            IdentitySchemaNode which contains data about identity
+     * @param context
+     *            SchemaContext which is used to get package and name
+     *            information about base of identity
+     *
      */
     private def void identityToGenType(Module module, String basePackageName, IdentitySchemaNode identity,
         SchemaContext context) {
@@ -580,31 +582,31 @@ public class BindingGeneratorImpl implements BindingGenerator {
             val gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName).toInstance();
             newType.setExtendsType(gto);
         }
-        newType.setAbstract(true);\r
-        val qname = identity.QName;\r
-        \r
-        newType.qnameConstant(BindingMapping.QNAME_STATIC_FIELD_NAME,qname);\r
+        newType.setAbstract(true);
+        val qname = identity.QName;
+        
+        newType.qnameConstant(BindingMapping.QNAME_STATIC_FIELD_NAME,qname);
         
         genCtx.get(module).addIdentityType(identity.QName,newType)
-    }\r
-    \r
+    }
+    
     private static def qnameConstant(GeneratedTypeBuilderBase<?> toBuilder, String constantName, QName name) {
-        toBuilder.addConstant(QName.typeForClass,constantName,'''\r
-            org.opendaylight.yangtools.yang.common.QName.create("«name.namespace»","«name.formattedRevision»","«name.localName»")\r
+        toBuilder.addConstant(QName.typeForClass,constantName,'''
+            org.opendaylight.yangtools.yang.common.QName.create("«name.namespace»","«name.formattedRevision»","«name.localName»")
         ''');
     }
 
-    /**\r
-     * Converts all <b>groupings</b> of the module to the list of\r
-     * <code>Type</code> objects. Firstly are groupings sorted according mutual\r
-     * dependencies. At least dependent (independent) groupings are in the list\r
-     * saved at first positions. For every grouping the record is added to map\r
-     * {@link BindingGeneratorImpl#allGroupings allGroupings}\r
-     *\r
-     * @param module\r
-     *            current module\r
-     * @param collection of groupings from which types will be generated\r
-     *\r
+    /**
+     * Converts all <b>groupings</b> of the module to the list of
+     * <code>Type</code> objects. Firstly are groupings sorted according mutual
+     * dependencies. At least dependent (independent) groupings are in the list
+     * saved at first positions. For every grouping the record is added to map
+     * {@link BindingGeneratorImpl#allGroupings allGroupings}
+     *
+     * @param module
+     *            current module
+     * @param collection of groupings from which types will be generated
+     *
      */
     private def void groupingsToGenTypes(Module module, Collection<GroupingDefinition> groupings) {
         val basePackageName = moduleNamespaceToPackageName(module);
@@ -615,18 +617,18 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Converts individual grouping to GeneratedType. Firstly generated type\r
-     * builder is created and every child node of grouping is resolved to the\r
-     * method.\r
-     *\r
-     * @param basePackageName\r
-     *            string contains the module package name\r
-     * @param grouping\r
-     *            GroupingDefinition which contains data about grouping\r
-     * @param module current module\r
-     * @return GeneratedType which is generated from grouping (object of type\r
-     *         <code>GroupingDefinition</code>)\r
+    /**
+     * Converts individual grouping to GeneratedType. Firstly generated type
+     * builder is created and every child node of grouping is resolved to the
+     * method.
+     *
+     * @param basePackageName
+     *            string contains the module package name
+     * @param grouping
+     *            GroupingDefinition which contains data about grouping
+     * @param module current module
+     * @return GeneratedType which is generated from grouping (object of type
+     *         <code>GroupingDefinition</code>)
      */
     private def void groupingToGenType(String basePackageName, GroupingDefinition grouping, Module module) {
         val packageName = packageNameForGeneratedType(basePackageName, grouping.path);
@@ -637,16 +639,16 @@ public class BindingGeneratorImpl implements BindingGenerator {
         processUsesAugments(grouping, module);
     }
 
-    /**\r
-     * Tries to find EnumTypeDefinition in <code>typeDefinition</code>. If base\r
-     * type of <code>typeDefinition</code> is of the type ExtendedType then this\r
-     * method is recursively called with this base type.\r
-     *\r
-     * @param typeDefinition\r
-     *            TypeDefinition in which should be EnumTypeDefinition found as\r
-     *            base type\r
-     * @return EnumTypeDefinition if it is found inside\r
-     *         <code>typeDefinition</code> or <code>null</code> in other case\r
+    /**
+     * Tries to find EnumTypeDefinition in <code>typeDefinition</code>. If base
+     * type of <code>typeDefinition</code> is of the type ExtendedType then this
+     * method is recursively called with this base type.
+     *
+     * @param typeDefinition
+     *            TypeDefinition in which should be EnumTypeDefinition found as
+     *            base type
+     * @return EnumTypeDefinition if it is found inside
+     *         <code>typeDefinition</code> or <code>null</code> in other case
      */
     private def EnumTypeDefinition enumTypeDefFromExtendedType(TypeDefinition<?> typeDefinition) {
         if (typeDefinition !== null) {
@@ -659,22 +661,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return null;
     }
 
-    /**\r
-     * Adds enumeration builder created from <code>enumTypeDef</code> to\r
-     * <code>typeBuilder</code>.\r
-     *\r
-     * Each <code>enumTypeDef</code> item is added to builder with its name and\r
-     * value.\r
-     *\r
-     * @param enumTypeDef\r
-     *            EnumTypeDefinition contains enum data\r
-     * @param enumName\r
-     *            string contains name which will be assigned to enumeration\r
-     *            builder\r
-     * @param typeBuilder\r
-     *            GeneratedTypeBuilder to which will be enum builder assigned\r
-     * @return enumeration builder which contains data from\r
-     *         <code>enumTypeDef</code>\r
+    /**
+     * Adds enumeration builder created from <code>enumTypeDef</code> to
+     * <code>typeBuilder</code>.
+     *
+     * Each <code>enumTypeDef</code> item is added to builder with its name and
+     * value.
+     *
+     * @param enumTypeDef
+     *            EnumTypeDefinition contains enum data
+     * @param enumName
+     *            string contains name which will be assigned to enumeration
+     *            builder
+     * @param typeBuilder
+     *            GeneratedTypeBuilder to which will be enum builder assigned
+     * @return enumeration builder which contains data from
+     *         <code>enumTypeDef</code>
      */
     private def EnumBuilder resolveInnerEnumFromTypeDefinition(EnumTypeDefinition enumTypeDef, QName enumName,
         GeneratedTypeBuilder typeBuilder) {
@@ -688,19 +690,19 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return null;
     }
 
-    /**\r
-     * Generates type builder for <code>module</code>.\r
-     *\r
-     * @param module\r
-     *            Module which is source of package name for generated type\r
-     *            builder\r
-     * @param postfix\r
-     *            string which is added to the module class name representation\r
-     *            as suffix\r
-     * @return instance of GeneratedTypeBuilder which represents\r
-     *         <code>module</code>.\r
-     * @throws IllegalArgumentException\r
-     *             if <code>module</code> equals null\r
+    /**
+     * Generates type builder for <code>module</code>.
+     *
+     * @param module
+     *            Module which is source of package name for generated type
+     *            builder
+     * @param postfix
+     *            string which is added to the module class name representation
+     *            as suffix
+     * @return instance of GeneratedTypeBuilder which represents
+     *         <code>module</code>.
+     * @throws IllegalArgumentException
+     *             if <code>module</code> equals null
      */
     private def GeneratedTypeBuilder moduleTypeBuilder(Module module, String postfix) {
         checkArgument(module !== null, "Module reference cannot be NULL.");
@@ -709,27 +711,27 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return new GeneratedTypeBuilderImpl(packageName, moduleName);
     }
 
-    /**\r
-     * Converts <code>augSchema</code> to list of <code>Type</code> which\r
-     * contains generated type for augmentation. In addition there are also\r
-     * generated types for all containers, list and choices which are child of\r
-     * <code>augSchema</code> node or a generated types for cases are added if\r
-     * augmented node is choice.\r
-     *\r
-     * @param augmentPackageName\r
-     *            string with the name of the package to which the augmentation\r
-     *            belongs\r
-     * @param augSchema\r
-     *            AugmentationSchema which is contains data about augmentation\r
-     *            (target path, childs...)\r
-     * @param module current module\r
-     * @param parentUsesNode parent uses node of this augment (can be null if this augment is not defined under uses statement)\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if <code>augmentPackageName</code> equals null</li>\r
-     *             <li>if <code>augSchema</code> equals null</li>\r
-     *             <li>if target path of <code>augSchema</code> equals null</li>\r
-     *             </ul>\r
+    /**
+     * Converts <code>augSchema</code> to list of <code>Type</code> which
+     * contains generated type for augmentation. In addition there are also
+     * generated types for all containers, list and choices which are child of
+     * <code>augSchema</code> node or a generated types for cases are added if
+     * augmented node is choice.
+     *
+     * @param augmentPackageName
+     *            string with the name of the package to which the augmentation
+     *            belongs
+     * @param augSchema
+     *            AugmentationSchema which is contains data about augmentation
+     *            (target path, childs...)
+     * @param module current module
+     * @param parentUsesNode parent uses node of this augment (can be null if this augment is not defined under uses statement)
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>augmentPackageName</code> equals null</li>
+     *             <li>if <code>augSchema</code> equals null</li>
+     *             <li>if target path of <code>augSchema</code> equals null</li>
+     *             </ul>
      */
     private def void augmentationToGenTypes(String augmentPackageName, AugmentationSchema augSchema, Module module) {
         checkArgument(augmentPackageName !== null, "Package Name cannot be NULL.");
@@ -760,7 +762,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         if (targetTypeBuilder === null) {
             throw new NullPointerException("Target type not yet generated: " + targetSchemaNode);
-        }\r
+        }
 
         if (!(targetSchemaNode instanceof ChoiceNode)) {
             var packageName = augmentPackageName;
@@ -773,7 +775,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 targetSchemaNode as ChoiceNode, augSchema.childNodes);
         }
     }
-\r
+
     private def void usesAugmentationToGenTypes(String augmentPackageName, AugmentationSchema augSchema, Module module,
         UsesNode usesNode, DataNodeContainer usesNodeParent) {
         checkArgument(augmentPackageName !== null, "Package Name cannot be NULL.");
@@ -795,7 +797,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         if (targetTypeBuilder === null) {
             throw new NullPointerException("Target type not yet generated: " + targetSchemaNode);
-        }\r
+        }
 
         if (!(targetSchemaNode instanceof ChoiceNode)) {
             var packageName = augmentPackageName;
@@ -810,10 +812,10 @@ public class BindingGeneratorImpl implements BindingGenerator {
             generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance,
                 targetSchemaNode as ChoiceNode, augSchema.childNodes);
         }
-    }\r
+    }
 
-    /**\r
-     * Utility method which search for original node defined in grouping.\r
+    /**
+     * Utility method which search for original node defined in grouping.
      */
     private def DataSchemaNode findOriginal(DataSchemaNode node) {
         var DataSchemaNode result = findCorrectTargetFromGrouping(node);
@@ -833,26 +835,26 @@ public class BindingGeneratorImpl implements BindingGenerator {
             return null
         }
 
-        var QName currentName = node.QName\r
+        var QName currentName = node.QName
         var Object currentNode = node
-        var Object parent = node;\r
-        val tmpPath = new ArrayList<QName>()\r
-        val tmpTree = new ArrayList<SchemaNode>()\r
+        var Object parent = node;
+        val tmpPath = new ArrayList<QName>()
+        val tmpTree = new ArrayList<SchemaNode>()
 
         var AugmentationSchema augment = null;
-        do {\r
-            val SchemaPath sp = (parent as SchemaNode).path\r
-            val List<QName> names = sp.path\r
-            val List<QName> newNames = new ArrayList(names)\r
-            newNames.remove(newNames.size - 1)\r
-            val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)\r
-            parent = findDataSchemaNode(schemaContext, newSp)\r
+        do {
+            val SchemaPath sp = (parent as SchemaNode).path
+            val List<QName> names = sp.path
+            val List<QName> newNames = new ArrayList(names)
+            newNames.remove(newNames.size - 1)
+            val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)
+            parent = findDataSchemaNode(schemaContext, newSp)
             if (parent instanceof AugmentationTarget) {
-                tmpPath.add(currentName);\r
-                tmpTree.add(currentNode as SchemaNode)\r
+                tmpPath.add(currentName);
+                tmpTree.add(currentNode as SchemaNode)
                 augment = findNodeInAugment((parent as AugmentationTarget).availableAugmentations, currentName);
                 if (augment == null) {
-                    currentName = (parent as DataSchemaNode).QName\r
+                    currentName = (parent as DataSchemaNode).QName
                     currentNode = parent
                 }
             }
@@ -861,7 +863,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         if (augment == null) {
             return null;
         } else {
-            Collections.reverse(tmpPath);\r
+            Collections.reverse(tmpPath);
             Collections.reverse(tmpTree);
             var Object actualParent = augment;
             var DataSchemaNode result = null;
@@ -877,7 +879,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 }
             }
 
-            if (result.addedByUses) {\r
+            if (result.addedByUses) {
                 result = findCorrectTargetFromAugmentGrouping(result, augment, tmpTree);
             }
 
@@ -886,37 +888,37 @@ public class BindingGeneratorImpl implements BindingGenerator {
     }
 
     private def AugmentationSchema findNodeInAugment(Collection<AugmentationSchema> augments, QName name) {
-        for (augment : augments) {\r
-            val DataSchemaNode node = augment.getDataChildByName(name);\r
+        for (augment : augments) {
+            val DataSchemaNode node = augment.getDataChildByName(name);
             if (node != null) {
                 return augment;
             }
         }
         return null;
     }
-\r
-    private def DataSchemaNode findCorrectTargetFromGrouping(DataSchemaNode node) {\r
-        if (node.path.path.size == 1) {\r
-            // uses is under module statement\r
-            val Module m = findParentModule(schemaContext, node);\r
-            var DataSchemaNode result = null;\r
-            for (u : m.uses) {\r
-                var SchemaNode targetGrouping = findNodeInSchemaContext(schemaContext, u.groupingPath.path);\r
-                if (!(targetGrouping instanceof GroupingDefinition)) {\r
-                    throw new IllegalArgumentException("Failed to generate code for augment in " + u);\r
-                }\r
-                var gr = targetGrouping as GroupingDefinition;\r
-                result = gr.getDataChildByName(node.QName.localName);\r
-            }\r
-            if (result == null) {\r
-                throw new IllegalArgumentException("Failed to generate code for augment")\r
-            }\r
-            return result\r
-        } else {\r
-            var DataSchemaNode result = null;\r
-            var QName currentName = node.QName\r
-            var tmpPath = new ArrayList<QName>()\r
-            var Object parent = null\r
+
+    private def DataSchemaNode findCorrectTargetFromGrouping(DataSchemaNode node) {
+        if (node.path.path.size == 1) {
+            // uses is under module statement
+            val Module m = findParentModule(schemaContext, node);
+            var DataSchemaNode result = null;
+            for (u : m.uses) {
+                var SchemaNode targetGrouping = findNodeInSchemaContext(schemaContext, u.groupingPath.path);
+                if (!(targetGrouping instanceof GroupingDefinition)) {
+                    throw new IllegalArgumentException("Failed to generate code for augment in " + u);
+                }
+                var gr = targetGrouping as GroupingDefinition;
+                result = gr.getDataChildByName(node.QName.localName);
+            }
+            if (result == null) {
+                throw new IllegalArgumentException("Failed to generate code for augment")
+            }
+            return result
+        } else {
+            var DataSchemaNode result = null;
+            var QName currentName = node.QName
+            var tmpPath = new ArrayList<QName>()
+            var Object parent = null
 
             val SchemaPath sp = node.path
             val List<QName> names = sp.path
@@ -924,17 +926,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
             newNames.remove(newNames.size - 1)
             val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)
             parent = findDataSchemaNode(schemaContext, newSp)
-\r
-            do {\r
-                tmpPath.add(currentName);\r
-                if (parent instanceof DataNodeContainer) {\r
-                    val dataNodeParent = parent as DataNodeContainer;\r
-                    for (u : dataNodeParent.uses) {\r
-                        if (result == null) {\r
-                            result = getResultFromUses(u, currentName.localName)\r
-                        }\r
-                    }\r
-                }\r
+
+            do {
+                tmpPath.add(currentName);
+                if (parent instanceof DataNodeContainer) {
+                    val dataNodeParent = parent as DataNodeContainer;
+                    for (u : dataNodeParent.uses) {
+                        if (result == null) {
+                            result = getResultFromUses(u, currentName.localName)
+                        }
+                    }
+                }
                 if (result == null) {
                     currentName = (parent as SchemaNode).QName
                     if (parent instanceof SchemaNode) {
@@ -951,52 +953,52 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     } else {
                         throw new IllegalArgumentException("Failed to generate code for augment")
                     }
-                }\r
-            } while (result == null && !(parent instanceof Module));\r
-\r
-            if (result != null) {\r
-                result = getTargetNode(tmpPath, result)\r
-            }\r
-            return result;\r
-        }\r
-    }\r
-\r
+                }
+            } while (result == null && !(parent instanceof Module));
+
+            if (result != null) {
+                result = getTargetNode(tmpPath, result)
+            }
+            return result;
+        }
+    }
+
     private def DataSchemaNode findCorrectTargetFromAugmentGrouping(DataSchemaNode node, AugmentationSchema parentNode,
-        List<SchemaNode> dataTree) {\r
-\r
+        List<SchemaNode> dataTree) {
+
         var DataSchemaNode result = null;
         var QName currentName = node.QName
-        var tmpPath = new ArrayList<QName>()\r
-        tmpPath.add(currentName)\r
-        var int i = 1;\r
+        var tmpPath = new ArrayList<QName>()
+        tmpPath.add(currentName)
+        var int i = 1;
         var Object parent = null
-\r
-        do {\r
+
+        do {
             if (dataTree.size < 2 || dataTree.size == i) {
                 parent = parentNode
             } else {
                 parent = dataTree.get(dataTree.size - (i+1))
                 tmpPath.add((parent as SchemaNode).QName)
-            }\r
+            }
 
             val dataNodeParent = parent as DataNodeContainer;
             for (u : dataNodeParent.uses) {
-                if (result == null) {\r
+                if (result == null) {
                     result = getResultFromUses(u, currentName.localName)
                 }
             }
             if (result == null) {
-                i = i + 1\r
+                i = i + 1
                 currentName = (parent as SchemaNode).QName
             }
         } while (result == null);
-\r
+
         if (result != null) {
-            result = getTargetNode(tmpPath, result)\r
+            result = getTargetNode(tmpPath, result)
         }
         return result;
-    }\r
-\r
+    }
+
     private def getResultFromUses(UsesNode u, String currentName) {
         var SchemaNode targetGrouping = findNodeInSchemaContext(schemaContext, u.groupingPath.path)
         if (!(targetGrouping instanceof GroupingDefinition)) {
@@ -1004,8 +1006,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         var gr = targetGrouping as GroupingDefinition
         return gr.getDataChildByName(currentName)
-    }\r
-\r
+    }
+
     private def getTargetNode(List<QName> tmpPath, DataSchemaNode node) {
         var DataSchemaNode result = node
         if (tmpPath.size == 1) {
@@ -1018,12 +1020,12 @@ public class BindingGeneratorImpl implements BindingGenerator {
             Collections.reverse(tmpPath);
 
             tmpPath.remove(0);
-            for (name : tmpPath) {\r
-                // searching by local name is must, because node has different namespace in its original location\r
-                if (newParent instanceof DataNodeContainer) {\r
-                    newParent = (newParent as DataNodeContainer).getDataChildByName(name.localName);\r
-                } else {\r
-                    newParent = (newParent as ChoiceNode).getCaseNodeByName(name.localName);\r
+            for (name : tmpPath) {
+                // searching by local name is must, because node has different namespace in its original location
+                if (newParent instanceof DataNodeContainer) {
+                    newParent = (newParent as DataNodeContainer).getDataChildByName(name.localName);
+                } else {
+                    newParent = (newParent as ChoiceNode).getCaseNodeByName(name.localName);
                 }
             }
             if (newParent != null && newParent.addedByUses) {
@@ -1031,11 +1033,11 @@ public class BindingGeneratorImpl implements BindingGenerator {
             }
             return newParent;
         }
-    }\r
+    }
 
 
-    /**\r
-     * Convenient method to find node added by uses statement.\r
+    /**
+     * Convenient method to find node added by uses statement.
      */
     private def DataSchemaNode findOriginalTargetFromGrouping(SchemaPath targetPath, UsesNode parentUsesNode) {
         var SchemaNode targetGrouping = findNodeInSchemaContext(schemaContext, parentUsesNode.groupingPath.path);
@@ -1043,11 +1045,11 @@ public class BindingGeneratorImpl implements BindingGenerator {
             throw new IllegalArgumentException("Failed to generate code for augment in " + parentUsesNode);
         }
 
-        var grouping = targetGrouping as GroupingDefinition;\r
-        var SchemaNode result = grouping;\r
-        val List<QName> path = targetPath.path\r
+        var grouping = targetGrouping as GroupingDefinition;
+        var SchemaNode result = grouping;
+        val List<QName> path = targetPath.path
         for (node : path) {
-            // finding by local name is valid, grouping cannot contain nodes with same name and different namespace\r
+            // finding by local name is valid, grouping cannot contain nodes with same name and different namespace
             if (result instanceof DataNodeContainer) {
                 result = (result as DataNodeContainer).getDataChildByName(node.localName)
             } else if (result instanceof ChoiceNode) {
@@ -1056,8 +1058,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         if (result == null) {
             return null;
-        }\r
-\r
+        }
+
         val String targetSchemaNodeName = result.QName.localName;
         var boolean fromUses = (result as DataSchemaNode).addedByUses
         var Iterator<UsesNode> groupingUses = grouping.uses.iterator;
@@ -1074,25 +1076,25 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return result as DataSchemaNode
     }
 
-    /**\r
-     * Returns a generated type builder for an augmentation.\r
-     *\r
-     * The name of the type builder is equal to the name of augmented node with\r
-     * serial number as suffix.\r
-     *\r
-     * @param module current module\r
-     * @param augmentPackageName\r
-     *            string with contains the package name to which the augment\r
-     *            belongs\r
-     * @param basePackageName\r
-     *            string with the package name to which the augmented node\r
-     *            belongs\r
-     * @param targetTypeRef\r
-     *            target type\r
-     * @param augSchema\r
-     *            augmentation schema which contains data about the child nodes\r
-     *            and uses of augment\r
-     * @return generated type builder for augment\r
+    /**
+     * Returns a generated type builder for an augmentation.
+     *
+     * The name of the type builder is equal to the name of augmented node with
+     * serial number as suffix.
+     *
+     * @param module current module
+     * @param augmentPackageName
+     *            string with contains the package name to which the augment
+     *            belongs
+     * @param basePackageName
+     *            string with the package name to which the augmented node
+     *            belongs
+     * @param targetTypeRef
+     *            target type
+     * @param augSchema
+     *            augmentation schema which contains data about the child nodes
+     *            and uses of augment
+     * @return generated type builder for augment
      */
     private def GeneratedTypeBuilder addRawAugmentGenTypeDefinition(Module module, String augmentPackageName,
         String basePackageName, Type targetTypeRef, AugmentationSchema augSchema) {
@@ -1120,10 +1122,10 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return augTypeBuilder;
     }
 
-    /**\r
-     *\r
-     * @param unknownSchemaNodes\r
-     * @return nodeParameter of UnknownSchemaNode\r
+    /**
+     *
+     * @param unknownSchemaNodes
+     * @return nodeParameter of UnknownSchemaNode
      */
     private def String getAugmentIdentifier(List<UnknownSchemaNode> unknownSchemaNodes) {
         for (unknownSchemaNode : unknownSchemaNodes) {
@@ -1136,17 +1138,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return null;
     }
 
-    /**\r
-     * Returns first unique name for the augment generated type builder. The\r
-     * generated type builder name for augment consists from name of augmented\r
-     * node and serial number of its augmentation.\r
-     *\r
-     * @param builders\r
-     *            map of builders which were created in the package to which the\r
-     *            augmentation belongs\r
-     * @param genTypeName\r
-     *            string with name of augmented node\r
-     * @return string with unique name for augmentation builder\r
+    /**
+     * Returns first unique name for the augment generated type builder. The
+     * generated type builder name for augment consists from name of augmented
+     * node and serial number of its augmentation.
+     *
+     * @param builders
+     *            map of builders which were created in the package to which the
+     *            augmentation belongs
+     * @param genTypeName
+     *            string with name of augmented node
+     * @return string with unique name for augmentation builder
      */
     private def String augGenTypeName(Map<String, GeneratedTypeBuilder> builders, String genTypeName) {
         var index = 1;
@@ -1156,28 +1158,28 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return genTypeName + index;
     }
 
-    /**\r
-     * Adds the methods to <code>typeBuilder</code> which represent subnodes of\r
-     * node for which <code>typeBuilder</code> was created.\r
-     *\r
-     * The subnodes aren't mapped to the methods if they are part of grouping or\r
-     * augment (in this case are already part of them).\r
-     *\r
-     * @param module current module\r
-     * @param basePackageName\r
-     *            string contains the module package name\r
-     * @param parent\r
-     *            generated type builder which represents any node. The subnodes\r
-     *            of this node are added to the <code>typeBuilder</code> as\r
-     *            methods. The subnode can be of type leaf, leaf-list, list,\r
-     *            container, choice.\r
-     * @param childOf parent type\r
-     * @param schemaNodes\r
-     *            set of data schema nodes which are the children of the node\r
-     *            for which <code>typeBuilder</code> was created\r
-     * @return generated type builder which is the same builder as input\r
-     *         parameter. The getter methods (representing child nodes) could be\r
-     *         added to it.\r
+    /**
+     * Adds the methods to <code>typeBuilder</code> which represent subnodes of
+     * node for which <code>typeBuilder</code> was created.
+     *
+     * The subnodes aren't mapped to the methods if they are part of grouping or
+     * augment (in this case are already part of them).
+     *
+     * @param module current module
+     * @param basePackageName
+     *            string contains the module package name
+     * @param parent
+     *            generated type builder which represents any node. The subnodes
+     *            of this node are added to the <code>typeBuilder</code> as
+     *            methods. The subnode can be of type leaf, leaf-list, list,
+     *            container, choice.
+     * @param childOf parent type
+     * @param schemaNodes
+     *            set of data schema nodes which are the children of the node
+     *            for which <code>typeBuilder</code> was created
+     * @return generated type builder which is the same builder as input
+     *         parameter. The getter methods (representing child nodes) could be
+     *         added to it.
      */
     private def GeneratedTypeBuilder resolveDataSchemaNodes(Module module, String basePackageName,
         GeneratedTypeBuilder parent, GeneratedTypeBuilder childOf, Set<DataSchemaNode> schemaNodes) {
@@ -1191,25 +1193,25 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return parent;
     }
 
-    /**\r
-     * Adds the methods to <code>typeBuilder</code> what represents subnodes of\r
-     * node for which <code>typeBuilder</code> was created.\r
-     *\r
-     * @param module current module\r
-     * @param basePackageName\r
-     *            string contains the module package name\r
-     * @param typeBuilder\r
-     *            generated type builder which represents any node. The subnodes\r
-     *            of this node are added to the <code>typeBuilder</code> as\r
-     *            methods. The subnode can be of type leaf, leaf-list, list,\r
-     *            container, choice.\r
-     * @param childOf parent type\r
-     * @param schemaNodes\r
-     *            set of data schema nodes which are the children of the node\r
-     *            for which <code>typeBuilder</code> was created\r
-     * @return generated type builder which is the same object as the input\r
-     *         parameter <code>typeBuilder</code>. The getter method could be\r
-     *         added to it.\r
+    /**
+     * Adds the methods to <code>typeBuilder</code> what represents subnodes of
+     * node for which <code>typeBuilder</code> was created.
+     *
+     * @param module current module
+     * @param basePackageName
+     *            string contains the module package name
+     * @param typeBuilder
+     *            generated type builder which represents any node. The subnodes
+     *            of this node are added to the <code>typeBuilder</code> as
+     *            methods. The subnode can be of type leaf, leaf-list, list,
+     *            container, choice.
+     * @param childOf parent type
+     * @param schemaNodes
+     *            set of data schema nodes which are the children of the node
+     *            for which <code>typeBuilder</code> was created
+     * @return generated type builder which is the same object as the input
+     *         parameter <code>typeBuilder</code>. The getter method could be
+     *         added to it.
      */
     private def GeneratedTypeBuilder augSchemaNodeToMethods(Module module, String basePackageName,
         GeneratedTypeBuilder typeBuilder, GeneratedTypeBuilder childOf, Set<DataSchemaNode> schemaNodes) {
@@ -1223,20 +1225,20 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return typeBuilder;
     }
 
-    /**\r
-     * Adds to <code>typeBuilder</code> a method which is derived from\r
-     * <code>schemaNode</code>.\r
-     *\r
-     * @param basePackageName\r
-     *            string with the module package name\r
-     * @param node\r
-     *            data schema node which is added to <code>typeBuilder</code> as\r
-     *            a method\r
-     * @param typeBuilder\r
-     *            generated type builder to which is <code>schemaNode</code>\r
-     *            added as a method.\r
-     * @param childOf parent type\r
-     * @param module current module\r
+    /**
+     * Adds to <code>typeBuilder</code> a method which is derived from
+     * <code>schemaNode</code>.
+     *
+     * @param basePackageName
+     *            string with the module package name
+     * @param node
+     *            data schema node which is added to <code>typeBuilder</code> as
+     *            a method
+     * @param typeBuilder
+     *            generated type builder to which is <code>schemaNode</code>
+     *            added as a method.
+     * @param childOf parent type
+     * @param module current module
      */
     private def void addSchemaNodeToBuilderAsMethod(String basePackageName, DataSchemaNode node,
         GeneratedTypeBuilder typeBuilder, GeneratedTypeBuilder childOf, Module module) {
@@ -1256,28 +1258,28 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Converts <code>choiceNode</code> to the list of generated types for\r
-     * choice and its cases.\r
-     *\r
-     * The package names for choice and for its cases are created as\r
-     * concatenation of the module package (<code>basePackageName</code>) and\r
-     * names of all parents node.\r
-     *\r
-     * @param module current module\r
-     * @param basePackageName\r
-     *            string with the module package name\r
-     * @param parent parent type\r
-     * @param childOf concrete parent for case child nodes\r
-     * @param choiceNode\r
-     *            choice node which is mapped to generated type. Also child\r
-     *            nodes - cases are mapped to generated types.\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if <code>basePackageName</code> equals null</li>\r
-     *             <li>if <code>choiceNode</code> equals null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Converts <code>choiceNode</code> to the list of generated types for
+     * choice and its cases.
+     *
+     * The package names for choice and for its cases are created as
+     * concatenation of the module package (<code>basePackageName</code>) and
+     * names of all parents node.
+     *
+     * @param module current module
+     * @param basePackageName
+     *            string with the module package name
+     * @param parent parent type
+     * @param childOf concrete parent for case child nodes
+     * @param choiceNode
+     *            choice node which is mapped to generated type. Also child
+     *            nodes - cases are mapped to generated types.
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>choiceNode</code> equals null</li>
+     *             </ul>
+     *
      */
     private def void choiceToGeneratedType(Module module, String basePackageName, GeneratedTypeBuilder parent,
         ChoiceNode choiceNode) {
@@ -1294,31 +1296,31 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Converts <code>caseNodes</code> set to list of corresponding generated\r
-     * types.\r
-     *\r
-     * For every <i>case</i> which isn't added through augment or <i>uses</i> is\r
-     * created generated type builder. The package names for the builder is\r
-     * created as concatenation of the module package (\r
-     * <code>basePackageName</code>) and names of all parents nodes of the\r
-     * concrete <i>case</i>. There is also relation "<i>implements type</i>"\r
-     * between every case builder and <i>choice</i> type\r
-     *\r
-     * @param basePackageName\r
-     *            string with the module package name\r
-     * @param refChoiceType\r
-     *            type which represents superior <i>case</i>\r
-     * @param caseNodes\r
-     *            set of choice case nodes which are mapped to generated types\r
-     * @return list of generated types for <code>caseNodes</code>.\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if <code>basePackageName</code> equals null</li>\r
-     *             <li>if <code>refChoiceType</code> equals null</li>\r
-     *             <li>if <code>caseNodes</code> equals null</li>\r
-     *             </ul>\r
-     *             *\r
+    /**
+     * Converts <code>caseNodes</code> set to list of corresponding generated
+     * types.
+     *
+     * For every <i>case</i> which isn't added through augment or <i>uses</i> is
+     * created generated type builder. The package names for the builder is
+     * created as concatenation of the module package (
+     * <code>basePackageName</code>) and names of all parents nodes of the
+     * concrete <i>case</i>. There is also relation "<i>implements type</i>"
+     * between every case builder and <i>choice</i> type
+     *
+     * @param basePackageName
+     *            string with the module package name
+     * @param refChoiceType
+     *            type which represents superior <i>case</i>
+     * @param caseNodes
+     *            set of choice case nodes which are mapped to generated types
+     * @return list of generated types for <code>caseNodes</code>.
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>refChoiceType</code> equals null</li>
+     *             <li>if <code>caseNodes</code> equals null</li>
+     *             </ul>
+     *             *
      */
     private def void generateTypesFromChoiceCases(Module module, String basePackageName,
         GeneratedTypeBuilder choiceParent, Type refChoiceType, ChoiceNode choiceNode) {
@@ -1339,13 +1341,13 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 genCtx.get(module).addCaseType(caseNode.path, caseTypeBuilder)
                 val Set<DataSchemaNode> caseChildNodes = caseNode.childNodes
                 if (caseChildNodes !== null) {
-                    var Object parentNode = null\r
-                    val SchemaPath nodeSp = choiceNode.path\r
-                    val List<QName> nodeNames = nodeSp.path\r
-                    val List<QName> nodeNewNames = new ArrayList(nodeNames)\r
-                    nodeNewNames.remove(nodeNewNames.size - 1)\r
-                    val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)\r
-                    parentNode = findDataSchemaNode(schemaContext, nodeNewSp)\r
+                    var Object parentNode = null
+                    val SchemaPath nodeSp = choiceNode.path
+                    val List<QName> nodeNames = nodeSp.path
+                    val List<QName> nodeNewNames = new ArrayList(nodeNames)
+                    nodeNewNames.remove(nodeNewNames.size - 1)
+                    val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)
+                    parentNode = findDataSchemaNode(schemaContext, nodeNewSp)
 
                     var SchemaNode parent
                     if (parentNode instanceof AugmentationSchema) {
@@ -1363,12 +1365,12 @@ public class BindingGeneratorImpl implements BindingGenerator {
                         }
                         parent = targetSchemaNode
                     } else {
-                        val SchemaPath sp = choiceNode.path\r
-                        val List<QName> names = sp.path\r
-                        val List<QName> newNames = new ArrayList(names)\r
-                        newNames.remove(newNames.size - 1)\r
-                        val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)\r
-                        parent = findDataSchemaNode(schemaContext, newSp)\r
+                        val SchemaPath sp = choiceNode.path
+                        val List<QName> names = sp.path
+                        val List<QName> newNames = new ArrayList(names)
+                        newNames.remove(newNames.size - 1)
+                        val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)
+                        parent = findDataSchemaNode(schemaContext, newSp)
                     }
                     var GeneratedTypeBuilder childOfType = findChildNodeByPath(parent.path)
                     resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, caseChildNodes)
@@ -1379,30 +1381,30 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Generates list of generated types for all the cases of a choice which are\r
-     * added to the choice through the augment.\r
-     *\r
-     *\r
-     * @param basePackageName\r
-     *            string contains name of package to which augment belongs. If\r
-     *            an augmented choice is from an other package (pcg1) than an\r
-     *            augmenting choice (pcg2) then case's of the augmenting choice\r
-     *            will belong to pcg2.\r
-     * @param refChoiceType\r
-     *            Type which represents the choice to which case belongs. Every\r
-     *            case has to contain its choice in extend part.\r
-     * @param caseNodes\r
-     *            set of choice case nodes for which is checked if are/aren't\r
-     *            added to choice through augmentation\r
-     * @return list of generated types which represents augmented cases of\r
-     *         choice <code>refChoiceType</code>\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if <code>basePackageName</code> equals null</li>\r
-     *             <li>if <code>refChoiceType</code> equals null</li>\r
-     *             <li>if <code>caseNodes</code> equals null</li>\r
-     *             </ul>\r
+    /**
+     * Generates list of generated types for all the cases of a choice which are
+     * added to the choice through the augment.
+     *
+     *
+     * @param basePackageName
+     *            string contains name of package to which augment belongs. If
+     *            an augmented choice is from an other package (pcg1) than an
+     *            augmenting choice (pcg2) then case's of the augmenting choice
+     *            will belong to pcg2.
+     * @param refChoiceType
+     *            Type which represents the choice to which case belongs. Every
+     *            case has to contain its choice in extend part.
+     * @param caseNodes
+     *            set of choice case nodes for which is checked if are/aren't
+     *            added to choice through augmentation
+     * @return list of generated types which represents augmented cases of
+     *         choice <code>refChoiceType</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>refChoiceType</code> equals null</li>
+     *             <li>if <code>caseNodes</code> equals null</li>
+     *             </ul>
      */
     private def void generateTypesFromAugmentedChoiceCases(Module module, String basePackageName, Type targetType,
         ChoiceNode targetNode, Set<DataSchemaNode> augmentedNodes) {
@@ -1416,13 +1418,13 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
                 caseTypeBuilder.addImplementsType(targetType);
 
-                var SchemaNode parent = null\r
-                val SchemaPath nodeSp = targetNode.path\r
-                val List<QName> nodeNames = nodeSp.path\r
-                val List<QName> nodeNewNames = new ArrayList(nodeNames)\r
-                nodeNewNames.remove(nodeNewNames.size - 1)\r
-                val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)\r
-                parent = findDataSchemaNode(schemaContext, nodeNewSp)\r
+                var SchemaNode parent = null
+                val SchemaPath nodeSp = targetNode.path
+                val List<QName> nodeNames = nodeSp.path
+                val List<QName> nodeNewNames = new ArrayList(nodeNames)
+                nodeNewNames.remove(nodeNewNames.size - 1)
+                val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)
+                parent = findDataSchemaNode(schemaContext, nodeNewSp)
 
                 var GeneratedTypeBuilder childOfType = null;
                 if (parent instanceof Module) {
@@ -1459,22 +1461,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
     }
 
-    /**\r
-     * Converts <code>leaf</code> to the getter method which is added to\r
-     * <code>typeBuilder</code>.\r
-     *\r
-     * @param typeBuilder\r
-     *            generated type builder to which is added getter method as\r
-     *            <code>leaf</code> mapping\r
-     * @param leaf\r
-     *            leaf schema node which is mapped as getter method which is\r
-     *            added to <code>typeBuilder</code>\r
-     * @return boolean value\r
-     *         <ul>\r
-     *         <li>false - if <code>leaf</code> or <code>typeBuilder</code> are\r
-     *         null</li>\r
-     *         <li>true - in other cases</li>\r
-     *         </ul>\r
+    /**
+     * Converts <code>leaf</code> to the getter method which is added to
+     * <code>typeBuilder</code>.
+     *
+     * @param typeBuilder
+     *            generated type builder to which is added getter method as
+     *            <code>leaf</code> mapping
+     * @param leaf
+     *            leaf schema node which is mapped as getter method which is
+     *            added to <code>typeBuilder</code>
+     * @return boolean value
+     *         <ul>
+     *         <li>false - if <code>leaf</code> or <code>typeBuilder</code> are
+     *         null</li>
+     *         <li>true - in other cases</li>
+     *         </ul>
      */
     private def boolean resolveLeafSchemaNodeAsMethod(GeneratedTypeBuilder typeBuilder, LeafSchemaNode leaf) {
         if ((leaf !== null) && (typeBuilder !== null)) {
@@ -1500,14 +1502,14 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     }
                     (typeProvider as TypeProviderImpl).putReferencedType(leaf.path, returnType);
                 } else if (typeDef instanceof UnionType) {
-                    genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leaf, parentModule);\r
-                    if (genTOBuilder !== null) {\r
-                        returnType = createReturnTypeForUnion(genTOBuilder, typeDef, typeBuilder, parentModule)\r
+                    genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leaf, parentModule);
+                    if (genTOBuilder !== null) {
+                        returnType = createReturnTypeForUnion(genTOBuilder, typeDef, typeBuilder, parentModule)
                     }
                 } else if (typeDef instanceof BitsTypeDefinition) {
-                    genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leaf, parentModule);\r
-                    if (genTOBuilder !== null) {\r
-                        returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);\r
+                    genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leaf, parentModule);
+                    if (genTOBuilder !== null) {
+                        returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
                     }
                 } else {
                     val Restrictions restrictions = BindingGeneratorUtil.getRestrictions(typeDef);
@@ -1579,24 +1581,24 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return null;
     }
 
-    /**\r
-     * Converts <code>leaf</code> schema node to property of generated TO\r
-     * builder.\r
-     *\r
-     * @param toBuilder\r
-     *            generated TO builder to which is <code>leaf</code> added as\r
-     *            property\r
-     * @param leaf\r
-     *            leaf schema node which is added to <code>toBuilder</code> as\r
-     *            property\r
-     * @param isReadOnly\r
-     *            boolean value which says if leaf property is|isn't read only\r
-     * @return boolean value\r
-     *         <ul>\r
-     *         <li>false - if <code>leaf</code>, <code>toBuilder</code> or leaf\r
-     *         name equals null or if leaf is added by <i>uses</i>.</li>\r
-     *         <li>true - other cases</li>\r
-     *         </ul>\r
+    /**
+     * Converts <code>leaf</code> schema node to property of generated TO
+     * builder.
+     *
+     * @param toBuilder
+     *            generated TO builder to which is <code>leaf</code> added as
+     *            property
+     * @param leaf
+     *            leaf schema node which is added to <code>toBuilder</code> as
+     *            property
+     * @param isReadOnly
+     *            boolean value which says if leaf property is|isn't read only
+     * @return boolean value
+     *         <ul>
+     *         <li>false - if <code>leaf</code>, <code>toBuilder</code> or leaf
+     *         name equals null or if leaf is added by <i>uses</i>.</li>
+     *         <li>true - other cases</li>
+     *         </ul>
      */
     private def boolean resolveLeafSchemaNodeAsProperty(GeneratedTOBuilder toBuilder, LeafSchemaNode leaf,
         boolean isReadOnly, Module module) {
@@ -1607,22 +1609,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 leafDesc = "";
             }
 
-            if (leafName !== null) {\r
+            if (leafName !== null) {
                 var Type returnType = null;
-                val TypeDefinition<?> typeDef = leaf.type;\r
-                if (typeDef instanceof UnionTypeDefinition) {\r
-                    // GeneratedType for this type definition should be already created\r
-                    var qname = typeDef.QName\r
-                    var Module unionModule = null\r
-                    if (qname.prefix == null || qname.prefix.empty) {\r
-                        unionModule = module\r
-                    } else {\r
-                        unionModule = findModuleFromImports(module.imports, qname.prefix)\r
-                    }\r
-                    val ModuleContext mc = genCtx.get(unionModule)\r
-                    returnType = mc.typedefs.get(typeDef.path)\r
-                } else {\r
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);\r
+                val TypeDefinition<?> typeDef = leaf.type;
+                if (typeDef instanceof UnionTypeDefinition) {
+                    // GeneratedType for this type definition should be already created
+                    var qname = typeDef.QName
+                    var Module unionModule = null
+                    if (qname.prefix == null || qname.prefix.empty) {
+                        unionModule = module
+                    } else {
+                        unionModule = findModuleFromImports(module.imports, qname.prefix)
+                    }
+                    val ModuleContext mc = genCtx.get(unionModule)
+                    returnType = mc.typedefs.get(typeDef.path)
+                } else {
+                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
                 }
 
                 if (returnType !== null) {
@@ -1640,22 +1642,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return false;
     }
 
-    /**\r
-     * Converts <code>node</code> leaf list schema node to getter method of\r
-     * <code>typeBuilder</code>.\r
-     *\r
-     * @param typeBuilder\r
-     *            generated type builder to which is <code>node</code> added as\r
-     *            getter method\r
-     * @param node\r
-     *            leaf list schema node which is added to\r
-     *            <code>typeBuilder</code> as getter method\r
-     * @return boolean value\r
-     *         <ul>\r
-     *         <li>true - if <code>node</code>, <code>typeBuilder</code>,\r
-     *         nodeName equal null or <code>node</code> is added by <i>uses</i></li>\r
-     *         <li>false - other cases</li>\r
-     *         </ul>\r
+    /**
+     * Converts <code>node</code> leaf list schema node to getter method of
+     * <code>typeBuilder</code>.
+     *
+     * @param typeBuilder
+     *            generated type builder to which is <code>node</code> added as
+     *            getter method
+     * @param node
+     *            leaf list schema node which is added to
+     *            <code>typeBuilder</code> as getter method
+     * @return boolean value
+     *         <ul>
+     *         <li>true - if <code>node</code>, <code>typeBuilder</code>,
+     *         nodeName equal null or <code>node</code> is added by <i>uses</i></li>
+     *         <li>false - other cases</li>
+     *         </ul>
      */
     private def boolean resolveLeafListSchemaNode(GeneratedTypeBuilder typeBuilder, LeafListSchemaNode node) {
         if ((node !== null) && (typeBuilder !== null)) {
@@ -1665,28 +1667,28 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 nodeDesc = "";
             }
             if (nodeName !== null && !node.isAddedByUses()) {
-                val TypeDefinition<?> typeDef = node.type;\r
-                val parentModule = findParentModule(schemaContext, node);\r
-\r
-                var Type returnType = null;\r
-                if (typeDef instanceof EnumTypeDefinition) {\r
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, node);\r
-                    val enumTypeDef = typeDef as EnumTypeDefinition;\r
-                    val enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, nodeName, typeBuilder);\r
-                    returnType = new ReferencedTypeImpl(enumBuilder.packageName, enumBuilder.name);\r
-                    (typeProvider as TypeProviderImpl).putReferencedType(node.path, returnType);\r
-                } else if (typeDef instanceof UnionType) {\r
-                    val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, node, parentModule);\r
-                    if (genTOBuilder !== null) {\r
-                        returnType = createReturnTypeForUnion(genTOBuilder, typeDef, typeBuilder, parentModule)\r
+                val TypeDefinition<?> typeDef = node.type;
+                val parentModule = findParentModule(schemaContext, node);
+
+                var Type returnType = null;
+                if (typeDef instanceof EnumTypeDefinition) {
+                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, node);
+                    val enumTypeDef = typeDef as EnumTypeDefinition;
+                    val enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, nodeName, typeBuilder);
+                    returnType = new ReferencedTypeImpl(enumBuilder.packageName, enumBuilder.name);
+                    (typeProvider as TypeProviderImpl).putReferencedType(node.path, returnType);
+                } else if (typeDef instanceof UnionType) {
+                    val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, node, parentModule);
+                    if (genTOBuilder !== null) {
+                        returnType = createReturnTypeForUnion(genTOBuilder, typeDef, typeBuilder, parentModule)
                     }
-                } else if (typeDef instanceof BitsTypeDefinition) {\r
-                    val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, node, parentModule);\r
-                    returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);\r
-                } else {\r
-                    val Restrictions restrictions = BindingGeneratorUtil.getRestrictions(typeDef);\r
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, node, restrictions);\r
-                }\r
+                } else if (typeDef instanceof BitsTypeDefinition) {
+                    val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, node, parentModule);
+                    returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
+                } else {
+                    val Restrictions restrictions = BindingGeneratorUtil.getRestrictions(typeDef);
+                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, node, restrictions);
+                }
 
                 val listType = Types.listTypeFor(returnType);
                 constructGetter(typeBuilder, nodeName.localName, nodeDesc, listType);
@@ -1695,7 +1697,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         return false;
     }
-\r
+
     private def Type createReturnTypeForUnion(GeneratedTOBuilder genTOBuilder, TypeDefinition<?> typeDef,
         GeneratedTypeBuilder typeBuilder, Module parentModule) {
         val Type returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
@@ -1703,7 +1705,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         genTOBuilder.setIsUnion(true);
         (typeProvider as TypeProviderImpl).addUnitsToGenTO(genTOBuilder, typeDef.getUnits());
 
-        // union builder\r
+        // union builder
         val GeneratedTOBuilder unionBuilder = new GeneratedTOBuilderImpl(typeBuilder.getPackageName(),
             genTOBuilder.getName() + "Builder");
         unionBuilder.setIsUnionBuilder(true);
@@ -1721,38 +1723,38 @@ public class BindingGeneratorImpl implements BindingGenerator {
             types.add(unionBuilder.toInstance)
         }
         return returnType
-    }\r
+    }
 
     private def GeneratedTypeBuilder addDefaultInterfaceDefinition(String packageName, SchemaNode schemaNode) {
         return addDefaultInterfaceDefinition(packageName, schemaNode, null);
     }
 
-    /**\r
-     * Instantiates generated type builder with <code>packageName</code> and\r
-     * <code>schemaNode</code>.\r
-     *\r
-     * The new builder always implements\r
-     * {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.<br />\r
-     * If <code>schemaNode</code> is instance of GroupingDefinition it also\r
-     * implements {@link org.opendaylight.yangtools.yang.binding.Augmentable\r
-     * Augmentable}.<br />\r
-     * If <code>schemaNode</code> is instance of\r
-     * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer\r
-     * DataNodeContainer} it can also implement nodes which are specified in\r
-     * <i>uses</i>.\r
-     *\r
-     * @param packageName\r
-     *            string with the name of the package to which\r
-     *            <code>schemaNode</code> belongs.\r
-     * @param schemaNode\r
-     *            schema node for which is created generated type builder\r
-     * @param parent parent type (can be null)\r
-     * @return generated type builder <code>schemaNode</code>\r
+    /**
+     * Instantiates generated type builder with <code>packageName</code> and
+     * <code>schemaNode</code>.
+     *
+     * The new builder always implements
+     * {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.<br />
+     * If <code>schemaNode</code> is instance of GroupingDefinition it also
+     * implements {@link org.opendaylight.yangtools.yang.binding.Augmentable
+     * Augmentable}.<br />
+     * If <code>schemaNode</code> is instance of
+     * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer
+     * DataNodeContainer} it can also implement nodes which are specified in
+     * <i>uses</i>.
+     *
+     * @param packageName
+     *            string with the name of the package to which
+     *            <code>schemaNode</code> belongs.
+     * @param schemaNode
+     *            schema node for which is created generated type builder
+     * @param parent parent type (can be null)
+     * @return generated type builder <code>schemaNode</code>
      */
     private def GeneratedTypeBuilder addDefaultInterfaceDefinition(String packageName, SchemaNode schemaNode,
         Type parent) {
-        val it = addRawInterfaceDefinition(packageName, schemaNode, "");\r
-        qnameConstant(BindingMapping.QNAME_STATIC_FIELD_NAME,schemaNode.QName);\r
+        val it = addRawInterfaceDefinition(packageName, schemaNode, "");
+        qnameConstant(BindingMapping.QNAME_STATIC_FIELD_NAME,schemaNode.QName);
         if (parent === null) {
             addImplementsType(DATA_OBJECT);
         } else {
@@ -1769,43 +1771,43 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return it;
     }
 
-    /**\r
-     * Wraps the calling of the same overloaded method.\r
-     *\r
-     * @param packageName\r
-     *            string with the package name to which returning generated type\r
-     *            builder belongs\r
-     * @param schemaNode\r
-     *            schema node which provide data about the schema node name\r
-     * @return generated type builder for <code>schemaNode</code>\r
+    /**
+     * Wraps the calling of the same overloaded method.
+     *
+     * @param packageName
+     *            string with the package name to which returning generated type
+     *            builder belongs
+     * @param schemaNode
+     *            schema node which provide data about the schema node name
+     * @return generated type builder for <code>schemaNode</code>
      */
     private def GeneratedTypeBuilder addRawInterfaceDefinition(String packageName, SchemaNode schemaNode) {
         return addRawInterfaceDefinition(packageName, schemaNode, "");
     }
 
-    /**\r
-     * Returns reference to generated type builder for specified\r
-     * <code>schemaNode</code> with <code>packageName</code>.\r
-     *\r
-     * Firstly the generated type builder is searched in\r
-     * {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. If it isn't\r
-     * found it is created and added to <code>genTypeBuilders</code>.\r
-     *\r
-     * @param packageName\r
-     *            string with the package name to which returning generated type\r
-     *            builder belongs\r
-     * @param schemaNode\r
-     *            schema node which provide data about the schema node name\r
-     * @param prefix return type name prefix\r
-     * @return generated type builder for <code>schemaNode</code>\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if <code>schemaNode</code> equals null</li>\r
-     *             <li>if <code>packageName</code> equals null</li>\r
-     *             <li>if Q name of schema node is null</li>\r
-     *             <li>if schema node name is null</li>\r
-     *             </ul>\r
-     *\r
+    /**
+     * Returns reference to generated type builder for specified
+     * <code>schemaNode</code> with <code>packageName</code>.
+     *
+     * Firstly the generated type builder is searched in
+     * {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. If it isn't
+     * found it is created and added to <code>genTypeBuilders</code>.
+     *
+     * @param packageName
+     *            string with the package name to which returning generated type
+     *            builder belongs
+     * @param schemaNode
+     *            schema node which provide data about the schema node name
+     * @param prefix return type name prefix
+     * @return generated type builder for <code>schemaNode</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>schemaNode</code> equals null</li>
+     *             <li>if <code>packageName</code> equals null</li>
+     *             <li>if Q name of schema node is null</li>
+     *             <li>if schema node name is null</li>
+     *             </ul>
+     *
      */
     private def GeneratedTypeBuilder addRawInterfaceDefinition(String packageName, SchemaNode schemaNode,
         String prefix) {
@@ -1822,7 +1824,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             genTypeName = prefix + BindingMapping.getClassName(schemaNodeName);
         }
 
-        //FIXME: Validation of name conflict\r
+        //FIXME: Validation of name conflict
         val newType = new GeneratedTypeBuilderImpl(packageName, genTypeName);
         if (!genTypeBuilders.containsKey(packageName)) {
             val Map<String, GeneratedTypeBuilder> builders = new HashMap();
@@ -1837,14 +1839,14 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return newType;
     }
 
-    /**\r
-     * Creates the name of the getter method from <code>methodName</code>.\r
-     *\r
-     * @param methodName\r
-     *            string with the name of the getter method\r
-     * @param returnType return type\r
-     * @return string with the name of the getter method for\r
-     *         <code>methodName</code> in JAVA method format\r
+    /**
+     * Creates the name of the getter method from <code>methodName</code>.
+     *
+     * @param methodName
+     *            string with the name of the getter method
+     * @param returnType return type
+     * @return string with the name of the getter method for
+     *         <code>methodName</code> in JAVA method format
      */
     public static def String getterMethodName(String localName, Type returnType) {
         val method = new StringBuilder();
@@ -1857,26 +1859,26 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return method.toString();
     }
 
-    /**\r
-     * Created a method signature builder as part of\r
-     * <code>interfaceBuilder</code>.\r
-     *\r
-     * The method signature builder is created for the getter method of\r
-     * <code>schemaNodeName</code>. Also <code>comment</code> and\r
-     * <code>returnType</code> information are added to the builder.\r
-     *\r
-     * @param interfaceBuilder\r
-     *            generated type builder for which the getter method should be\r
-     *            created\r
-     * @param schemaNodeName\r
-     *            string with schema node name. The name will be the part of the\r
-     *            getter method name.\r
-     * @param comment\r
-     *            string with comment for the getter method\r
-     * @param returnType\r
-     *            type which represents the return type of the getter method\r
-     * @return method signature builder which represents the getter method of\r
-     *         <code>interfaceBuilder</code>\r
+    /**
+     * Created a method signature builder as part of
+     * <code>interfaceBuilder</code>.
+     *
+     * The method signature builder is created for the getter method of
+     * <code>schemaNodeName</code>. Also <code>comment</code> and
+     * <code>returnType</code> information are added to the builder.
+     *
+     * @param interfaceBuilder
+     *            generated type builder for which the getter method should be
+     *            created
+     * @param schemaNodeName
+     *            string with schema node name. The name will be the part of the
+     *            getter method name.
+     * @param comment
+     *            string with comment for the getter method
+     * @param returnType
+     *            type which represents the return type of the getter method
+     * @return method signature builder which represents the getter method of
+     *         <code>interfaceBuilder</code>
      */
     private def MethodSignatureBuilder constructGetter(GeneratedTypeBuilder interfaceBuilder, String schemaNodeName,
         String comment, Type returnType) {
@@ -1886,28 +1888,28 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return getMethod;
     }
 
-    /**\r
-     * Adds <code>schemaNode</code> to <code>typeBuilder</code> as getter method\r
-     * or to <code>genTOBuilder</code> as property.\r
-     *\r
-     * @param basePackageName\r
-     *            string contains the module package name\r
-     * @param schemaNode\r
-     *            data schema node which should be added as getter method to\r
-     *            <code>typeBuilder</code> or as a property to\r
-     *            <code>genTOBuilder</code> if is part of the list key\r
-     * @param typeBuilder\r
-     *            generated type builder for the list schema node\r
-     * @param genTOBuilder\r
-     *            generated TO builder for the list keys\r
-     * @param listKeys\r
-     *            list of string which contains names of the list keys\r
-     * @param module current module\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if <code>schemaNode</code> equals null</li>\r
-     *             <li>if <code>typeBuilder</code> equals null</li>\r
-     *             </ul>\r
+    /**
+     * Adds <code>schemaNode</code> to <code>typeBuilder</code> as getter method
+     * or to <code>genTOBuilder</code> as property.
+     *
+     * @param basePackageName
+     *            string contains the module package name
+     * @param schemaNode
+     *            data schema node which should be added as getter method to
+     *            <code>typeBuilder</code> or as a property to
+     *            <code>genTOBuilder</code> if is part of the list key
+     * @param typeBuilder
+     *            generated type builder for the list schema node
+     * @param genTOBuilder
+     *            generated TO builder for the list keys
+     * @param listKeys
+     *            list of string which contains names of the list keys
+     * @param module current module
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>schemaNode</code> equals null</li>
+     *             <li>if <code>typeBuilder</code> equals null</li>
+     *             </ul>
      */
     private def void addSchemaNodeToListBuilders(String basePackageName, DataSchemaNode schemaNode,
         GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder, List<String> listKeys, Module module) {
@@ -1916,7 +1918,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         if (schemaNode instanceof LeafSchemaNode) {
             val leaf = schemaNode as LeafSchemaNode;
-            val leafName = leaf.QName.localName;\r
+            val leafName = leaf.QName.localName;
             resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);
             if (listKeys.contains(leafName)) {
                 resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true, module)
@@ -1944,15 +1946,15 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
     }
 
-    /**\r
-     * Selects the names of the list keys from <code>list</code> and returns\r
-     * them as the list of the strings\r
-     *\r
-     * @param list\r
-     *            of string with names of the list keys\r
-     * @return list of string which represents names of the list keys. If the\r
-     *         <code>list</code> contains no keys then the empty list is\r
-     *         returned.\r
+    /**
+     * Selects the names of the list keys from <code>list</code> and returns
+     * them as the list of the strings
+     *
+     * @param list
+     *            of string with names of the list keys
+     * @return list of string which represents names of the list keys. If the
+     *         <code>list</code> contains no keys then the empty list is
+     *         returned.
      */
     private def listKeys(ListSchemaNode list) {
         val List<String> listKeys = new ArrayList();
@@ -1966,17 +1968,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return listKeys;
     }
 
-    /**\r
-     * Generates for the <code>list</code> which contains any list keys special\r
-     * generated TO builder.\r
-     *\r
-     * @param packageName\r
-     *            string with package name to which the list belongs\r
-     * @param list\r
-     *            list schema node which is source of data about the list name\r
-     * @return generated TO builder which represents the keys of the\r
-     *         <code>list</code> or null if <code>list</code> is null or list of\r
-     *         key definitions is null or empty.\r
+    /**
+     * Generates for the <code>list</code> which contains any list keys special
+     * generated TO builder.
+     *
+     * @param packageName
+     *            string with package name to which the list belongs
+     * @param list
+     *            list schema node which is source of data about the list name
+     * @return generated TO builder which represents the keys of the
+     *         <code>list</code> or null if <code>list</code> is null or list of
+     *         key definitions is null or empty.
      */
     private def GeneratedTOBuilder resolveListKeyTOBuilder(String packageName, ListSchemaNode list) {
         var GeneratedTOBuilder genTOBuilder = null;
@@ -1988,54 +1990,54 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return genTOBuilder;
     }
 
-    /**\r
-     * Builds generated TO builders for <code>typeDef</code> of type\r
-     * {@link org.opendaylight.yangtools.yang.model.util.UnionType UnionType} or\r
-     * {@link org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition\r
-     * BitsTypeDefinition} which are also added to <code>typeBuilder</code> as\r
-     * enclosing transfer object.\r
-     *\r
-     * If more then one generated TO builder is created for enclosing then all\r
-     * of the generated TO builders are added to <code>typeBuilder</code> as\r
-     * enclosing transfer objects.\r
-     *\r
-     * @param typeDef\r
-     *            type definition which can be of type <code>UnionType</code> or\r
-     *            <code>BitsTypeDefinition</code>\r
-     * @param typeBuilder\r
-     *            generated type builder to which is added generated TO created\r
-     *            from <code>typeDef</code>\r
-     * @param leafName\r
-     *            string with name for generated TO builder\r
-     * @param leaf\r
-     * @param parentModule\r
-     * @return generated TO builder for <code>typeDef</code>\r
+    /**
+     * Builds generated TO builders for <code>typeDef</code> of type
+     * {@link org.opendaylight.yangtools.yang.model.util.UnionType UnionType} or
+     * {@link org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition
+     * BitsTypeDefinition} which are also added to <code>typeBuilder</code> as
+     * enclosing transfer object.
+     *
+     * If more then one generated TO builder is created for enclosing then all
+     * of the generated TO builders are added to <code>typeBuilder</code> as
+     * enclosing transfer objects.
+     *
+     * @param typeDef
+     *            type definition which can be of type <code>UnionType</code> or
+     *            <code>BitsTypeDefinition</code>
+     * @param typeBuilder
+     *            generated type builder to which is added generated TO created
+     *            from <code>typeDef</code>
+     * @param leafName
+     *            string with name for generated TO builder
+     * @param leaf
+     * @param parentModule
+     * @return generated TO builder for <code>typeDef</code>
      */
     private def GeneratedTOBuilder addTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,
         DataSchemaNode leaf, Module parentModule) {
         val classNameFromLeaf = BindingMapping.getClassName(leaf.QName);
         val List<GeneratedTOBuilder> genTOBuilders = new ArrayList();
         val packageName = typeBuilder.fullyQualifiedName;
-        if (typeDef instanceof UnionTypeDefinition) {\r
-            val List<GeneratedTOBuilder> types = (typeProvider as TypeProviderImpl).\r
-                    provideGeneratedTOBuildersForUnionTypeDef(packageName, (typeDef as UnionTypeDefinition),\r
+        if (typeDef instanceof UnionTypeDefinition) {
+            val List<GeneratedTOBuilder> types = (typeProvider as TypeProviderImpl).
+                    provideGeneratedTOBuildersForUnionTypeDef(packageName, (typeDef as UnionTypeDefinition),
                         classNameFromLeaf, leaf); 
-            genTOBuilders.addAll(types);\r
-                        \r
-            \r
-        var GeneratedTOBuilder resultTOBuilder = null;\r
-        if (!types.isEmpty()) {\r
-            resultTOBuilder = types.remove(0);\r
-            for (GeneratedTOBuilder genTOBuilder : types) {\r
-                resultTOBuilder.addEnclosingTransferObject(genTOBuilder);\r
-            }\r
-        }\r
-\r
-        val GeneratedPropertyBuilder genPropBuilder = resultTOBuilder.addProperty("value");\r
-        genPropBuilder.setReturnType(Types.primitiveType("char[]", null));\r
-        resultTOBuilder.addEqualsIdentity(genPropBuilder);\r
-        resultTOBuilder.addHashIdentity(genPropBuilder);\r
-        resultTOBuilder.addToStringProperty(genPropBuilder);\r
+            genTOBuilders.addAll(types);
+                        
+            
+        var GeneratedTOBuilder resultTOBuilder = null;
+        if (!types.isEmpty()) {
+            resultTOBuilder = types.remove(0);
+            for (GeneratedTOBuilder genTOBuilder : types) {
+                resultTOBuilder.addEnclosingTransferObject(genTOBuilder);
+            }
+        }
+
+        val GeneratedPropertyBuilder genPropBuilder = resultTOBuilder.addProperty("value");
+        genPropBuilder.setReturnType(Types.primitiveType("char[]", null));
+        resultTOBuilder.addEqualsIdentity(genPropBuilder);
+        resultTOBuilder.addHashIdentity(genPropBuilder);
+        resultTOBuilder.addToStringProperty(genPropBuilder);
 
         } else if (typeDef instanceof BitsTypeDefinition) {
             genTOBuilders.add(
@@ -2052,21 +2054,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
     }
 
-    /**\r
-     * Adds the implemented types to type builder.\r
-     *\r
-     * The method passes through the list of <i>uses</i> in\r
-     * {@code dataNodeContainer}. For every <i>use</i> is obtained corresponding\r
-     * generated type from {@link BindingGeneratorImpl#allGroupings\r
-     * allGroupings} which is added as <i>implements type</i> to\r
-     * <code>builder</code>\r
-     *\r
-     * @param dataNodeContainer\r
-     *            element which contains the list of used YANG groupings\r
-     * @param builder\r
-     *            builder to which are added implemented types according to\r
-     *            <code>dataNodeContainer</code>\r
-     * @return generated type builder with all implemented types\r
+    /**
+     * Adds the implemented types to type builder.
+     *
+     * The method passes through the list of <i>uses</i> in
+     * {@code dataNodeContainer}. For every <i>use</i> is obtained corresponding
+     * generated type from {@link BindingGeneratorImpl#allGroupings
+     * allGroupings} which is added as <i>implements type</i> to
+     * <code>builder</code>
+     *
+     * @param dataNodeContainer
+     *            element which contains the list of used YANG groupings
+     * @param builder
+     *            builder to which are added implemented types according to
+     *            <code>dataNodeContainer</code>
+     * @return generated type builder with all implemented types
      */
     private def addImplementedInterfaceFromUses(DataNodeContainer dataNodeContainer, GeneratedTypeBuilder builder) {
         for (usesNode : dataNodeContainer.uses) {
@@ -2111,16 +2113,16 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         return null
     }
-\r
-    private def Module getParentModule(SchemaNode node) {\r
-        val QName qname = node.getPath().getPath().get(0);\r
-        val URI namespace = qname.getNamespace();\r
-        val Date revision = qname.getRevision();\r
-        return schemaContext.findModuleByNamespaceAndRevision(namespace, revision);\r
-    }\r
-\r
-    public def getModuleContexts() {\r
-        genCtx;\r
-    }\r
-\r
+
+    private def Module getParentModule(SchemaNode node) {
+        val QName qname = node.getPath().getPath().get(0);
+        val URI namespace = qname.getNamespace();
+        val Date revision = qname.getRevision();
+        return schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
+    }
+
+    public def getModuleContexts() {
+        genCtx;
+    }
+
 }
index 0091d366971549f40036f037752268a4a04d5afd..d0aa79bc9bc497574840b78598d004cdb57b9614 100644 (file)
@@ -1,13 +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.generator.spi;\r
-\r
-public interface TypeProviderFactory {\r
-\r
-    TypeProvider providerFor(YANGModuleIdentifier module);\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.yang.model.api.ModuleIdentifier;
+
+//FIXME not implemented anywhere
+public interface TypeProviderFactory {
+
+    TypeProvider providerFor(ModuleIdentifier module);
+}
diff --git a/code-generator/binding-generator-spi/src/main/java/org/opendaylight/yangtools/sal/binding/generator/spi/YANGModuleIdentifier.java b/code-generator/binding-generator-spi/src/main/java/org/opendaylight/yangtools/sal/binding/generator/spi/YANGModuleIdentifier.java
deleted file mode 100644 (file)
index d948cde..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.sal.binding.generator.spi;
-
-import java.net.URI;
-import java.util.Date;
-
-
-public class YANGModuleIdentifier {
-    private String name;
-    private URI namespace;
-    private Date revision;
-
-    /**
-     * Returns name.
-     * 
-     * @return string with name
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * Returns URI namespace.
-     * 
-     * @return URI with namespace
-     */
-    public URI getNamespace() {
-        return this.namespace;
-    }
-
-    /**
-     * Returns the revision date.
-     * 
-     * @return date of revision
-     */
-    public Date getRevision() {
-        return this.revision;
-    }
-}
index f062b66784307481c71bb72da81e79445803abfd..7c9df45b4db526ac2e2bd66798febaf39e03556b 100644 (file)
@@ -17,7 +17,7 @@
     <packaging>bundle</packaging>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>concepts</artifactId>
-    <name>Concepts</name>
+    <name>${project.artifactId}</name>
     <description>Java binding for YANG</description>
 
     <build>
index 7c322ac3e2c2b6682fede9fdbfec038e8758df52..8854863e55859c0eb1ad343055970d53b14b88ab 100644 (file)
@@ -24,5 +24,13 @@ public abstract class AbstractObjectRegistration<T> extends AbstractRegistration
     public final T getInstance() {
         return instance;
     }
+
+
+    @Override
+    public String toString() {
+        return "AbstractObjectRegistration{" +
+                "instance=" + instance +
+                '}';
+    }
 }
 
diff --git a/pom.xml b/pom.xml
index a661458631e158ec81cc21148af33d61098eac6e..37399eff88b7163690ef34c9e5152d53196ad46c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,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
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
     <artifactId>yangtools</artifactId>
                 <artifactId>plexus-slf4j-logging</artifactId>
                 <version>1.1</version>
             </dependency>
+            <dependency>
+                <groupId>commons-io</groupId>
+                <artifactId>commons-io</artifactId>
+                <version>2.4</version>
+            </dependency>
 
-           <!-- Our artifacts -->
-           <dependency>
-                   <groupId>${project.groupId}</groupId>
-                   <artifactId>concepts</artifactId>
-                   <version>${project.version}</version>
-           </dependency>
+
+            <!-- Our artifacts -->
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>concepts</artifactId>
+                <version>${project.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
                     <configuration>
                         <instructions>
                             <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
-<!--
-                            <Export-Package>*</Export-Package>
--->
+                            <!--
+                                                        <Export-Package>*</Export-Package>
+                            -->
                         </instructions>
                     </configuration>
                 </plugin>
                                         </goals>
                                     </pluginExecutionFilter>
                                     <action>
-                                        <execute />
+                                        <execute/>
                                     </action>
                                 </pluginExecution>
                             </pluginExecutions>
index c22dd7ca01cfadb7a59ebace6ee0edf5d1ac2687..be73c409162a326019932a10d3226d93ab439af7 100644 (file)
                 <artifactId>concepts</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.apache.commons</groupId>
-                <artifactId>commons-io</artifactId>
-                <version>1.3.2</version>
-            </dependency>
             <dependency>
                 <groupId>org.glassfish.jersey.ext</groupId>
                 <artifactId>jersey-proxy-client</artifactId>
                 <version>1.1.1</version>
             </dependency>
 
-            <dependency>
-                <groupId>commons-io</groupId>
-                <artifactId>commons-io</artifactId>
-                <version>2.4</version>
-            </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-model-util</artifactId>
index 379c1f7cdb454b0f15cc4d4aa7c3a18ebcb8a8f8..00aaccc1ff3af27ef0ea38c8e9a80ae98d5e72e1 100644 (file)
@@ -7,19 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.common;
 
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
 
 /**
  * The QName from XML consists of local name of element and XML namespace, but
@@ -47,17 +48,7 @@ public final class QName implements Immutable,Serializable {
 
     protected static final Logger LOGGER = LoggerFactory.getLogger(QName.class);
 
-    private static final ThreadLocal<SimpleDateFormat> REVISION_FORMAT = new ThreadLocal<SimpleDateFormat>() {
-
-        protected SimpleDateFormat initialValue() {
-            return new SimpleDateFormat("yyyy-MM-dd");
-        };
-
-        public void set(SimpleDateFormat value) {
-            throw new UnsupportedOperationException();
-        };
 
-    };
     static final String QNAME_REVISION_DELIMITER = "?revision=";
     static final String QNAME_LEFT_PARENTHESIS = "(";
     static final String QNAME_RIGHT_PARENTHESIS = ")";
@@ -92,7 +83,7 @@ public final class QName implements Immutable,Serializable {
         this.revision = revision;
         this.prefix = prefix;
         if(revision != null) {
-            this.formattedRevision = REVISION_FORMAT.get().format(revision);
+            this.formattedRevision = getRevisionFormat().format(revision);
         } else {
             this.formattedRevision = null;
         }
@@ -157,7 +148,7 @@ public final class QName implements Immutable,Serializable {
         if (nsAndRev.contains("?")) {
             String[] splitted = nsAndRev.split("\\?");
             this.namespace = URI.create(splitted[0]);
-            revision = REVISION_FORMAT.get().parse(splitted[1]);
+            revision = getRevisionFormat().parse(splitted[1]);
         } else {
             this.namespace = URI.create(nsAndRev);
         }
@@ -166,7 +157,7 @@ public final class QName implements Immutable,Serializable {
         this.revision = revision;
         this.prefix = null;
         if (revision != null) {
-            this.formattedRevision = REVISION_FORMAT.get().format(revision);
+            this.formattedRevision = getRevisionFormat().format(revision);
         } else {
             this.formattedRevision = null;
         }
@@ -315,7 +306,7 @@ public final class QName implements Immutable,Serializable {
             sb.append(QNAME_LEFT_PARENTHESIS + namespace);
 
             if (revision != null) {
-                sb.append(QNAME_REVISION_DELIMITER + REVISION_FORMAT.get().format(revision));
+                sb.append(QNAME_REVISION_DELIMITER + getRevisionFormat().format(revision));
             }
             sb.append(QNAME_RIGHT_PARENTHESIS);
         }
@@ -365,7 +356,7 @@ public final class QName implements Immutable,Serializable {
 
     public static Date parseRevision(String formatedDate) {
         try {
-            return REVISION_FORMAT.get().parse(formatedDate);
+            return getRevisionFormat().parse(formatedDate);
         } catch (ParseException| RuntimeException e) {
             throw new IllegalArgumentException("Revision is not in supported format:" + formatedDate,e);
         }
@@ -375,7 +366,7 @@ public final class QName implements Immutable,Serializable {
         if(revision == null) {
             return null;
         }
-        return REVISION_FORMAT.get().format(revision);
+        return getRevisionFormat().format(revision);
     }
 
     public boolean isEqualWithoutRevision(QName other) {
diff --git a/yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/SimpleDateFormatUtil.java b/yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/SimpleDateFormatUtil.java
new file mode 100644 (file)
index 0000000..fd50c95
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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.yang.common;
+
+import java.text.SimpleDateFormat;
+
+public class SimpleDateFormatUtil {
+
+    private static final ThreadLocal<SimpleDateFormat> REVISION_FORMAT = new ThreadLocal<SimpleDateFormat>() {
+
+        protected SimpleDateFormat initialValue() {
+            return new SimpleDateFormat("yyyy-MM-dd");
+        };
+
+        public void set(SimpleDateFormat value) {
+            throw new UnsupportedOperationException();
+        };
+
+    };
+
+    public static SimpleDateFormat getRevisionFormat() {
+        return REVISION_FORMAT.get();
+    }
+}
index c66c21a80a52c92fb022e0c3e84e138d71219090..8ffa8204c2ec04fc49f8815ab0b226a68fccdbd8 100644 (file)
@@ -73,7 +73,6 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.4</version>
         </dependency>
 
         <dependency>
index 9efe633ffafc57c6f39b604e807fcd1a25c410ad..fa0fa27e41eccebf34763935df4f1fbcbb9a4699 100644 (file)
@@ -7,18 +7,8 @@
  */
 package org.opendaylight.yangtools.yang2sources.plugin;
 
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Maps;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -36,8 +26,19 @@ import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
 import org.sonatype.plexus.build.incremental.BuildContext;
 import org.sonatype.plexus.build.incremental.DefaultBuildContext;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Maps;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
 
 class YangToSourcesProcessor {
     static final String LOG_PREFIX = "yang-to-sources:";
@@ -148,7 +149,8 @@ class YangToSourcesProcessor {
 
                 projectYangModules = new HashSet<>();
                 for (InputStream inProject : yangsInProject) {
-                    projectYangModules.add(allYangModules.get(inProject));
+                    Module module = checkNotNull(allYangModules.get(inProject), "Cannot find module by %s", inProject);
+                    projectYangModules.add(module);
                 }
 
             } finally {
index 8b9915e209a4089e37c98e30e747a4ed85007dad..8f16814a374300e594ba11c54680a0ec6c09c63f 100644 (file)
@@ -25,5 +25,9 @@
             <groupId>${project.groupId}</groupId>
             <artifactId>yang-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
     </dependencies>
 </project>
index d6c4966c70c62d988081110d27b6283f62c9119b..16fda82ed4761af26b7c381b54a4fdb32f4ebe8e 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
@@ -57,33 +55,8 @@ import java.util.Set;
     </code>
  */
 
-public interface Module extends DataNodeContainer, SourceStreamAware {
+public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIdentifier {
 
-    /**
-     * Returns the namespace of the module which is specified as argument of
-     * YANG {@link Module <b><font color="#00FF00">namespace</font></b>}
-     * keyword.
-     *
-     * @return URI format of the namespace of the module
-     */
-    URI getNamespace();
-
-    /**
-     * Returns the name of the module which is specified as argument of YANG
-     * {@link Module <b><font color="#FF0000">module</font></b>} keyword
-     *
-     * @return string with the name of the module
-     */
-    String getName();
-
-    /**
-     * Returns the revision date for the module.
-     *
-     * @return date of the module revision which is specified as argument of
-     *         YANG {@link Module <b><font color="#339900">revison</font></b>}
-     *         keyword
-     */
-    Date getRevision();
 
     /**
      * Returns the prefix of the module
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleIdentifier.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleIdentifier.java
new file mode 100644 (file)
index 0000000..a1e8b43
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.yang.model.api;
+
+import java.net.URI;
+import java.util.Date;
+
+
+public interface ModuleIdentifier {
+
+    /**
+     * Returns the namespace of the module which is specified as argument of
+     * YANG {@link Module <b><font color="#00FF00">namespace</font></b>}
+     * keyword.
+     *
+     * @return URI format of the namespace of the module
+     */
+    URI getNamespace();
+
+    /**
+     * Returns the name of the module which is specified as argument of YANG
+     * {@link Module <b><font color="#FF0000">module</font></b>} keyword
+     *
+     * @return string with the name of the module
+     */
+    String getName();
+
+    /**
+     * Returns the revision date for the module.
+     *
+     * @return date of the module revision which is specified as argument of
+     *         YANG {@link Module <b><font color="#339900">revison</font></b>}
+     *         keyword
+     */
+    Date getRevision();
+}
index e51e4684323f63df9bd14fa6f6501ce1b48a034e..ecafe233a4fa210b52943408f63a7d0ba7e03964 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+import com.google.common.base.Optional;
+import org.opendaylight.yangtools.yang.common.QName;
+
 import java.net.URI;
 import java.util.Date;
 import java.util.Set;
 
-import org.opendaylight.yangtools.yang.common.QName;
-
 /**
  * The interface contains the methods for manipulating all the top level context
  * data (data from all red modules) like YANG notifications, extensions,
@@ -104,4 +105,20 @@ public interface SchemaContext extends ContainerSchemaNode {
      */
     Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision);
 
+
+    /**
+     * Get yang source code represented as string for matching
+     * {@link org.opendaylight.yangtools.yang.model.api.ModuleIdentifier}.
+     * @param moduleIdentifier must provide a non-null
+     * {@link org.opendaylight.yangtools.yang.model.api.ModuleIdentifier#getName()},
+     * other methods might return null.
+     * @return value iif matching module is found in schema context.
+     */
+    Optional<String> getModuleSource(ModuleIdentifier moduleIdentifier);
+
+    /**
+     * Get all module and submodule identifiers.
+     */
+    Set<ModuleIdentifier> getAllModuleIdentifiers();
+
 }
index 4ed6617eeb34d739630aa01797e6c46003605c78..a05a3a15c41518b4242069cbdd82be31e1784a47 100644 (file)
@@ -7,8 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+// TODO: merge into Module, makes no sense as standalone interface
 public interface SourceStreamAware {
 
+    /**
+     * Get descriptive source path (usually file path) from which this module was parsed.
+     */
     String getModuleSourcePath();
 
 }
index 0ab1a29f302e29de50a7c6374ba5ff8414f70ae9..02d488d4206f7088f1b3c32bf82eda5937f142de 100644 (file)
@@ -7,21 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.model.parser.api;
 
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
+
 import java.io.File;
 import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
-
 /**
  * Yang Model Parser interface is designed for parsing yang models and convert
  * the information to Data Schema Tree.
  * 
  */
+// refactor methods returning input streams, after introducing
 public interface YangModelParser {
 
     /**
@@ -107,6 +108,8 @@ public interface YangModelParser {
      *            yang streams to parse
      * @return Map of Yang Modules
      */
+    //TODO: when working with input streams do not swallow IOException, it should be propagated without having to wrap it in a runtime exception
+    //FIXME: it is not defined in which state are the returning streams.
     Map<InputStream, Module> parseYangModelsFromStreamsMapped(final List<InputStream> yangModelStreams);
 
     /**
index fae3b6ebd2d8078312cd3c225e17856c381dfaf1..0231aa80c6f513ba36b134c6c918381426a38107 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>concepts</artifactId>
         </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
index e21e9f0483a1797161c5d0198ff0b4cb879109d1..4350692632ef0eb2d159e6dd2ac253ba742581f3 100644 (file)
@@ -7,17 +7,48 @@
  */
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
-import java.net.URI;
-import java.util.*;
-
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
-import org.opendaylight.yangtools.yang.parser.builder.api.*;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.parser.builder.api.AbstractDataNodeContainerBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
+import org.opendaylight.yangtools.yang.parser.builder.api.DataNodeContainerBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.GroupingBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.TypeAwareBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.util.Comparators;
 import org.opendaylight.yangtools.yang.parser.util.ModuleImportImpl;
 import org.opendaylight.yangtools.yang.parser.util.RefineHolder;
 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
 /**
  * Builder of Module object. If this module is dependent on external
  * module/modules, these dependencies must be resolved before module is built,
@@ -80,6 +111,8 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
 
     private final List<ListSchemaNodeBuilder> allLists = new ArrayList<ListSchemaNodeBuilder>();
 
+    private String source;
+
     public ModuleBuilder(final String name, final String sourcePath) {
         this(name, false, sourcePath);
     }
@@ -207,6 +240,8 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
         Collections.sort(unknownNodes, Comparators.SCHEMA_NODE_COMP);
         instance.setUnknownSchemaNodes(unknownNodes);
 
+        instance.setSource(source);
+
         return instance;
     }
 
@@ -885,7 +920,11 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
         return "module " + name;
     }
 
-    private static final class ModuleImpl implements Module {
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public static final class ModuleImpl implements Module {
         private URI namespace;
         private final String name;
         private final String sourcePath;
@@ -909,6 +948,7 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
         private final List<ExtensionDefinition> extensionNodes = new ArrayList<>();
         private final Set<IdentitySchemaNode> identities = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
         private final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
+        private String source;
 
         private ModuleImpl(String name, String sourcePath) {
             this.name = name;
@@ -1151,6 +1191,15 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
             return getChildNode(childNodes, name);
         }
 
+        void setSource(String source){
+            this.source = source;
+        }
+
+        public String getSource() {
+            return source;
+        }
+
+        // FIXME: prefix should not be taken into consideration, perhaps namespace too
         @Override
         public int hashCode() {
             final int prime = 31;
@@ -1402,4 +1451,5 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
         return true;
     }
 
+
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleIdentifierImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleIdentifierImpl.java
new file mode 100644 (file)
index 0000000..02f6abb
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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.yang.parser.builder.impl;
+
+import com.google.common.base.Optional;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+
+import java.net.URI;
+import java.util.Date;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * ModuleIdentifier that can be used for indexing/searching by name.
+ * Name is only non-null attribute.
+ * Equality check on namespace and revision is only triggered if they are non-null
+ */
+public class ModuleIdentifierImpl implements ModuleIdentifier {
+    private final String name;
+    private final Optional<URI> namespace;
+    private final Optional<Date> revision;
+
+    public ModuleIdentifierImpl(String name, Optional<URI> namespace, Optional<Date> revision) {
+        this.name = checkNotNull(name);
+        this.namespace = checkNotNull(namespace);
+        this.revision = checkNotNull(revision);
+    }
+
+    @Override
+    public Date getRevision() {
+        return revision.orNull();
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public URI getNamespace() {
+        return namespace.orNull();
+    }
+
+    @Override
+    public String toString() {
+        return "ModuleIdentifierImpl{" +
+                "name='" + name + '\'' +
+                ", namespace=" + namespace +
+                ", revision=" + revision +
+                '}';
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || (o instanceof ModuleIdentifier == false)) {
+            return false;
+        }
+
+        ModuleIdentifier that = (ModuleIdentifier) o;
+
+        if (!name.equals(that.getName())) {
+            return false;
+        }
+        // only fail if this namespace is non-null
+        if (namespace.isPresent() && namespace.get().equals(that.getNamespace()) == false)  {
+            return false;
+        }
+        // only fail if this revision is non-null
+        if (revision.isPresent() && revision.get().equals(that.getRevision()) == false) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+}
index 73b2cb637e7828b5ac22a614f8d261b4af74612b..6f81e7adaf66bfa951ccda2a25f2ab4eec886ea8 100644 (file)
@@ -7,16 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeMap;
-
+import com.google.common.base.Optional;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
@@ -24,6 +15,7 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -34,11 +26,24 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
 
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
 final class SchemaContextImpl implements SchemaContext {
     private final Set<Module> modules;
+    private final Map<ModuleIdentifier, String> identifiersToSources;
 
-    SchemaContextImpl(final Set<Module> modules) {
+    SchemaContextImpl(final Set<Module> modules, Map<ModuleIdentifier, String> identifiersToSources) {
         this.modules = modules;
+        this.identifiersToSources = identifiersToSources;
     }
 
     @Override
@@ -257,4 +262,15 @@ final class SchemaContextImpl implements SchemaContext {
         return Collections.emptySet();
     }
 
+    //FIXME: should work for submodules too
+    @Override
+    public Set<ModuleIdentifier> getAllModuleIdentifiers() {
+        return identifiersToSources.keySet();
+    }
+
+    @Override
+    public Optional<String> getModuleSource(ModuleIdentifier moduleIdentifier) {
+        String maybeSource = identifiersToSources.get(moduleIdentifier);
+        return Optional.fromNullable(maybeSource);
+    }
 }
index 591d5c4f5c7de9518c9cbe00136197c93b45d8fd..fe57b76dab8ec87b515220e21435149f6e486992 100644 (file)
@@ -7,29 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
-import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.*;
-import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveType;
-import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveTypeUnion;
-import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveTypeUnionWithContext;
-import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveTypeWithContext;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.*;
-
+import com.google.common.base.Preconditions;
 import org.antlr.v4.runtime.ANTLRInputStream;
 import org.antlr.v4.runtime.CommonTokenStream;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.apache.commons.io.IOUtils;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangLexer;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
@@ -40,19 +38,66 @@ import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.TypeAwareBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.impl.*;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceCaseBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.DeviationBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ExtensionBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.IdentitySchemaNodeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.IdentityrefTypeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder.ModuleImpl;
+import org.opendaylight.yangtools.yang.parser.builder.impl.UnionTypeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.util.Comparators;
 import org.opendaylight.yangtools.yang.parser.util.GroupingSort;
 import org.opendaylight.yangtools.yang.parser.util.GroupingUtils;
 import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import org.opendaylight.yangtools.yang.parser.util.NamedByteArrayInputStream;
+import org.opendaylight.yangtools.yang.parser.util.NamedInputStream;
 import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 import org.opendaylight.yangtools.yang.validator.YangModelBasicValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.fillAugmentTarget;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findBaseIdentity;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findBaseIdentityFromContext;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findModuleFromBuilders;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findModuleFromContext;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findSchemaNode;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findSchemaNodeInModule;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.processAugmentation;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.setNodeAddedByUses;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.wrapChildNode;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.wrapChildNodes;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.wrapGroupings;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.wrapTypedefs;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.wrapUnknownNodes;
+import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveType;
+import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveTypeUnion;
+import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveTypeUnionWithContext;
+import static org.opendaylight.yangtools.yang.parser.util.TypeUtils.resolveTypeWithContext;
 
 
 public final class YangParserImpl implements YangModelParser {
@@ -68,7 +113,7 @@ public final class YangParserImpl implements YangModelParser {
 
         final String yangFileName = yangFile.getName();
         final String[] fileList = directory.list();
-        Preconditions.checkNotNull(fileList, directory + " not found");
+        checkNotNull(fileList, directory + " not found");
 
         FileInputStream yangFileStream = null;
         LinkedHashMap<InputStream, File> streamToFileMap = new LinkedHashMap<>();
@@ -221,30 +266,84 @@ public final class YangParserImpl implements YangModelParser {
         return result;
     }
 
+    // TODO: fix exception handling
     @Override
     public Map<InputStream, Module> parseYangModelsFromStreamsMapped(final List<InputStream> yangModelStreams) {
         if (yangModelStreams == null) {
             return Collections.emptyMap();
         }
 
-        Map<ModuleBuilder, InputStream> builderToStreamMap = new HashMap<>();
-        Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuilders(yangModelStreams, builderToStreamMap,
+
+        // copy input streams so that they can be read more than once
+        Map<InputStream/*array backed copy */, InputStream/* original for returning*/> arrayBackedToOriginalInputStreams = new HashMap<>();
+        for (final InputStream originalIS : yangModelStreams) {
+            InputStream arrayBackedIs;
+            try {
+                arrayBackedIs = NamedByteArrayInputStream.create(originalIS);
+            } catch (IOException e) {
+                // FIXME: throw IOException here
+                throw new IllegalStateException("Can not get yang as String from " + originalIS, e);
+            }
+            arrayBackedToOriginalInputStreams.put(arrayBackedIs, originalIS);
+        }
+
+        // it would be better if all code from here used string representation of yang sources instead of input streams
+        Map<ModuleBuilder, InputStream> builderToStreamMap = new HashMap<>(); // FIXME: do not modify input parameter
+        Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuilders(new ArrayList<>(arrayBackedToOriginalInputStreams.keySet()),
+                builderToStreamMap,
                 null);
-        Map<InputStream, Module> result = new LinkedHashMap<>();
+
+
+        // TODO move deeper
+        for(TreeMap<Date, ModuleBuilder> value : modules.values()) {
+            Collection<ModuleBuilder> values = value.values();
+            for(ModuleBuilder builder: values) {
+                InputStream is = builderToStreamMap.get(builder);
+                try {
+                    is.reset();
+                } catch (IOException e) {
+                    // this cannot happen because it is ByteArrayInputStream
+                    throw new IllegalStateException("Possible error in code", e);
+                }
+                String content;
+                try {
+                    content = IOUtils.toString(is);
+                } catch (IOException e) {
+                    // this cannot happen because it is ByteArrayInputStream
+                    throw new IllegalStateException("Possible error in code", e);
+                }
+                builder.setSource(content);
+            }
+        }
+
+
         Map<ModuleBuilder, Module> builderToModuleMap = build(modules);
+
         Set<ModuleBuilder> keyset = builderToModuleMap.keySet();
         List<ModuleBuilder> sorted = ModuleDependencySort.sort(keyset.toArray(new ModuleBuilder[keyset.size()]));
+        Map<InputStream, Module> result = new LinkedHashMap<>();
         for (ModuleBuilder key : sorted) {
-            result.put(builderToStreamMap.get(key), builderToModuleMap.get(key));
+            Module value = checkNotNull(builderToModuleMap.get(key), "Cannot get module for %s", key);
+            InputStream arrayBackedIS = checkNotNull(builderToStreamMap.get(key), "Cannot get is for %s", key);
+            InputStream originalIS = arrayBackedToOriginalInputStreams.get(arrayBackedIS);
+            result.put(originalIS, value);
         }
         return result;
     }
 
     @Override
     public SchemaContext resolveSchemaContext(final Set<Module> modules) {
-        return new SchemaContextImpl(modules);
+        // after merging parse method with this one, add support for getting submodule sources.
+        Map<ModuleIdentifier, String> identifiersToSources = new HashMap<>();
+        for(Module module: modules) {
+            ModuleImpl moduleImpl = (ModuleImpl) module;
+            identifiersToSources.put(module, moduleImpl.getSource());
+        }
+        return new SchemaContextImpl(modules, identifiersToSources);
     }
 
+    // FIXME: why a list is required?
+    // FIXME: streamToBuilderMap is output of this method, not input
     private Map<InputStream, ModuleBuilder> parseModuleBuilders(List<InputStream> inputStreams,
             Map<ModuleBuilder, InputStream> streamToBuilderMap) {
         Map<InputStream, ModuleBuilder> modules = parseBuilders(inputStreams, streamToBuilderMap);
@@ -252,6 +351,8 @@ public final class YangParserImpl implements YangModelParser {
         return result;
     }
 
+    // FIXME: why a list is required?
+    // FIXME: streamToBuilderMap is output of this method, not input
     private Map<InputStream, ModuleBuilder> parseBuilders(List<InputStream> inputStreams,
             Map<ModuleBuilder, InputStream> streamToBuilderMap) {
         final ParseTreeWalker walker = new ParseTreeWalker();
@@ -265,15 +366,15 @@ public final class YangParserImpl implements YangModelParser {
         for (Map.Entry<InputStream, ParseTree> entry : trees.entrySet()) {
             InputStream is = entry.getKey();
             String path = null;
-            if (is instanceof NamedFileInputStream) {
-                NamedFileInputStream nis = (NamedFileInputStream)is;
-                path = nis.getFileDestination();
+            if (is instanceof NamedInputStream) {
+                path = is.toString();
             }
             yangModelParser = new YangParserListenerImpl(path);
             walker.walk(yangModelParser, entry.getValue());
             ModuleBuilder moduleBuilder = yangModelParser.getModuleBuilder();
 
             // We expect the order of trees and streams has to be the same
+            // FIXME: input parameters should be treated as immutable
             streamToBuilderMap.put(moduleBuilder, entry.getKey());
 
             builders.put(entry.getKey(), moduleBuilder);
@@ -359,6 +460,8 @@ public final class YangParserImpl implements YangModelParser {
         module.getAllUnknownNodes().addAll(submodule.getAllUnknownNodes());
     }
 
+    // FIXME: why a list is required?
+    // FIXME: streamToBuilderMap is output of this method, not input
     private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(final List<InputStream> yangFileStreams,
             final Map<ModuleBuilder, InputStream> streamToBuilderMap, final SchemaContext context) {
         Map<InputStream, ModuleBuilder> parsedBuilders = parseModuleBuilders(yangFileStreams, streamToBuilderMap);
@@ -440,6 +543,7 @@ public final class YangParserImpl implements YangModelParser {
         }
     }
 
+    // FIXME: why a list is required?
     private Map<InputStream, ParseTree> parseStreams(final List<InputStream> yangStreams) {
         final Map<InputStream, ParseTree> trees = new HashMap<>();
         for (InputStream yangStream : yangStreams) {
@@ -461,6 +565,7 @@ public final class YangParserImpl implements YangModelParser {
             result = parser.yang();
             errorListener.validate();
         } catch (IOException e) {
+            // TODO: fix this ASAP
             LOG.warn("Exception while reading yang file: " + yangStream, e);
         }
         return result;
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedByteArrayInputStream.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedByteArrayInputStream.java
new file mode 100644 (file)
index 0000000..fd5bd9d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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.yang.parser.util;
+
+import org.apache.commons.io.IOUtils;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class NamedByteArrayInputStream extends ByteArrayInputStream implements NamedInputStream {
+    private final String toString;
+    private NamedByteArrayInputStream(byte[] buf, String toString) {
+        super(buf);
+        this.toString = toString;
+    }
+
+    public static ByteArrayInputStream create(InputStream originalIS) throws IOException {
+        String content = IOUtils.toString(originalIS);
+        if (originalIS instanceof NamedInputStream) {
+            return new NamedByteArrayInputStream(content.getBytes(), originalIS.toString());
+        } else {
+            return new ByteArrayInputStream(content.getBytes());
+        }
+    }
+
+    @Override
+    public String toString() {
+        return toString;
+    }
+}
index c2d1d24d2153fcfa4bf0fc218af1e52de340717a..e78db8e2714cc29c7a5dca55cf9de6f23355f548 100644 (file)
@@ -11,7 +11,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 
-public class NamedFileInputStream extends FileInputStream {
+public class NamedFileInputStream extends FileInputStream implements NamedInputStream {
     private final String fileDestination;
 
     public NamedFileInputStream(File file, String fileDestination) throws FileNotFoundException {
@@ -23,4 +23,8 @@ public class NamedFileInputStream extends FileInputStream {
         return fileDestination;
     }
 
+    @Override
+    public String toString() {
+        return fileDestination;
+    }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedInputStream.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedInputStream.java
new file mode 100644 (file)
index 0000000..4f56d94
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * 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.yang.parser.util;
+
+public interface NamedInputStream {
+
+    /**
+     * @return name of resource from which this input stream is derived, typically file path.
+     */
+    String toString();
+}
index 0d2f1dffc99af2d18e4ba0ac92ccd191e6b70b08..9002afdcd224f50e9c9c6b9b4d36c4a2144bd3f3 100644 (file)
@@ -7,7 +7,43 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
-import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+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.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.util.Decimal64;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.Int16;
+import org.opendaylight.yangtools.yang.model.util.Int32;
+import org.opendaylight.yangtools.yang.model.util.StringType;
+import org.opendaylight.yangtools.yang.model.util.Uint32;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -20,6 +56,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
@@ -27,22 +64,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
-import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
-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.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.model.util.Decimal64;
-import org.opendaylight.yangtools.yang.model.util.ExtendedType;
-import org.opendaylight.yangtools.yang.model.util.Int16;
-import org.opendaylight.yangtools.yang.model.util.Int32;
-import org.opendaylight.yangtools.yang.model.util.StringType;
-import org.opendaylight.yangtools.yang.model.util.Uint32;
-import org.opendaylight.yangtools.yang.model.util.UnionType;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 public class YangParserTest {
     public static final String FS = File.separator;
@@ -826,7 +853,7 @@ public class YangParserTest {
         File dependenciesDir = new File(getClass().getResource("/sorting-test").toURI());
         YangModelParser parser = new YangParserImpl();
         modules = parser.parseYangModels(yangFile, dependenciesDir);
-        SchemaContext ctx = new SchemaContextImpl(modules);
+        SchemaContext ctx = new SchemaContextImpl(modules, Collections.<ModuleIdentifier, String>emptyMap());
         checkOrder(modules);
         assertSetEquals(modules, ctx.getModules());
 
@@ -843,12 +870,12 @@ public class YangParserTest {
         }
         Set<Module> newModules = parser.parseYangModels(testFiles);
         assertSetEquals(newModules, modules);
-        ctx = new SchemaContextImpl(newModules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
         assertSetEquals(newModules, ctx.getModules());
         // ##########
         newModules = parser.parseYangModels(testFiles, null);
         assertSetEquals(newModules, modules);
-        ctx = new SchemaContextImpl(newModules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
         assertSetEquals(newModules, ctx.getModules());
         // ##########
         List<InputStream> streams = new ArrayList<>();
@@ -857,7 +884,7 @@ public class YangParserTest {
         }
         newModules = parser.parseYangModelsFromStreams(streams);
         assertSetEquals(newModules, modules);
-        ctx = new SchemaContextImpl(newModules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
         assertSetEquals(newModules, ctx.getModules());
         // ##########
         streams.clear();
@@ -866,13 +893,13 @@ public class YangParserTest {
         }
         newModules = parser.parseYangModelsFromStreams(streams, null);
         assertSetEquals(newModules, modules);
-        ctx = new SchemaContextImpl(newModules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
         assertSetEquals(newModules, ctx.getModules());
         // ##########
         Map<File, Module> mapped = parser.parseYangModelsMapped(testFiles);
         newModules = new LinkedHashSet<>(mapped.values());
         assertSetEquals(newModules, modules);
-        ctx = new SchemaContextImpl(newModules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
         assertSetEquals(newModules, ctx.getModules());
         // ##########
         streams.clear();
@@ -882,7 +909,7 @@ public class YangParserTest {
         Map<InputStream, Module> mappedStreams = parser.parseYangModelsFromStreamsMapped(streams);
         newModules = new LinkedHashSet<>(mappedStreams.values());
         assertSetEquals(newModules, modules);
-        ctx = new SchemaContextImpl(newModules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
         assertSetEquals(newModules, ctx.getModules());
     }