Comments of source code. 22/922/3
authorJozef Gloncak <jgloncak@cisco.com>
Thu, 15 Aug 2013 14:03:34 +0000 (16:03 +0200)
committerJozef Gloncak <jgloncak@cisco.com>
Wed, 21 Aug 2013 12:05:46 +0000 (14:05 +0200)
Comments were added to files:
- BindingGeneratorImpl.java
- BaseYangTypes.java
- GroupingDefinitionDependencySort.java
- NodeWrappedType.java
- TypeProviderImpl.java
- UnionDependencySort.java
- AbstractBaseType.java
- BindingGeneratorUtil.java
- ReferencedTypeImpl.java
- TypeConstants.java
- Types.java
- EnumerationBuilderImpl.java
- BuilderGenerator.java
- BuilderTemplate.xtend
- ClassTemplate.xtend
- Constants.java
- EnumGenerator.java
- EnumTemplate.xtend
- GeneratorJavaFile.java
- GeneratorUtil.java
- InterfaceGenerator.java
- InterfaceTemplate.xtend
- TOGenerator.java
- CodeGenerator.java
- Enumeration.java
- WildcardType.java

-> new class NodeWrappedType was created instead of GroupingDefinitionNode a
UnionNode
-> the method resolveListTypeBuilder of BindingGeneratorImpl was removed and
its using was replaced with method addDefaultInterfaceDefinition

Change-Id: Iea6317aea75bc37883cf0f2fbf094cb8d4f02f00
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
26 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/GroupingDefinitionDependencySort.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/NodeWrappedType.java [new file with mode: 0644]
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/UnionDependencySort.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/AbstractBaseType.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/ReferencedTypeImpl.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/TypeConstants.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/Types.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BuilderGenerator.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BuilderTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/Constants.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumGenerator.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorJavaFile.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtil.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceGenerator.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/TOGenerator.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/CodeGenerator.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/Enumeration.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/WildcardType.java

index ea3b472710fbeb84b4783396ee0e73809d274b56..8a5705410dc13b732b70541ed880a8c5c634ec1a 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.generator.impl;\r
-\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.moduleNamespaceToPackageName;\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType;\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToClassName;\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToValidParamName;\r
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.schemaNodeToTransferObjectBuilder;\r
-import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;\r
-import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;\r
-\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.concurrent.Future;\r
-\r
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;\r
-import org.opendaylight.yangtools.binding.generator.util.Types;\r
-import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;\r
-import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;\r
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
-import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;\r
-import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.EnumBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;\r
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;\r
-import org.opendaylight.yangtools.sal.binding.yang.types.GroupingDefinitionDependencySort;\r
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;\r
-import org.opendaylight.yangtools.yang.binding.DataRoot;\r
-import org.opendaylight.yangtools.yang.binding.Identifiable;\r
-import org.opendaylight.yangtools.yang.binding.Identifier;\r
-import org.opendaylight.yangtools.yang.binding.RpcService;\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.common.RpcResult;\r
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;\r
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;\r
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;\r
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.UsesNode;\r
-import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;\r
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;\r
-import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;\r
-import org.opendaylight.yangtools.yang.model.util.ExtendedType;\r
-import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;\r
-import org.opendaylight.yangtools.yang.model.util.UnionType;\r
-\r
-public final class BindingGeneratorImpl implements BindingGenerator {\r
-\r
-    /**\r
-     * Outter key represents the package name. Outter 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
-     */\r
-    private Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders;\r
-\r
-    /**\r
-     * Provide methods for converting YANG types to JAVA types.\r
-     */\r
-    private TypeProvider typeProvider;\r
-\r
-    /**\r
-     * Holds reference to schema context to resolve data of augmented elemnt\r
-     * when creating augmentation builder\r
-     */\r
-    private SchemaContext schemaContext;\r
-\r
-    /**\r
-     * Each grouping which is converted from schema node to generated type is\r
-     * added to this map with its Schema path as key to make it easier to get\r
-     * reference to it. In schema nodes in <code>uses</code> attribute there is\r
-     * only Schema Path but when building list of implemented interfaces for\r
-     * Schema node the object of type <code>Type</code> is required. So in this\r
-     * case is used this map.\r
-     */\r
-    private final Map<SchemaPath, GeneratedType> allGroupings = new HashMap<SchemaPath, GeneratedType>();\r
-\r
-    /**\r
-     * Only parent constructor is invoked.\r
-     */\r
-    \r
-    private final static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";\r
-    private final static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";\r
-    \r
-    public BindingGeneratorImpl() {\r
-        super();\r
-    }\r
-\r
-    /**\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
-     */\r
-    @Override\r
-    public List<Type> generateTypes(final SchemaContext context) {\r
-        if (context == null) {\r
-            throw new IllegalArgumentException("Schema Context reference cannot be NULL!");\r
-        }\r
-        if (context.getModules() == null) {\r
-            throw new IllegalStateException("Schema Context does not contain defined modules!");\r
-        }\r
-\r
-        final List<Type> generatedTypes = new ArrayList<>();\r
-        schemaContext = context;\r
-        typeProvider = new TypeProviderImpl(context);\r
-        final Set<Module> modules = context.getModules();\r
-        genTypeBuilders = new HashMap<>();\r
-        for (final Module module : modules) {\r
-\r
-            generatedTypes.addAll(allGroupingsToGenTypes(module));\r
-\r
-            if (false == module.getChildNodes().isEmpty()) {\r
-                generatedTypes.add(moduleToDataType(module));\r
-            }\r
-            generatedTypes.addAll(allTypeDefinitionsToGenTypes(module));\r
-            generatedTypes.addAll(allContainersToGenTypes(module));\r
-            generatedTypes.addAll(allListsToGenTypes(module));\r
-            generatedTypes.addAll(allChoicesToGenTypes(module));\r
-            generatedTypes.addAll(allAugmentsToGenTypes(module));\r
-            generatedTypes.addAll(allRPCMethodsToGenType(module));\r
-            generatedTypes.addAll(allNotificationsToGenType(module));\r
-            generatedTypes.addAll(allIdentitiesToGenTypes(module, context));\r
-\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\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
-     */\r
-    @Override\r
-    public List<Type> generateTypes(final SchemaContext context, final Set<Module> modules) {\r
-        if (context == null) {\r
-            throw new IllegalArgumentException("Schema Context reference cannot be NULL!");\r
-        }\r
-        if (context.getModules() == null) {\r
-            throw new IllegalStateException("Schema Context does not contain defined modules!");\r
-        }\r
-        if (modules == null) {\r
-            throw new IllegalArgumentException("Sef of Modules cannot be NULL!");\r
-        }\r
-\r
-        final List<Type> filteredGenTypes = new ArrayList<>();\r
-        schemaContext = context;\r
-        typeProvider = new TypeProviderImpl(context);\r
-        final Set<Module> contextModules = context.getModules();\r
-        genTypeBuilders = new HashMap<>();\r
-        for (final Module contextModule : contextModules) {\r
-            final List<Type> generatedTypes = new ArrayList<>();\r
-\r
-            generatedTypes.addAll(allGroupingsToGenTypes(contextModule));\r
-            if (false == contextModule.getChildNodes().isEmpty()) {\r
-                generatedTypes.add(moduleToDataType(contextModule));\r
-            }\r
-            generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));\r
-            generatedTypes.addAll(allContainersToGenTypes(contextModule));\r
-            generatedTypes.addAll(allListsToGenTypes(contextModule));\r
-            generatedTypes.addAll(allChoicesToGenTypes(contextModule));\r
-            generatedTypes.addAll(allAugmentsToGenTypes(contextModule));\r
-            generatedTypes.addAll(allRPCMethodsToGenType(contextModule));\r
-            generatedTypes.addAll(allNotificationsToGenType(contextModule));\r
-            generatedTypes.addAll(allIdentitiesToGenTypes(contextModule, context));\r
-\r
-            if (modules.contains(contextModule)) {\r
-                filteredGenTypes.addAll(generatedTypes);\r
-            }\r
-        }\r
-        return filteredGenTypes;\r
-    }\r
-\r
-    /**\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
-     * @return list of <code>Type</code> which are generated from extended\r
-     *         definition types (object of type <code>ExtendedType</code>)\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
-     */\r
-    private List<Type> allTypeDefinitionsToGenTypes(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-        if (module.getTypeDefinitions() == null) {\r
-            throw new IllegalArgumentException("Type Definitions for module " + module.getName() + " cannot be NULL!");\r
-        }\r
-\r
-        final Set<TypeDefinition<?>> typeDefinitions = module.getTypeDefinitions();\r
-        final List<Type> generatedTypes = new ArrayList<>();\r
-        for (final TypeDefinition<?> typedef : typeDefinitions) {\r
-            if (typedef != null) {\r
-                final Type type = ((TypeProviderImpl) typeProvider).generatedTypeForExtendedDefinitionType(typedef);\r
-                if ((type != null) && !generatedTypes.contains(type)) {\r
-                    generatedTypes.add(type);\r
-                }\r
-            }\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\r
-     * Converts all <b>containers</b> of the module to the list of\r
-     * <code>Type</code> objects.\r
-     * \r
-     * @param module\r
-     *            module from which is obtained DataNodeIterator to iterate over\r
-     *            all containers\r
-     * @return list of <code>Type</code> which are generated from containers\r
-     *         (objects of type <code>ContainerSchemaNode</code>)\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
-     */\r
-    private List<Type> allContainersToGenTypes(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-\r
-        if (module.getChildNodes() == null) {\r
-            throw new IllegalArgumentException("Reference to Set of Child Nodes in module " + module.getName()\r
-                    + " cannot be NULL!");\r
-        }\r
-\r
-        final List<Type> generatedTypes = new ArrayList<>();\r
-        final DataNodeIterator it = new DataNodeIterator(module);\r
-        final List<ContainerSchemaNode> schemaContainers = it.allContainers();\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        for (final ContainerSchemaNode container : schemaContainers) {\r
-            if (!container.isAddedByUses()) {\r
-                generatedTypes.add(containerToGenType(basePackageName, container));\r
-            }\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\r
-     * Converts all <b>lists</b> of the module to the list of <code>Type</code>\r
-     * objects.\r
-     * \r
-     * @param module\r
-     *            module from which is obtained DataNodeIterator to iterate over\r
-     *            all lists\r
-     * @return list of <code>Type</code> which are generated from lists (objects\r
-     *         of type <code>ListSchemaNode</code>)\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
-     */\r
-    private List<Type> allListsToGenTypes(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-\r
-        if (module.getChildNodes() == null) {\r
-            throw new IllegalArgumentException("Reference to Set of Child Nodes in module " + module.getName()\r
-                    + " cannot be NULL!");\r
-        }\r
-\r
-        final List<Type> generatedTypes = new ArrayList<>();\r
-        final DataNodeIterator it = new DataNodeIterator(module);\r
-        final List<ListSchemaNode> schemaLists = it.allLists();\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        if (schemaLists != null) {\r
-            for (final ListSchemaNode list : schemaLists) {\r
-                if (!list.isAddedByUses()) {\r
-                    generatedTypes.addAll(listToGenType(basePackageName, list));\r
-                }\r
-            }\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\r
-     * Converts all <b>choices</b> of the module to the list of\r
-     * <code>Type</code> objects.\r
-     * \r
-     * @param module\r
-     *            module from which is obtained DataNodeIterator to iterate over\r
-     *            all choices\r
-     * @return list of <code>Type</code> which are generated from choices\r
-     *         (objects of type <code>ChoiceNode</code>)\r
-     * @throws IllegalArgumentException\r
-     *             <ul>\r
-     *             <li>if the module equals null</li>\r
-     *             <li>if the name of module equals null</li> *\r
-     *             </ul>\r
-     * \r
-     */\r
-    private List<GeneratedType> allChoicesToGenTypes(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-\r
-        final DataNodeIterator it = new DataNodeIterator(module);\r
-        final List<ChoiceNode> choiceNodes = it.allChoices();\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-\r
-        final List<GeneratedType> generatedTypes = new ArrayList<>();\r
-        for (final ChoiceNode choice : choiceNodes) {\r
-            if ((choice != null) && !choice.isAddedByUses()) {\r
-                generatedTypes.addAll(choiceToGeneratedType(basePackageName, choice));\r
-            }\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\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
-     * @return list of <code>Type</code> which are generated from augments\r
-     *         (objects of type <code>AugmentationSchema</code>)\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
-     */\r
-    private List<Type> allAugmentsToGenTypes(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-        if (module.getChildNodes() == null) {\r
-            throw new IllegalArgumentException("Reference to Set of Augmentation Definitions in module "\r
-                    + module.getName() + " cannot be NULL!");\r
-        }\r
-\r
-        final List<Type> generatedTypes = new ArrayList<>();\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        final List<AugmentationSchema> augmentations = resolveAugmentations(module);\r
-        for (final AugmentationSchema augment : augmentations) {\r
-            generatedTypes.addAll(augmentationToGenTypes(basePackageName, augment));\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\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
-     */\r
-    private List<AugmentationSchema> resolveAugmentations(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-        if (module.getAugmentations() == null) {\r
-            throw new IllegalStateException("Augmentations Set cannot be NULL!");\r
-        }\r
-\r
-        final Set<AugmentationSchema> augmentations = module.getAugmentations();\r
-        final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(augmentations);\r
-        Collections.sort(sortedAugmentations, new Comparator<AugmentationSchema>() {\r
-\r
-            @Override\r
-            public int compare(AugmentationSchema augSchema1, AugmentationSchema augSchema2) {\r
-\r
-                if (augSchema1.getTargetPath().getPath().size() > augSchema2.getTargetPath().getPath().size()) {\r
-                    return 1;\r
-                } else if (augSchema1.getTargetPath().getPath().size() < augSchema2.getTargetPath().getPath().size()) {\r
-                    return -1;\r
-                }\r
-                return 0;\r
-\r
-            }\r
-        });\r
-\r
-        return sortedAugmentations;\r
-    }\r
-\r
-    /**\r
-     * Converts whole <b>module</b> to <code>GeneratedType</code> object.\r
-     * Firstly is created the module builder object from which is finally\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
-     */\r
-    private GeneratedType moduleToDataType(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-\r
-        final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(module, "Data");\r
-        addImplementedInterfaceFromUses(module, moduleDataTypeBuilder);\r
-        moduleDataTypeBuilder.addImplementsType(Types.typeForClass(DataRoot.class));\r
-\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        if (moduleDataTypeBuilder != null) {\r
-            final Set<DataSchemaNode> dataNodes = module.getChildNodes();\r
-            resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder, dataNodes);\r
-        }\r
-        return moduleDataTypeBuilder.toInstance();\r
-    }\r
-\r
-    /**\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
-     * @return list of <code>Type</code> which are generated from rpcs inputs,\r
-     *         outputs + container and lists which are part of inputs or outputs\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
-     */\r
-    private List<Type> allRPCMethodsToGenType(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-\r
-        if (module.getChildNodes() == null) {\r
-            throw new IllegalArgumentException("Reference to Set of RPC Method Definitions in module "\r
-                    + module.getName() + " cannot be NULL!");\r
-        }\r
-\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        final Set<RpcDefinition> rpcDefinitions = module.getRpcs();\r
-\r
-        if (rpcDefinitions.isEmpty()) {\r
-            return Collections.emptyList();\r
-        }\r
-\r
-        final List<Type> genRPCTypes = new ArrayList<>();\r
-        final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module, "Service");\r
-        interfaceBuilder.addImplementsType(Types.typeForClass(RpcService.class));\r
-        final Type future = Types.typeForClass(Future.class);\r
-        for (final RpcDefinition rpc : rpcDefinitions) {\r
-            if (rpc != null) {\r
-\r
-                String rpcName = parseToClassName(rpc.getQName().getLocalName());\r
-                String rpcMethodName = parseToValidParamName(rpcName);\r
-                MethodSignatureBuilder method = interfaceBuilder.addMethod(rpcMethodName);\r
-\r
-                final List<DataNodeIterator> rpcInOut = new ArrayList<>();\r
-\r
-                ContainerSchemaNode input = rpc.getInput();\r
-                ContainerSchemaNode output = rpc.getOutput();\r
-\r
-                if (input != null) {\r
-                    rpcInOut.add(new DataNodeIterator(input));\r
-                    GeneratedTypeBuilder inType = addRawInterfaceDefinition(basePackageName, input, rpcName);\r
-                    addImplementedInterfaceFromUses(input, inType);\r
-                    inType.addImplementsType(Types.DATA_OBJECT);\r
-                    resolveDataSchemaNodes(basePackageName, inType, input.getChildNodes());\r
-                    Type inTypeInstance = inType.toInstance();\r
-                    genRPCTypes.add(inTypeInstance);\r
-                    method.addParameter(inTypeInstance, "input");\r
-                }\r
-\r
-                Type outTypeInstance = Types.typeForClass(Void.class);\r
-                if (output != null) {\r
-                    rpcInOut.add(new DataNodeIterator(output));\r
-                    GeneratedTypeBuilder outType = addRawInterfaceDefinition(basePackageName, output, rpcName);\r
-                    addImplementedInterfaceFromUses(output, outType);\r
-                    outType.addImplementsType(Types.DATA_OBJECT);\r
-                    resolveDataSchemaNodes(basePackageName, outType, output.getChildNodes());\r
-                    outTypeInstance = outType.toInstance();\r
-                    genRPCTypes.add(outTypeInstance);\r
-\r
-                }\r
-\r
-                final Type rpcRes = Types.parameterizedTypeFor(Types.typeForClass(RpcResult.class), outTypeInstance);\r
-                method.setReturnType(Types.parameterizedTypeFor(future, rpcRes));\r
-                for (DataNodeIterator it : rpcInOut) {\r
-                    List<ContainerSchemaNode> nContainers = it.allContainers();\r
-                    if ((nContainers != null) && !nContainers.isEmpty()) {\r
-                        for (final ContainerSchemaNode container : nContainers) {\r
-                            if (!container.isAddedByUses()) {\r
-                                genRPCTypes.add(containerToGenType(basePackageName, container));\r
-                            }\r
-                        }\r
-                    }\r
-                    List<ListSchemaNode> nLists = it.allLists();\r
-                    if ((nLists != null) && !nLists.isEmpty()) {\r
-                        for (final ListSchemaNode list : nLists) {\r
-                            if (!list.isAddedByUses()) {\r
-                                genRPCTypes.addAll(listToGenType(basePackageName, list));\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        genRPCTypes.add(interfaceBuilder.toInstance());\r
-        return genRPCTypes;\r
-    }\r
-\r
-    /**\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
-     * @return list of <code>Type</code> which are generated from notification\r
-     *         (object of type <code>NotificationDefinition</code>\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
-     */\r
-    private List<Type> allNotificationsToGenType(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-\r
-        if (module.getName() == null) {\r
-            throw new IllegalArgumentException("Module name cannot be NULL!");\r
-        }\r
-\r
-        if (module.getChildNodes() == null) {\r
-            throw new IllegalArgumentException("Reference to Set of Notification Definitions in module "\r
-                    + module.getName() + " cannot be NULL!");\r
-        }\r
-\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        final List<Type> genNotifyTypes = new ArrayList<>();\r
-        final Set<NotificationDefinition> notifications = module.getNotifications();\r
-\r
-        for (final NotificationDefinition notification : notifications) {\r
-            if (notification != null) {\r
-                DataNodeIterator it = new DataNodeIterator(notification);\r
-\r
-                // Containers\r
-                for (ContainerSchemaNode node : it.allContainers()) {\r
-                    if (!node.isAddedByUses()) {\r
-                        genNotifyTypes.add(containerToGenType(basePackageName, node));\r
-                    }\r
-                }\r
-                // Lists\r
-                for (ListSchemaNode node : it.allLists()) {\r
-                    if (!node.isAddedByUses()) {\r
-                        genNotifyTypes.addAll(listToGenType(basePackageName, node));\r
-                    }\r
-                }\r
-                final GeneratedTypeBuilder notificationTypeBuilder = addDefaultInterfaceDefinition(basePackageName,\r
-                        notification);\r
-                notificationTypeBuilder.addImplementsType(Types\r
-                        .typeForClass(org.opendaylight.yangtools.yang.binding.Notification.class));\r
-                // Notification object\r
-                resolveDataSchemaNodes(basePackageName, notificationTypeBuilder, notification.getChildNodes());\r
-                genNotifyTypes.add(notificationTypeBuilder.toInstance());\r
-            }\r
-        }\r
-        return genNotifyTypes;\r
-    }\r
-\r
-    /**\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
-     * @return list of <code>Type</code> which are generated from identities\r
-     *         (object of type <code>IdentitySchemaNode</code>\r
-     * \r
-     */\r
-    private List<Type> allIdentitiesToGenTypes(final Module module, final SchemaContext context) {\r
-        List<Type> genTypes = new ArrayList<>();\r
-\r
-        final Set<IdentitySchemaNode> schemaIdentities = module.getIdentities();\r
-\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-\r
-        if (schemaIdentities != null && !schemaIdentities.isEmpty()) {\r
-            for (final IdentitySchemaNode identity : schemaIdentities) {\r
-                genTypes.add(identityToGenType(basePackageName, identity, context));\r
-            }\r
-        }\r
-        return genTypes;\r
-    }\r
-\r
-    /**\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 basePackageName\r
-     *            string containing package name to which identity belongs\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
-     * @return GeneratedType which is generated from identity (object of type\r
-     *         <code>IdentitySchemaNode</code>\r
-     * \r
-     */\r
-    private GeneratedType identityToGenType(final String basePackageName, final IdentitySchemaNode identity,\r
-            final SchemaContext context) {\r
-        if (identity == null) {\r
-            return null;\r
-        }\r
-\r
-        final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath());\r
-        final String genTypeName = parseToClassName(identity.getQName().getLocalName());\r
-        final GeneratedTOBuilderImpl newType = new GeneratedTOBuilderImpl(packageName, genTypeName);\r
-\r
-        IdentitySchemaNode baseIdentity = identity.getBaseIdentity();\r
-        if (baseIdentity != null) {\r
-            Module baseIdentityParentModule = SchemaContextUtil.findParentModule(context, baseIdentity);\r
-\r
-            final String returnTypePkgName = moduleNamespaceToPackageName(baseIdentityParentModule);\r
-            final String returnTypeName = parseToClassName(baseIdentity.getQName().getLocalName());\r
-\r
-            GeneratedTransferObject gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName).toInstance();\r
-            newType.setExtendsType(gto);\r
-        } else {\r
-            newType.setExtendsType(Types.getBaseIdentityTO());\r
-        }\r
-        newType.setAbstract(true);\r
-        return newType.toInstance();\r
-    }\r
-\r
-    /**\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 dependend (indepedent) 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
-     *            module from which is obtained set of all grouping objects to\r
-     *            iterate over them\r
-     * @return list of <code>Type</code> which are generated from groupings\r
-     *         (object of type <code>GroupingDefinition</code>)\r
-     * \r
-     */\r
-    private List<Type> allGroupingsToGenTypes(final Module module) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module parameter can not be null");\r
-        }\r
-        final List<Type> genTypes = new ArrayList<>();\r
-        final String basePackageName = moduleNamespaceToPackageName(module);\r
-        final Set<GroupingDefinition> groupings = module.getGroupings();\r
-        List<GroupingDefinition> groupingsSortedByDependencies;\r
-\r
-        groupingsSortedByDependencies = GroupingDefinitionDependencySort.sort(groupings);\r
-\r
-        for (final GroupingDefinition grouping : groupingsSortedByDependencies) {\r
-            GeneratedType genType = groupingToGenType(basePackageName, grouping);\r
-            genTypes.add(genType);\r
-            SchemaPath schemaPath = grouping.getPath();\r
-            allGroupings.put(schemaPath, genType);\r
-        }\r
-        return genTypes;\r
-    }\r
-\r
-    /**\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 containing name of package to which grouping belongs.\r
-     * @param grouping\r
-     *            GroupingDefinition which contains data about grouping\r
-     * @return GeneratedType which is generated from grouping (object of type\r
-     *         <code>GroupingDefinition</code>)\r
-     */\r
-    private GeneratedType groupingToGenType(final String basePackageName, GroupingDefinition grouping) {\r
-        if (grouping == null) {\r
-            return null;\r
-        }\r
-\r
-        final String packageName = packageNameForGeneratedType(basePackageName, grouping.getPath());\r
-        final Set<DataSchemaNode> schemaNodes = grouping.getChildNodes();\r
-        final GeneratedTypeBuilder typeBuilder = addDefaultInterfaceDefinition(packageName, grouping);\r
-\r
-        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);\r
-        return typeBuilder.toInstance();\r
-    }\r
-\r
-    /**\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 recursivelly 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
-     */\r
-    private EnumTypeDefinition enumTypeDefFromExtendedType(final TypeDefinition<?> typeDefinition) {\r
-        if (typeDefinition != null) {\r
-            if (typeDefinition.getBaseType() instanceof EnumTypeDefinition) {\r
-                return (EnumTypeDefinition) typeDefinition.getBaseType();\r
-            } else if (typeDefinition.getBaseType() instanceof ExtendedType) {\r
-                return enumTypeDefFromExtendedType(typeDefinition.getBaseType());\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    /**\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 contais data from\r
-     *         <code>enumTypeDef</code>\r
-     */\r
-    private EnumBuilder resolveInnerEnumFromTypeDefinition(final EnumTypeDefinition enumTypeDef, final String enumName,\r
-            final GeneratedTypeBuilder typeBuilder) {\r
-        if ((enumTypeDef != null) && (typeBuilder != null) && (enumTypeDef.getQName() != null)\r
-                && (enumTypeDef.getQName().getLocalName() != null)) {\r
-\r
-            final String enumerationName = parseToClassName(enumName);\r
-            final EnumBuilder enumBuilder = typeBuilder.addEnumeration(enumerationName);\r
-\r
-            if (enumBuilder != null) {\r
-                final List<EnumPair> enums = enumTypeDef.getValues();\r
-                if (enums != null) {\r
-                    int listIndex = 0;\r
-                    for (final EnumPair enumPair : enums) {\r
-                        if (enumPair != null) {\r
-                            final String enumPairName = parseToClassName(enumPair.getName());\r
-                            Integer enumPairValue = enumPair.getValue();\r
-\r
-                            if (enumPairValue == null) {\r
-                                enumPairValue = listIndex;\r
-                            }\r
-                            enumBuilder.addValue(enumPairName, enumPairValue);\r
-                            listIndex++;\r
-                        }\r
-                    }\r
-                }\r
-                return enumBuilder;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    /**\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
-     */\r
-    private GeneratedTypeBuilder moduleTypeBuilder(final Module module, final String postfix) {\r
-        if (module == null) {\r
-            throw new IllegalArgumentException("Module reference cannot be NULL!");\r
-        }\r
-        String packageName = moduleNamespaceToPackageName(module);\r
-        final String moduleName = parseToClassName(module.getName()) + postfix;\r
-\r
-        return new GeneratedTypeBuilderImpl(packageName, moduleName);\r
-\r
-    }\r
-\r
-    /**\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 agumentation\r
-     *            (target path, childs...)\r
-     * @return list of <code>Type</code> objects which contains generated type\r
-     *         for augmentation and for container, list and choice child nodes\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
-     */\r
-    private List<Type> augmentationToGenTypes(final String augmentPackageName, final AugmentationSchema augSchema) {\r
-        if (augmentPackageName == null) {\r
-            throw new IllegalArgumentException("Package Name cannot be NULL!");\r
-        }\r
-        if (augSchema == null) {\r
-            throw new IllegalArgumentException("Augmentation Schema cannot be NULL!");\r
-        }\r
-        if (augSchema.getTargetPath() == null) {\r
-            throw new IllegalStateException("Augmentation Schema does not contain Target Path (Target Path is NULL).");\r
-        }\r
-\r
-        final List<Type> genTypes = new ArrayList<>();\r
-\r
-        // EVERY augmented interface will extends Augmentation<T> interface\r
-        // and DataObject interface!!!\r
-        final SchemaPath targetPath = augSchema.getTargetPath();\r
-        final DataSchemaNode targetSchemaNode = findDataSchemaNode(schemaContext, targetPath);\r
-        if ((targetSchemaNode != null) && (targetSchemaNode.getQName() != null)\r
-                && (targetSchemaNode.getQName().getLocalName() != null)) {\r
-            final Module targetModule = findParentModule(schemaContext, targetSchemaNode);\r
-            final String targetBasePackage = moduleNamespaceToPackageName(targetModule);\r
-            final String targetPackageName = packageNameForGeneratedType(targetBasePackage, targetSchemaNode.getPath());\r
-            final String targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();\r
-            final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();\r
-\r
-            if (!(targetSchemaNode instanceof ChoiceNode)) {\r
-                final GeneratedTypeBuilder augTypeBuilder = addRawAugmentGenTypeDefinition(augmentPackageName,\r
-                        targetPackageName, targetSchemaNodeName, augSchema);\r
-                final GeneratedType augType = augTypeBuilder.toInstance();\r
-                genTypes.add(augType);\r
-            } else {\r
-                final Type refChoiceType = new ReferencedTypeImpl(targetPackageName,\r
-                        parseToClassName(targetSchemaNodeName));\r
-                final ChoiceNode choiceTarget = (ChoiceNode) targetSchemaNode;\r
-                final Set<ChoiceCaseNode> choiceCaseNodes = choiceTarget.getCases();\r
-                genTypes.addAll(generateTypesFromAugmentedChoiceCases(augmentPackageName, refChoiceType,\r
-                        choiceCaseNodes));\r
-            }\r
-            genTypes.addAll(augmentationBodyToGenTypes(augmentPackageName, augChildNodes));\r
-        }\r
-        return genTypes;\r
-    }\r
-\r
-    /**\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 augmentPackageName\r
-     *            string with contains the package name to which the augment\r
-     *            belongs\r
-     * @param targetPackageName\r
-     *            string with the package name to which the augmented node\r
-     *            belongs\r
-     * @param targetSchemaNodeName\r
-     *            string with the name of the augmented node\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
-     */\r
-    private GeneratedTypeBuilder addRawAugmentGenTypeDefinition(final String augmentPackageName,\r
-            final String targetPackageName, final String targetSchemaNodeName, final AugmentationSchema augSchema) {\r
-        final String targetTypeName = parseToClassName(targetSchemaNodeName);\r
-        Map<String, GeneratedTypeBuilder> augmentBuilders = genTypeBuilders.get(augmentPackageName);\r
-        if (augmentBuilders == null) {\r
-            augmentBuilders = new HashMap<>();\r
-            genTypeBuilders.put(augmentPackageName, augmentBuilders);\r
-        }\r
-        final String augIdentifier = getAugmentIdentifier(augSchema.getUnknownSchemaNodes());\r
-        \r
-        final String augTypeName =  augIdentifier != null ? parseToClassName(augIdentifier): augGenTypeName(augmentBuilders, targetTypeName);\r
-        final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);\r
-        final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();\r
-\r
-        final GeneratedTypeBuilder augTypeBuilder = new GeneratedTypeBuilderImpl(augmentPackageName, augTypeName);\r
-\r
-        augTypeBuilder.addImplementsType(Types.DATA_OBJECT);\r
-        augTypeBuilder.addImplementsType(Types.augmentationTypeFor(targetTypeRef));\r
-        addImplementedInterfaceFromUses(augSchema, augTypeBuilder);\r
-\r
-        augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);\r
-        augmentBuilders.put(augTypeName, augTypeBuilder);\r
-        return augTypeBuilder;\r
-    }\r
-\r
-    private String getAugmentIdentifier(List<UnknownSchemaNode> unknownSchemaNodes) {\r
-        String ret = null;\r
-        for (UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) {\r
-            QName nodeType = unknownSchemaNode.getNodeType();\r
-            if(AUGMENT_IDENTIFIER_NAME.equals(nodeType.getLocalName()) &&\r
-                    YANG_EXT_NAMESPACE.equals(nodeType.getNamespace().toString())) {\r
-                return unknownSchemaNode.getNodeParameter();\r
-            }\r
-        }\r
-        return ret;\r
-    }\r
-\r
-    /**\r
-     * Convert a container, list and choice subnodes (and recursivelly their\r
-     * subnodes) of augment to generated types\r
-     * \r
-     * @param augBasePackageName\r
-     *            string with the augment package name\r
-     * @param augChildNodes\r
-     *            set of data schema nodes which represents child nodes of the\r
-     *            augment\r
-     * \r
-     * @return list of <code>Type</code> which represents container, list and\r
-     *         choice subnodes of augment\r
-     */\r
-    private List<Type> augmentationBodyToGenTypes(final String augBasePackageName,\r
-            final Set<DataSchemaNode> augChildNodes) {\r
-        final List<Type> genTypes = new ArrayList<>();\r
-        final List<DataNodeIterator> augSchemaIts = new ArrayList<>();\r
-        for (final DataSchemaNode childNode : augChildNodes) {\r
-            if (childNode instanceof DataNodeContainer) {\r
-                augSchemaIts.add(new DataNodeIterator((DataNodeContainer) childNode));\r
-\r
-                if (childNode instanceof ContainerSchemaNode) {\r
-                    genTypes.add(containerToGenType(augBasePackageName, (ContainerSchemaNode) childNode));\r
-                } else if (childNode instanceof ListSchemaNode) {\r
-                    genTypes.addAll(listToGenType(augBasePackageName, (ListSchemaNode) childNode));\r
-                }\r
-            } else if (childNode instanceof ChoiceNode) {\r
-                final ChoiceNode choice = (ChoiceNode) childNode;\r
-                for (final ChoiceCaseNode caseNode : choice.getCases()) {\r
-                    augSchemaIts.add(new DataNodeIterator(caseNode));\r
-                }\r
-                genTypes.addAll(choiceToGeneratedType(augBasePackageName, (ChoiceNode) childNode));\r
-            }\r
-        }\r
-\r
-        for (final DataNodeIterator it : augSchemaIts) {\r
-            final List<ContainerSchemaNode> augContainers = it.allContainers();\r
-            final List<ListSchemaNode> augLists = it.allLists();\r
-            final List<ChoiceNode> augChoices = it.allChoices();\r
-\r
-            if (augContainers != null) {\r
-                for (final ContainerSchemaNode container : augContainers) {\r
-                    genTypes.add(containerToGenType(augBasePackageName, container));\r
-                }\r
-            }\r
-            if (augLists != null) {\r
-                for (final ListSchemaNode list : augLists) {\r
-                    genTypes.addAll(listToGenType(augBasePackageName, list));\r
-                }\r
-            }\r
-            if (augChoices != null) {\r
-                for (final ChoiceNode choice : augChoices) {\r
-                    genTypes.addAll(choiceToGeneratedType(augBasePackageName, choice));\r
-                }\r
-            }\r
-        }\r
-        return genTypes;\r
-    }\r
-\r
-    /**\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
-     */\r
-    private String augGenTypeName(final Map<String, GeneratedTypeBuilder> builders, final String genTypeName) {\r
-        String augTypeName = genTypeName;\r
-\r
-        int index = 1;\r
-        while ((builders != null) && builders.containsKey(genTypeName + index)) {\r
-            index++;\r
-        }\r
-        augTypeName += index;\r
-        return augTypeName;\r
-    }\r
-\r
-    /**\r
-     * Converts <code>containerNode</code> to generated type. Firstly the\r
-     * generated type builder is created. The subnodes of\r
-     * <code>containerNode</code> are added as methods and the instance of\r
-     * <code>GeneratedType</code> is returned.\r
-     * \r
-     * @param basePackageName\r
-     *            string with name of the package to which the superior node\r
-     *            belongs\r
-     * @param containerNode\r
-     *            container schema node with the data about childs nodes and\r
-     *            schema paths\r
-     * @return generated type for <code>containerNode</code>\r
-     */\r
-    private GeneratedType containerToGenType(final String basePackageName, ContainerSchemaNode containerNode) {\r
-        if (containerNode == null) {\r
-            return null;\r
-        }\r
-\r
-        final String packageName = packageNameForGeneratedType(basePackageName, containerNode.getPath());\r
-        final Set<DataSchemaNode> schemaNodes = containerNode.getChildNodes();\r
-        final GeneratedTypeBuilder typeBuilder = addDefaultInterfaceDefinition(packageName, containerNode);\r
-\r
-        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);\r
-        return typeBuilder.toInstance();\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param basePackageName\r
-     * @param typeBuilder\r
-     * @param schemaNodes\r
-     * @return\r
-     */\r
-    private GeneratedTypeBuilder resolveDataSchemaNodes(final String basePackageName,\r
-            final GeneratedTypeBuilder typeBuilder, final Set<DataSchemaNode> schemaNodes) {\r
-        if ((schemaNodes != null) && (typeBuilder != null)) {\r
-            for (final DataSchemaNode schemaNode : schemaNodes) {\r
-                if (schemaNode.isAugmenting() || schemaNode.isAddedByUses()) {\r
-                    continue;\r
-                }\r
-                addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);\r
-            }\r
-        }\r
-        return typeBuilder;\r
-    }\r
-\r
-    private GeneratedTypeBuilder augSchemaNodeToMethods(final String basePackageName,\r
-            final GeneratedTypeBuilder typeBuilder, final Set<DataSchemaNode> schemaNodes) {\r
-        if ((schemaNodes != null) && (typeBuilder != null)) {\r
-            for (final DataSchemaNode schemaNode : schemaNodes) {\r
-                if (schemaNode.isAugmenting()) {\r
-                    addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);\r
-                }\r
-            }\r
-        }\r
-        return typeBuilder;\r
-    }\r
-\r
-    private void addSchemaNodeToBuilderAsMethod(final String basePackageName, final DataSchemaNode schemaNode,\r
-            final GeneratedTypeBuilder typeBuilder) {\r
-        if (schemaNode != null && typeBuilder != null) {\r
-            if (schemaNode instanceof LeafSchemaNode) {\r
-                resolveLeafSchemaNodeAsMethod(typeBuilder, (LeafSchemaNode) schemaNode);\r
-            } else if (schemaNode instanceof LeafListSchemaNode) {\r
-                resolveLeafListSchemaNode(typeBuilder, (LeafListSchemaNode) schemaNode);\r
-            } else if (schemaNode instanceof ContainerSchemaNode) {\r
-                resolveContainerSchemaNode(basePackageName, typeBuilder, (ContainerSchemaNode) schemaNode);\r
-            } else if (schemaNode instanceof ListSchemaNode) {\r
-                resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);\r
-            } else if (schemaNode instanceof ChoiceNode) {\r
-                resolveChoiceSchemaNode(basePackageName, typeBuilder, (ChoiceNode) schemaNode);\r
-            }\r
-        }\r
-    }\r
-\r
-    private void resolveChoiceSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,\r
-            final ChoiceNode choiceNode) {\r
-        if (basePackageName == null) {\r
-            throw new IllegalArgumentException("Base Package Name cannot be NULL!");\r
-        }\r
-        if (typeBuilder == null) {\r
-            throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");\r
-        }\r
-        if (choiceNode == null) {\r
-            throw new IllegalArgumentException("Choice Schema Node cannot be NULL!");\r
-        }\r
-\r
-        final String choiceName = choiceNode.getQName().getLocalName();\r
-        if (choiceName != null && !choiceNode.isAddedByUses()) {\r
-            final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath());\r
-            final GeneratedTypeBuilder choiceType = addDefaultInterfaceDefinition(packageName, choiceNode);\r
-            constructGetter(typeBuilder, choiceName, choiceNode.getDescription(), choiceType);\r
-        }\r
-    }\r
-\r
-    private List<GeneratedType> choiceToGeneratedType(final String basePackageName, final ChoiceNode choiceNode) {\r
-        if (basePackageName == null) {\r
-            throw new IllegalArgumentException("Base Package Name cannot be NULL!");\r
-        }\r
-        if (choiceNode == null) {\r
-            throw new IllegalArgumentException("Choice Schema Node cannot be NULL!");\r
-        }\r
-\r
-        final List<GeneratedType> generatedTypes = new ArrayList<>();\r
-        final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath());\r
-        final GeneratedTypeBuilder choiceTypeBuilder = addRawInterfaceDefinition(packageName, choiceNode);\r
-        choiceTypeBuilder.addImplementsType(Types.DATA_OBJECT);\r
-        final GeneratedType choiceType = choiceTypeBuilder.toInstance();\r
-\r
-        generatedTypes.add(choiceType);\r
-        final Set<ChoiceCaseNode> caseNodes = choiceNode.getCases();\r
-        if ((caseNodes != null) && !caseNodes.isEmpty()) {\r
-            generatedTypes.addAll(generateTypesFromChoiceCases(basePackageName, choiceType, caseNodes));\r
-        }\r
-        return generatedTypes;\r
-    }\r
-\r
-    private List<GeneratedType> generateTypesFromChoiceCases(final String basePackageName, final Type refChoiceType,\r
-            final Set<ChoiceCaseNode> caseNodes) {\r
-        if (basePackageName == null) {\r
-            throw new IllegalArgumentException("Base Package Name cannot be NULL!");\r
-        }\r
-        if (refChoiceType == null) {\r
-            throw new IllegalArgumentException("Referenced Choice Type cannot be NULL!");\r
-        }\r
-        if (caseNodes == null) {\r
-            throw new IllegalArgumentException("Set of Choice Case Nodes cannot be NULL!");\r
-        }\r
-\r
-        final List<GeneratedType> generatedTypes = new ArrayList<>();\r
-        for (final ChoiceCaseNode caseNode : caseNodes) {\r
-            if (caseNode != null && !caseNode.isAddedByUses() && !caseNode.isAugmenting()) {\r
-                final String packageName = packageNameForGeneratedType(basePackageName, caseNode.getPath());\r
-                final GeneratedTypeBuilder caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);\r
-                caseTypeBuilder.addImplementsType(refChoiceType);\r
-\r
-                final Set<DataSchemaNode> childNodes = caseNode.getChildNodes();\r
-                if (childNodes != null) {\r
-                    resolveDataSchemaNodes(basePackageName, caseTypeBuilder, childNodes);\r
-                }\r
-                generatedTypes.add(caseTypeBuilder.toInstance());\r
-            }\r
-        }\r
-\r
-        return generatedTypes;\r
-    }\r
-\r
-    /**\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
-     */\r
-    private List<GeneratedType> generateTypesFromAugmentedChoiceCases(final String basePackageName,\r
-            final Type refChoiceType, final Set<ChoiceCaseNode> caseNodes) {\r
-        if (basePackageName == null) {\r
-            throw new IllegalArgumentException("Base Package Name cannot be NULL!");\r
-        }\r
-        if (refChoiceType == null) {\r
-            throw new IllegalArgumentException("Referenced Choice Type cannot be NULL!");\r
-        }\r
-        if (caseNodes == null) {\r
-            throw new IllegalArgumentException("Set of Choice Case Nodes cannot be NULL!");\r
-        }\r
-\r
-        final List<GeneratedType> generatedTypes = new ArrayList<>();\r
-        for (final ChoiceCaseNode caseNode : caseNodes) {\r
-            if (caseNode != null && caseNode.isAugmenting()) {\r
-                final String packageName = packageNameForGeneratedType(basePackageName, caseNode.getPath());\r
-                final GeneratedTypeBuilder caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);\r
-                caseTypeBuilder.addImplementsType(refChoiceType);\r
-\r
-                final Set<DataSchemaNode> childNodes = caseNode.getChildNodes();\r
-                if (childNodes != null) {\r
-                    resolveDataSchemaNodes(basePackageName, caseTypeBuilder, childNodes);\r
-                }\r
-                generatedTypes.add(caseTypeBuilder.toInstance());\r
-            }\r
-        }\r
-\r
-        return generatedTypes;\r
-    }\r
-\r
-    private boolean resolveLeafSchemaNodeAsMethod(final GeneratedTypeBuilder typeBuilder, final LeafSchemaNode leaf) {\r
-        if ((leaf != null) && (typeBuilder != null)) {\r
-            final String leafName = leaf.getQName().getLocalName();\r
-            String leafDesc = leaf.getDescription();\r
-            if (leafDesc == null) {\r
-                leafDesc = "";\r
-            }\r
-\r
-            if (leafName != null && !leaf.isAddedByUses()) {\r
-                final TypeDefinition<?> typeDef = leaf.getType();\r
-\r
-                Type returnType = null;\r
-                if (typeDef instanceof EnumTypeDefinition) {\r
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef);\r
-                    final EnumTypeDefinition enumTypeDef = enumTypeDefFromExtendedType(typeDef);\r
-                    final EnumBuilder enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, leafName,\r
-                            typeBuilder);\r
-\r
-                    if (enumBuilder != null) {\r
-                        returnType = new ReferencedTypeImpl(enumBuilder.getPackageName(), enumBuilder.getName());\r
-                    }\r
-                    ((TypeProviderImpl) typeProvider).putReferencedType(leaf.getPath(), returnType);\r
-                } else if (typeDef instanceof UnionType) {\r
-                    GeneratedTOBuilder genTOBuilder = addEnclosedTOToTypeBuilder(typeDef, typeBuilder, leafName);\r
-                    if (genTOBuilder != null) {\r
-                        returnType = new ReferencedTypeImpl(genTOBuilder.getPackageName(), genTOBuilder.getName());\r
-                    }\r
-                } else if (typeDef instanceof BitsTypeDefinition) {\r
-                    GeneratedTOBuilder genTOBuilder = addEnclosedTOToTypeBuilder(typeDef, typeBuilder, leafName);\r
-                    if (genTOBuilder != null) {\r
-                        returnType = new ReferencedTypeImpl(genTOBuilder.getPackageName(), genTOBuilder.getName());\r
-                    }\r
-                } else {\r
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef);\r
-                }\r
-                if (returnType != null) {\r
-                    constructGetter(typeBuilder, leafName, leafDesc, returnType);\r
-                    return true;\r
-                }\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    private boolean resolveLeafSchemaNodeAsProperty(final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf,\r
-            boolean isReadOnly) {\r
-        if ((leaf != null) && (toBuilder != null)) {\r
-            final String leafName = leaf.getQName().getLocalName();\r
-            String leafDesc = leaf.getDescription();\r
-            if (leafDesc == null) {\r
-                leafDesc = "";\r
-            }\r
-\r
-            if (leafName != null && !leaf.isAddedByUses()) {\r
-                final TypeDefinition<?> typeDef = leaf.getType();\r
-\r
-                // TODO: properly resolve enum types\r
-                final Type returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef);\r
-\r
-                if (returnType != null) {\r
-                    final GeneratedPropertyBuilder propBuilder = toBuilder.addProperty(parseToClassName(leafName));\r
-\r
-                    propBuilder.setReadOnly(isReadOnly);\r
-                    propBuilder.setReturnType(returnType);\r
-                    propBuilder.setComment(leafDesc);\r
-\r
-                    toBuilder.addEqualsIdentity(propBuilder);\r
-                    toBuilder.addHashIdentity(propBuilder);\r
-                    toBuilder.addToStringProperty(propBuilder);\r
-\r
-                    return true;\r
-                }\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    private boolean resolveLeafListSchemaNode(final GeneratedTypeBuilder typeBuilder, final LeafListSchemaNode node) {\r
-        if ((node != null) && (typeBuilder != null)) {\r
-            final String nodeName = node.getQName().getLocalName();\r
-            String nodeDesc = node.getDescription();\r
-            if (nodeDesc == null) {\r
-                nodeDesc = "";\r
-            }\r
-\r
-            if (nodeName != null && !node.isAddedByUses()) {\r
-                final TypeDefinition<?> type = node.getType();\r
-                final Type listType = Types.listTypeFor(typeProvider.javaTypeForSchemaDefinitionType(type));\r
-\r
-                constructGetter(typeBuilder, nodeName, nodeDesc, listType);\r
-                return true;\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    private boolean resolveContainerSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,\r
-            final ContainerSchemaNode containerNode) {\r
-        if ((containerNode != null) && (typeBuilder != null)) {\r
-            final String nodeName = containerNode.getQName().getLocalName();\r
-\r
-            if (nodeName != null && !containerNode.isAddedByUses()) {\r
-                final String packageName = packageNameForGeneratedType(basePackageName, containerNode.getPath());\r
-\r
-                final GeneratedTypeBuilder rawGenType = addDefaultInterfaceDefinition(packageName, containerNode);\r
-                constructGetter(typeBuilder, nodeName, containerNode.getDescription(), rawGenType);\r
-\r
-                return true;\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    private boolean resolveListSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,\r
-            final ListSchemaNode schemaNode) {\r
-        if ((schemaNode != null) && (typeBuilder != null)) {\r
-            final String listName = schemaNode.getQName().getLocalName();\r
-\r
-            if (listName != null && !schemaNode.isAddedByUses()) {\r
-                final String packageName = packageNameForGeneratedType(basePackageName, schemaNode.getPath());\r
-                final GeneratedTypeBuilder rawGenType = addDefaultInterfaceDefinition(packageName, schemaNode);\r
-                constructGetter(typeBuilder, listName, schemaNode.getDescription(), Types.listTypeFor(rawGenType));\r
-                return true;\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    /**\r
-     * Method instantiates new Generated Type Builder and sets the implements\r
-     * definitions of Data Object and Augmentable.\r
-     * \r
-     * @param packageName\r
-     *            Generated Type Package Name\r
-     * @param schemaNode\r
-     *            Schema Node definition\r
-     * @return Generated Type Builder instance for Schema Node definition\r
-     */\r
-    private GeneratedTypeBuilder addDefaultInterfaceDefinition(final String packageName, final SchemaNode schemaNode) {\r
-        final GeneratedTypeBuilder builder = addRawInterfaceDefinition(packageName, schemaNode, "");\r
-        builder.addImplementsType(Types.DATA_OBJECT);\r
-        if (!(schemaNode instanceof GroupingDefinition)) {\r
-            builder.addImplementsType(Types.augmentableTypeFor(builder));\r
-        }\r
-\r
-        if (schemaNode instanceof DataNodeContainer) {\r
-            addImplementedInterfaceFromUses((DataNodeContainer) schemaNode, builder);\r
-        }\r
-\r
-        return builder;\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param packageName\r
-     * @param schemaNode\r
-     * @return\r
-     */\r
-    private GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode) {\r
-        return addRawInterfaceDefinition(packageName, schemaNode, "");\r
-    }\r
-\r
-    private GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode,\r
-            final String prefix) {\r
-        if (schemaNode == null) {\r
-            throw new IllegalArgumentException("Data Schema Node cannot be NULL!");\r
-        }\r
-        if (packageName == null) {\r
-            throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");\r
-        }\r
-        if (schemaNode.getQName() == null) {\r
-            throw new IllegalArgumentException("QName for Data Schema Node cannot be NULL!");\r
-        }\r
-        final String schemaNodeName = schemaNode.getQName().getLocalName();\r
-        if (schemaNodeName == null) {\r
-            throw new IllegalArgumentException("Local Name of QName for Data Schema Node cannot be NULL!");\r
-        }\r
-\r
-        final String genTypeName;\r
-        if (prefix == null) {\r
-            genTypeName = parseToClassName(schemaNodeName);\r
-        } else {\r
-            genTypeName = prefix + parseToClassName(schemaNodeName);\r
-        }\r
-\r
-        final GeneratedTypeBuilder newType = new GeneratedTypeBuilderImpl(packageName, genTypeName);\r
-        if (!genTypeBuilders.containsKey(packageName)) {\r
-            final Map<String, GeneratedTypeBuilder> builders = new HashMap<>();\r
-            builders.put(genTypeName, newType);\r
-            genTypeBuilders.put(packageName, builders);\r
-        } else {\r
-            final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);\r
-            if (!builders.containsKey(genTypeName)) {\r
-                builders.put(genTypeName, newType);\r
-            }\r
-        }\r
-        return newType;\r
-    }\r
-\r
-    private String getterMethodName(final String methodName) {\r
-        final StringBuilder method = new StringBuilder();\r
-        method.append("get");\r
-        method.append(parseToClassName(methodName));\r
-        return method.toString();\r
-    }\r
-\r
-    private String setterMethodName(final String methodName) {\r
-        final StringBuilder method = new StringBuilder();\r
-        method.append("set");\r
-        method.append(parseToClassName(methodName));\r
-        return method.toString();\r
-    }\r
-\r
-    private MethodSignatureBuilder constructGetter(final GeneratedTypeBuilder interfaceBuilder,\r
-            final String schemaNodeName, final String comment, final Type returnType) {\r
-        final MethodSignatureBuilder getMethod = interfaceBuilder.addMethod(getterMethodName(schemaNodeName));\r
-\r
-        getMethod.setComment(comment);\r
-        getMethod.setReturnType(returnType);\r
-\r
-        return getMethod;\r
-    }\r
-\r
-    private MethodSignatureBuilder constructSetter(final GeneratedTypeBuilder interfaceBuilder,\r
-            final String schemaNodeName, final String comment, final Type parameterType) {\r
-        final MethodSignatureBuilder setMethod = interfaceBuilder.addMethod(setterMethodName(schemaNodeName));\r
-\r
-        setMethod.setComment(comment);\r
-        setMethod.addParameter(parameterType, parseToValidParamName(schemaNodeName));\r
-        setMethod.setReturnType(Types.voidType());\r
-\r
-        return setMethod;\r
-    }\r
-\r
-    private List<Type> listToGenType(final String basePackageName, final ListSchemaNode list) {\r
-        if (basePackageName == null) {\r
-            throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");\r
-        }\r
-        if (list == null) {\r
-            throw new IllegalArgumentException("List Schema Node cannot be NULL!");\r
-        }\r
-\r
-        final String packageName = packageNameForGeneratedType(basePackageName, list.getPath());\r
-        final GeneratedTypeBuilder typeBuilder = resolveListTypeBuilder(packageName, list);\r
-        final List<String> listKeys = listKeys(list);\r
-        GeneratedTOBuilder genTOBuilder = resolveListKeyTOBuilder(packageName, list, listKeys);\r
-        \r
-        \r
-        if(genTOBuilder != null) {\r
-            ParameterizedType identifierMarker = Types.parameterizedTypeFor( Types.typeForClass(Identifier.class), typeBuilder);\r
-            ParameterizedType identifiableMarker = Types.parameterizedTypeFor(Types.typeForClass(Identifiable.class), genTOBuilder);\r
-            genTOBuilder.addImplementsType(identifierMarker);\r
-            typeBuilder.addImplementsType(identifiableMarker);\r
-        }\r
-        final Set<DataSchemaNode> schemaNodes = list.getChildNodes();\r
-\r
-        for (final DataSchemaNode schemaNode : schemaNodes) {\r
-            if (schemaNode.isAugmenting()) {\r
-                continue;\r
-            }\r
-            addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder, genTOBuilder, listKeys);\r
-        }\r
-        return typeBuildersToGenTypes(typeBuilder, genTOBuilder);\r
-    }\r
-\r
-    private void addSchemaNodeToListBuilders(final String basePackageName, final DataSchemaNode schemaNode,\r
-            final GeneratedTypeBuilder typeBuilder, final GeneratedTOBuilder genTOBuilder, final List<String> listKeys) {\r
-        if (schemaNode == null) {\r
-            throw new IllegalArgumentException("Data Schema Node cannot be NULL!");\r
-        }\r
-\r
-        if (typeBuilder == null) {\r
-            throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");\r
-        }\r
-\r
-        if (schemaNode instanceof LeafSchemaNode) {\r
-            final LeafSchemaNode leaf = (LeafSchemaNode) schemaNode;\r
-            if (!isPartOfListKey(leaf, listKeys)) {\r
-                resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);\r
-            } else {\r
-                resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true);\r
-            }\r
-        } else if (schemaNode instanceof LeafListSchemaNode) {\r
-            resolveLeafListSchemaNode(typeBuilder, (LeafListSchemaNode) schemaNode);\r
-        } else if (schemaNode instanceof ContainerSchemaNode) {\r
-            resolveContainerSchemaNode(basePackageName, typeBuilder, (ContainerSchemaNode) schemaNode);\r
-        } else if (schemaNode instanceof ListSchemaNode) {\r
-            resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);\r
-        }\r
-    }\r
-\r
-    private List<Type> typeBuildersToGenTypes(final GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder) {\r
-        final List<Type> genTypes = new ArrayList<>();\r
-        if (typeBuilder == null) {\r
-            throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");\r
-        }\r
-\r
-        if (genTOBuilder != null) {\r
-            final GeneratedTransferObject genTO = genTOBuilder.toInstance();\r
-            constructGetter(typeBuilder, "key", "Returns Primary Key of Yang List Type", genTO);\r
-            genTypes.add(genTO);\r
-        }\r
-        genTypes.add(typeBuilder.toInstance());\r
-        return genTypes;\r
-    }\r
-\r
-    /**\r
-     * @param list\r
-     * @return\r
-     */\r
-    private GeneratedTOBuilder resolveListKey(final String packageName, final ListSchemaNode list) {\r
-        final String listName = list.getQName().getLocalName() + "Key";\r
-        return schemaNodeToTransferObjectBuilder(packageName, list, listName);\r
-    }\r
-\r
-    private boolean isPartOfListKey(final LeafSchemaNode leaf, final List<String> keys) {\r
-        if ((leaf != null) && (keys != null) && (leaf.getQName() != null)) {\r
-            final String leafName = leaf.getQName().getLocalName();\r
-            if (keys.contains(leafName)) {\r
-                return true;\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    private List<String> listKeys(final ListSchemaNode list) {\r
-        final List<String> listKeys = new ArrayList<>();\r
-\r
-        if (list.getKeyDefinition() != null) {\r
-            final List<QName> keyDefinitions = list.getKeyDefinition();\r
-\r
-            for (final QName keyDefinition : keyDefinitions) {\r
-                listKeys.add(keyDefinition.getLocalName());\r
-            }\r
-        }\r
-        return listKeys;\r
-    }\r
-\r
-    private GeneratedTypeBuilder resolveListTypeBuilder(final String packageName, final ListSchemaNode list) {\r
-        if (packageName == null) {\r
-            throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");\r
-        }\r
-        if (list == null) {\r
-            throw new IllegalArgumentException("List Schema Node cannot be NULL!");\r
-        }\r
-\r
-        final String schemaNodeName = list.getQName().getLocalName();\r
-        final String genTypeName = parseToClassName(schemaNodeName);\r
-\r
-        GeneratedTypeBuilder typeBuilder = null;\r
-        final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);\r
-        if (builders != null) {\r
-            typeBuilder = builders.get(genTypeName);\r
-        }\r
-        if (typeBuilder == null) {\r
-            typeBuilder = addDefaultInterfaceDefinition(packageName, list);\r
-        }\r
-        return typeBuilder;\r
-    }\r
-\r
-    private GeneratedTOBuilder resolveListKeyTOBuilder(final String packageName, final ListSchemaNode list,\r
-            final List<String> listKeys) {\r
-        GeneratedTOBuilder genTOBuilder = null;\r
-        if (listKeys.size() > 0) {\r
-            genTOBuilder = resolveListKey(packageName, list);\r
-        }\r
-        return genTOBuilder;\r
-    }\r
-\r
-    private GeneratedTOBuilder addEnclosedTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,\r
-            String leafName) {\r
-        String className = parseToClassName(leafName);\r
-        GeneratedTOBuilder genTOBuilder = null;\r
-        if (typeDef instanceof UnionType) {\r
-            genTOBuilder = ((TypeProviderImpl) typeProvider).addUnionGeneratedTypeDefinition(\r
-                    typeBuilder.getFullyQualifiedName(), typeDef, className);\r
-        } else if (typeDef instanceof BitsTypeDefinition) {\r
-            genTOBuilder = ((TypeProviderImpl) typeProvider).bitsTypedefToTransferObject(\r
-                    typeBuilder.getFullyQualifiedName(), typeDef, className);\r
-        }\r
-        if (genTOBuilder != null) {\r
-            typeBuilder.addEnclosingTransferObject(genTOBuilder);\r
-            return genTOBuilder;\r
-        }\r
-        return null;\r
-\r
-    }\r
-\r
-    /**\r
-     * Adds the implemented types to type builder. The method passes through the\r
-     * list of elements which contains {@code dataNodeContainer} and adds them\r
-     * as <i>implements type</i> to <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 which contains implemented types\r
-     */\r
-    private GeneratedTypeBuilder addImplementedInterfaceFromUses(final DataNodeContainer dataNodeContainer,\r
-            final GeneratedTypeBuilder builder) {\r
-        for (UsesNode usesNode : dataNodeContainer.getUses()) {\r
-            if (usesNode.getGroupingPath() != null) {\r
-                GeneratedType genType = allGroupings.get(usesNode.getGroupingPath());\r
-                if (genType == null) {\r
-                    throw new IllegalStateException("Grouping " + usesNode.getGroupingPath() + "is not resolved for "\r
-                            + builder.getName());\r
-                }\r
-                builder.addImplementsType(genType);\r
-            }\r
-        }\r
-        return builder;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.sal.binding.generator.impl;
+
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.moduleNamespaceToPackageName;
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType;
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToClassName;
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToValidParamName;
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.schemaNodeToTransferObjectBuilder;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
+import org.opendaylight.yangtools.binding.generator.util.Types;
+import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
+import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
+import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.EnumBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.yangtools.sal.binding.yang.types.GroupingDefinitionDependencySort;
+import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+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.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+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.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+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.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
+
+public final class BindingGeneratorImpl implements BindingGenerator {
+
+    /**
+     * Outter key represents the package name. Outter 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;
+
+    /**
+     * Provide methods for converting YANG types to JAVA types.
+     */
+    private TypeProvider typeProvider;
+
+    /**
+     * Holds reference to schema context to resolve data of augmented elemnt
+     * when creating augmentation builder
+     */
+    private SchemaContext schemaContext;
+
+    /**
+     * Each grouping which is converted from schema node to generated type is
+     * added to this map with its Schema path as key to make it easier to get
+     * reference to it. In schema nodes in <code>uses</code> attribute there is
+     * only Schema Path but when building list of implemented interfaces for
+     * Schema node the object of type <code>Type</code> is required. So in this
+     * case is used this map.
+     */
+    private final Map<SchemaPath, GeneratedType> allGroupings = new HashMap<SchemaPath, GeneratedType>();
+
+    /**
+     * Only parent constructor is invoked.
+     */
+    
+    private final static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";
+    private final static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";
+    
+    public BindingGeneratorImpl() {
+        super();
+    }
+
+    /**
+     * 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
+    public List<Type> generateTypes(final SchemaContext context) {
+        if (context == null) {
+            throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
+        }
+        if (context.getModules() == null) {
+            throw new IllegalStateException("Schema Context does not contain defined modules!");
+        }
+
+        final List<Type> generatedTypes = new ArrayList<>();
+        schemaContext = context;
+        typeProvider = new TypeProviderImpl(context);
+        final Set<Module> modules = context.getModules();
+        genTypeBuilders = new HashMap<>();
+        for (final Module module : modules) {
+
+            generatedTypes.addAll(allGroupingsToGenTypes(module));
+
+            if (false == module.getChildNodes().isEmpty()) {
+                generatedTypes.add(moduleToDataType(module));
+            }
+            generatedTypes.addAll(allTypeDefinitionsToGenTypes(module));
+            generatedTypes.addAll(allContainersToGenTypes(module));
+            generatedTypes.addAll(allListsToGenTypes(module));
+            generatedTypes.addAll(allChoicesToGenTypes(module));
+            generatedTypes.addAll(allAugmentsToGenTypes(module));
+            generatedTypes.addAll(allRPCMethodsToGenType(module));
+            generatedTypes.addAll(allNotificationsToGenType(module));
+            generatedTypes.addAll(allIdentitiesToGenTypes(module, context));
+
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * 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
+    public List<Type> generateTypes(final SchemaContext context, final Set<Module> modules) {
+        if (context == null) {
+            throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
+        }
+        if (context.getModules() == null) {
+            throw new IllegalStateException("Schema Context does not contain defined modules!");
+        }
+        if (modules == null) {
+            throw new IllegalArgumentException("Sef of Modules cannot be NULL!");
+        }
+
+        final List<Type> filteredGenTypes = new ArrayList<>();
+        schemaContext = context;
+        typeProvider = new TypeProviderImpl(context);
+        final Set<Module> contextModules = context.getModules();
+        genTypeBuilders = new HashMap<>();
+        for (final Module contextModule : contextModules) {
+            final List<Type> generatedTypes = new ArrayList<>();
+
+            generatedTypes.addAll(allGroupingsToGenTypes(contextModule));
+            if (false == contextModule.getChildNodes().isEmpty()) {
+                generatedTypes.add(moduleToDataType(contextModule));
+            }
+            generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));
+            generatedTypes.addAll(allContainersToGenTypes(contextModule));
+            generatedTypes.addAll(allListsToGenTypes(contextModule));
+            generatedTypes.addAll(allChoicesToGenTypes(contextModule));
+            generatedTypes.addAll(allAugmentsToGenTypes(contextModule));
+            generatedTypes.addAll(allRPCMethodsToGenType(contextModule));
+            generatedTypes.addAll(allNotificationsToGenType(contextModule));
+            generatedTypes.addAll(allIdentitiesToGenTypes(contextModule, context));
+
+            if (modules.contains(contextModule)) {
+                filteredGenTypes.addAll(generatedTypes);
+            }
+        }
+        return filteredGenTypes;
+    }
+
+    /**
+     * 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
+     * @return list of <code>Type</code> which are generated from extended
+     *         definition types (object of type <code>ExtendedType</code>)
+     * @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 List<Type> allTypeDefinitionsToGenTypes(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+        if (module.getTypeDefinitions() == null) {
+            throw new IllegalArgumentException("Type Definitions for module " + module.getName() + " cannot be NULL!");
+        }
+
+        final Set<TypeDefinition<?>> typeDefinitions = module.getTypeDefinitions();
+        final List<Type> generatedTypes = new ArrayList<>();
+        for (final TypeDefinition<?> typedef : typeDefinitions) {
+            if (typedef != null) {
+                final Type type = ((TypeProviderImpl) typeProvider).generatedTypeForExtendedDefinitionType(typedef);
+                if ((type != null) && !generatedTypes.contains(type)) {
+                    generatedTypes.add(type);
+                }
+            }
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * Converts all <b>containers</b> of the module to the list of
+     * <code>Type</code> objects.
+     * 
+     * @param module
+     *            module from which is obtained DataNodeIterator to iterate over
+     *            all containers
+     * @return list of <code>Type</code> which are generated from containers
+     *         (objects of type <code>ContainerSchemaNode</code>)
+     * @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 List<Type> allContainersToGenTypes(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+
+        if (module.getChildNodes() == null) {
+            throw new IllegalArgumentException("Reference to Set of Child Nodes in module " + module.getName()
+                    + " cannot be NULL!");
+        }
+
+        final List<Type> generatedTypes = new ArrayList<>();
+        final DataNodeIterator it = new DataNodeIterator(module);
+        final List<ContainerSchemaNode> schemaContainers = it.allContainers();
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        for (final ContainerSchemaNode container : schemaContainers) {
+            if (!container.isAddedByUses()) {
+                generatedTypes.add(containerToGenType(basePackageName, container));
+            }
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * Converts all <b>lists</b> of the module to the list of <code>Type</code>
+     * objects.
+     * 
+     * @param module
+     *            module from which is obtained DataNodeIterator to iterate over
+     *            all lists
+     * @return list of <code>Type</code> which are generated from lists (objects
+     *         of type <code>ListSchemaNode</code>)
+     * @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 List<Type> allListsToGenTypes(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+
+        if (module.getChildNodes() == null) {
+            throw new IllegalArgumentException("Reference to Set of Child Nodes in module " + module.getName()
+                    + " cannot be NULL!");
+        }
+
+        final List<Type> generatedTypes = new ArrayList<>();
+        final DataNodeIterator it = new DataNodeIterator(module);
+        final List<ListSchemaNode> schemaLists = it.allLists();
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        if (schemaLists != null) {
+            for (final ListSchemaNode list : schemaLists) {
+                if (!list.isAddedByUses()) {
+                    generatedTypes.addAll(listToGenType(basePackageName, list));
+                }
+            }
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * Converts all <b>choices</b> of the module to the list of
+     * <code>Type</code> objects.
+     * 
+     * @param module
+     *            module from which is obtained DataNodeIterator to iterate over
+     *            all choices
+     * @return list of <code>Type</code> which are generated from choices
+     *         (objects of type <code>ChoiceNode</code>)
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the module equals null</li>
+     *             <li>if the name of module equals null</li> *
+     *             </ul>
+     * 
+     */
+    private List<GeneratedType> allChoicesToGenTypes(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+
+        final DataNodeIterator it = new DataNodeIterator(module);
+        final List<ChoiceNode> choiceNodes = it.allChoices();
+        final String basePackageName = moduleNamespaceToPackageName(module);
+
+        final List<GeneratedType> generatedTypes = new ArrayList<>();
+        for (final ChoiceNode choice : choiceNodes) {
+            if ((choice != null) && !choice.isAddedByUses()) {
+                generatedTypes.addAll(choiceToGeneratedType(basePackageName, choice));
+            }
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * 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
+     * @return list of <code>Type</code> which are generated from augments
+     *         (objects of type <code>AugmentationSchema</code>)
+     * @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 List<Type> allAugmentsToGenTypes(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+        if (module.getChildNodes() == null) {
+            throw new IllegalArgumentException("Reference to Set of Augmentation Definitions in module "
+                    + module.getName() + " cannot be NULL!");
+        }
+
+        final List<Type> generatedTypes = new ArrayList<>();
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        final List<AugmentationSchema> augmentations = resolveAugmentations(module);
+        for (final AugmentationSchema augment : augmentations) {
+            generatedTypes.addAll(augmentationToGenTypes(basePackageName, augment));
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * 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 List<AugmentationSchema> resolveAugmentations(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        if (module.getAugmentations() == null) {
+            throw new IllegalStateException("Augmentations Set cannot be NULL!");
+        }
+
+        final Set<AugmentationSchema> augmentations = module.getAugmentations();
+        final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(augmentations);
+        Collections.sort(sortedAugmentations, new Comparator<AugmentationSchema>() {
+
+            @Override
+            public int compare(AugmentationSchema augSchema1, AugmentationSchema augSchema2) {
+
+                if (augSchema1.getTargetPath().getPath().size() > augSchema2.getTargetPath().getPath().size()) {
+                    return 1;
+                } else if (augSchema1.getTargetPath().getPath().size() < augSchema2.getTargetPath().getPath().size()) {
+                    return -1;
+                }
+                return 0;
+
+            }
+        });
+
+        return sortedAugmentations;
+    }
+
+    /**
+     * Converts whole <b>module</b> to <code>GeneratedType</code> object.
+     * Firstly is created the module builder object from which is finally
+     * 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 GeneratedType moduleToDataType(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+
+        final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(module, "Data");
+        addImplementedInterfaceFromUses(module, moduleDataTypeBuilder);
+        moduleDataTypeBuilder.addImplementsType(Types.typeForClass(DataRoot.class));
+
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        if (moduleDataTypeBuilder != null) {
+            final Set<DataSchemaNode> dataNodes = module.getChildNodes();
+            resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder, dataNodes);
+        }
+        return moduleDataTypeBuilder.toInstance();
+    }
+
+    /**
+     * 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
+     * @return list of <code>Type</code> which are generated from rpcs inputs,
+     *         outputs + container and lists which are part of inputs or outputs
+     * @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 List<Type> allRPCMethodsToGenType(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+
+        if (module.getChildNodes() == null) {
+            throw new IllegalArgumentException("Reference to Set of RPC Method Definitions in module "
+                    + module.getName() + " cannot be NULL!");
+        }
+
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
+
+        if (rpcDefinitions.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        final List<Type> genRPCTypes = new ArrayList<>();
+        final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module, "Service");
+        interfaceBuilder.addImplementsType(Types.typeForClass(RpcService.class));
+        final Type future = Types.typeForClass(Future.class);
+        for (final RpcDefinition rpc : rpcDefinitions) {
+            if (rpc != null) {
+
+                String rpcName = parseToClassName(rpc.getQName().getLocalName());
+                String rpcMethodName = parseToValidParamName(rpcName);
+                MethodSignatureBuilder method = interfaceBuilder.addMethod(rpcMethodName);
+
+                final List<DataNodeIterator> rpcInOut = new ArrayList<>();
+
+                ContainerSchemaNode input = rpc.getInput();
+                ContainerSchemaNode output = rpc.getOutput();
+
+                if (input != null) {
+                    rpcInOut.add(new DataNodeIterator(input));
+                    GeneratedTypeBuilder inType = addRawInterfaceDefinition(basePackageName, input, rpcName);
+                    addImplementedInterfaceFromUses(input, inType);
+                    inType.addImplementsType(Types.DATA_OBJECT);
+                    resolveDataSchemaNodes(basePackageName, inType, input.getChildNodes());
+                    Type inTypeInstance = inType.toInstance();
+                    genRPCTypes.add(inTypeInstance);
+                    method.addParameter(inTypeInstance, "input");
+                }
+
+                Type outTypeInstance = Types.typeForClass(Void.class);
+                if (output != null) {
+                    rpcInOut.add(new DataNodeIterator(output));
+                    GeneratedTypeBuilder outType = addRawInterfaceDefinition(basePackageName, output, rpcName);
+                    addImplementedInterfaceFromUses(output, outType);
+                    outType.addImplementsType(Types.DATA_OBJECT);
+                    resolveDataSchemaNodes(basePackageName, outType, output.getChildNodes());
+                    outTypeInstance = outType.toInstance();
+                    genRPCTypes.add(outTypeInstance);
+
+                }
+
+                final Type rpcRes = Types.parameterizedTypeFor(Types.typeForClass(RpcResult.class), outTypeInstance);
+                method.setReturnType(Types.parameterizedTypeFor(future, rpcRes));
+                for (DataNodeIterator it : rpcInOut) {
+                    List<ContainerSchemaNode> nContainers = it.allContainers();
+                    if ((nContainers != null) && !nContainers.isEmpty()) {
+                        for (final ContainerSchemaNode container : nContainers) {
+                            if (!container.isAddedByUses()) {
+                                genRPCTypes.add(containerToGenType(basePackageName, container));
+                            }
+                        }
+                    }
+                    List<ListSchemaNode> nLists = it.allLists();
+                    if ((nLists != null) && !nLists.isEmpty()) {
+                        for (final ListSchemaNode list : nLists) {
+                            if (!list.isAddedByUses()) {
+                                genRPCTypes.addAll(listToGenType(basePackageName, list));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        genRPCTypes.add(interfaceBuilder.toInstance());
+        return genRPCTypes;
+    }
+
+    /**
+     * 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
+     * @return list of <code>Type</code> which are generated from notification
+     *         (object of type <code>NotificationDefinition</code>
+     * @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 List<Type> allNotificationsToGenType(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+
+        if (module.getName() == null) {
+            throw new IllegalArgumentException("Module name cannot be NULL!");
+        }
+
+        if (module.getChildNodes() == null) {
+            throw new IllegalArgumentException("Reference to Set of Notification Definitions in module "
+                    + module.getName() + " cannot be NULL!");
+        }
+
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        final List<Type> genNotifyTypes = new ArrayList<>();
+        final Set<NotificationDefinition> notifications = module.getNotifications();
+
+        for (final NotificationDefinition notification : notifications) {
+            if (notification != null) {
+                DataNodeIterator it = new DataNodeIterator(notification);
+
+                // Containers
+                for (ContainerSchemaNode node : it.allContainers()) {
+                    if (!node.isAddedByUses()) {
+                        genNotifyTypes.add(containerToGenType(basePackageName, node));
+                    }
+                }
+                // Lists
+                for (ListSchemaNode node : it.allLists()) {
+                    if (!node.isAddedByUses()) {
+                        genNotifyTypes.addAll(listToGenType(basePackageName, node));
+                    }
+                }
+                final GeneratedTypeBuilder notificationTypeBuilder = addDefaultInterfaceDefinition(basePackageName,
+                        notification);
+                notificationTypeBuilder.addImplementsType(Types
+                        .typeForClass(org.opendaylight.yangtools.yang.binding.Notification.class));
+                // Notification object
+                resolveDataSchemaNodes(basePackageName, notificationTypeBuilder, notification.getChildNodes());
+                genNotifyTypes.add(notificationTypeBuilder.toInstance());
+            }
+        }
+        return genNotifyTypes;
+    }
+
+    /**
+     * 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}
+     * @return list of <code>Type</code> which are generated from identities
+     *         (object of type <code>IdentitySchemaNode</code>
+     * 
+     */
+    private List<Type> allIdentitiesToGenTypes(final Module module, final SchemaContext context) {
+        List<Type> genTypes = new ArrayList<>();
+
+        final Set<IdentitySchemaNode> schemaIdentities = module.getIdentities();
+
+        final String basePackageName = moduleNamespaceToPackageName(module);
+
+        if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
+            for (final IdentitySchemaNode identity : schemaIdentities) {
+                genTypes.add(identityToGenType(basePackageName, identity, context));
+            }
+        }
+        return genTypes;
+    }
+
+    /**
+     * 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 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
+     * 
+     * @return GeneratedType which is generated from identity (object of type
+     *         <code>IdentitySchemaNode</code>
+     * 
+     */
+    private GeneratedType identityToGenType(final String basePackageName, final IdentitySchemaNode identity,
+            final SchemaContext context) {
+        if (identity == null) {
+            return null;
+        }
+
+        final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath());
+        final String genTypeName = parseToClassName(identity.getQName().getLocalName());
+        final GeneratedTOBuilderImpl newType = new GeneratedTOBuilderImpl(packageName, genTypeName);
+
+        IdentitySchemaNode baseIdentity = identity.getBaseIdentity();
+        if (baseIdentity != null) {
+            Module baseIdentityParentModule = SchemaContextUtil.findParentModule(context, baseIdentity);
+
+            final String returnTypePkgName = moduleNamespaceToPackageName(baseIdentityParentModule);
+            final String returnTypeName = parseToClassName(baseIdentity.getQName().getLocalName());
+
+            GeneratedTransferObject gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName).toInstance();
+            newType.setExtendsType(gto);
+        } else {
+            newType.setExtendsType(Types.getBaseIdentityTO());
+        }
+        newType.setAbstract(true);
+        return newType.toInstance();
+    }
+
+    /**
+     * 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 dependend (indepedent) groupings are in the list
+     * saved at first positions. For every grouping the record is added to map
+     * {@link BindingGeneratorImpl#allGroupings allGroupings}
+     * 
+     * @param module
+     *            module from which is obtained set of all grouping objects to
+     *            iterate over them
+     * @return list of <code>Type</code> which are generated from groupings
+     *         (object of type <code>GroupingDefinition</code>)
+     * 
+     */
+    private List<Type> allGroupingsToGenTypes(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module parameter can not be null");
+        }
+        final List<Type> genTypes = new ArrayList<>();
+        final String basePackageName = moduleNamespaceToPackageName(module);
+        final Set<GroupingDefinition> groupings = module.getGroupings();
+        List<GroupingDefinition> groupingsSortedByDependencies;
+
+        groupingsSortedByDependencies = GroupingDefinitionDependencySort.sort(groupings); 
+
+        for (final GroupingDefinition grouping : groupingsSortedByDependencies) {
+            GeneratedType genType = groupingToGenType(basePackageName, grouping);
+            genTypes.add(genType);
+            SchemaPath schemaPath = grouping.getPath();
+            allGroupings.put(schemaPath, genType);
+        }
+        return genTypes;
+    }
+
+    /**
+     * 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
+     * @return GeneratedType which is generated from grouping (object of type
+     *         <code>GroupingDefinition</code>)
+     */
+    private GeneratedType groupingToGenType(final String basePackageName, GroupingDefinition grouping) {
+        if (grouping == null) {
+            return null;
+        }
+
+        final String packageName = packageNameForGeneratedType(basePackageName, grouping.getPath());
+        final Set<DataSchemaNode> schemaNodes = grouping.getChildNodes();
+        final GeneratedTypeBuilder typeBuilder = addDefaultInterfaceDefinition(packageName, grouping);
+
+        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
+        return typeBuilder.toInstance();
+    }
+
+    /**
+     * Tries to find EnumTypeDefinition in <code>typeDefinition</code>. If base
+     * type of <code>typeDefinition</code> is of the type ExtendedType then this
+     * method is recursivelly 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 EnumTypeDefinition enumTypeDefFromExtendedType(final TypeDefinition<?> typeDefinition) {
+        if (typeDefinition != null) {
+            if (typeDefinition.getBaseType() instanceof EnumTypeDefinition) {
+                return (EnumTypeDefinition) typeDefinition.getBaseType();
+            } else if (typeDefinition.getBaseType() instanceof ExtendedType) {
+                return enumTypeDefFromExtendedType(typeDefinition.getBaseType());
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 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 contais data from
+     *         <code>enumTypeDef</code>
+     */
+    private EnumBuilder resolveInnerEnumFromTypeDefinition(final EnumTypeDefinition enumTypeDef, final String enumName,
+            final GeneratedTypeBuilder typeBuilder) {
+        if ((enumTypeDef != null) && (typeBuilder != null) && (enumTypeDef.getQName() != null)
+                && (enumTypeDef.getQName().getLocalName() != null)) {
+
+            final String enumerationName = parseToClassName(enumName);
+            final EnumBuilder enumBuilder = typeBuilder.addEnumeration(enumerationName);
+
+            if (enumBuilder != null) {
+                final List<EnumPair> enums = enumTypeDef.getValues();
+                if (enums != null) {
+                    int listIndex = 0;
+                    for (final EnumPair enumPair : enums) {
+                        if (enumPair != null) {
+                            final String enumPairName = parseToClassName(enumPair.getName());
+                            Integer enumPairValue = enumPair.getValue();
+
+                            if (enumPairValue == null) {
+                                enumPairValue = listIndex;
+                            }
+                            enumBuilder.addValue(enumPairName, enumPairValue);
+                            listIndex++;
+                        }
+                    }
+                }
+                return enumBuilder;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 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 GeneratedTypeBuilder moduleTypeBuilder(final Module module, final String postfix) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        String packageName = moduleNamespaceToPackageName(module);
+        final String moduleName = parseToClassName(module.getName()) + postfix;
+
+        return new GeneratedTypeBuilderImpl(packageName, moduleName);
+
+    }
+
+    /**
+     * 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 agumentation
+     *            (target path, childs...)
+     * @return list of <code>Type</code> objects which contains generated type
+     *         for augmentation and for container, list and choice child nodes
+     * @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 List<Type> augmentationToGenTypes(final String augmentPackageName, final AugmentationSchema augSchema) {
+        if (augmentPackageName == null) {
+            throw new IllegalArgumentException("Package Name cannot be NULL!");
+        }
+        if (augSchema == null) {
+            throw new IllegalArgumentException("Augmentation Schema cannot be NULL!");
+        }
+        if (augSchema.getTargetPath() == null) {
+            throw new IllegalStateException("Augmentation Schema does not contain Target Path (Target Path is NULL).");
+        }
+
+        final List<Type> genTypes = new ArrayList<>();
+
+        // EVERY augmented interface will extends Augmentation<T> interface
+        // and DataObject interface!!!
+        final SchemaPath targetPath = augSchema.getTargetPath();
+        final DataSchemaNode targetSchemaNode = findDataSchemaNode(schemaContext, targetPath);
+        if ((targetSchemaNode != null) && (targetSchemaNode.getQName() != null)
+                && (targetSchemaNode.getQName().getLocalName() != null)) {
+            final Module targetModule = findParentModule(schemaContext, targetSchemaNode);
+            final String targetBasePackage = moduleNamespaceToPackageName(targetModule);
+            final String targetPackageName = packageNameForGeneratedType(targetBasePackage, targetSchemaNode.getPath());
+            final String targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
+            final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
+
+            if (!(targetSchemaNode instanceof ChoiceNode)) {
+                final GeneratedTypeBuilder augTypeBuilder = addRawAugmentGenTypeDefinition(augmentPackageName,
+                        targetPackageName, targetSchemaNodeName, augSchema);
+                final GeneratedType augType = augTypeBuilder.toInstance();
+                genTypes.add(augType);
+            } else {
+                final Type refChoiceType = new ReferencedTypeImpl(targetPackageName,
+                        parseToClassName(targetSchemaNodeName));
+                final ChoiceNode choiceTarget = (ChoiceNode) targetSchemaNode;
+                final Set<ChoiceCaseNode> choiceCaseNodes = choiceTarget.getCases();
+                genTypes.addAll(generateTypesFromAugmentedChoiceCases(augmentPackageName, refChoiceType,
+                        choiceCaseNodes));
+            }
+            genTypes.addAll(augmentationBodyToGenTypes(augmentPackageName, augChildNodes));
+        }
+        return genTypes;
+    }
+
+    /**
+     * 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 augmentPackageName
+     *            string with contains the package name to which the augment
+     *            belongs
+     * @param targetPackageName
+     *            string with the package name to which the augmented node
+     *            belongs
+     * @param targetSchemaNodeName
+     *            string with the name of the augmented node
+     * @param augSchema
+     *            augmentation schema which contains data about the child nodes
+     *            and uses of augment
+     * @return generated type builder for augment
+     */
+    private GeneratedTypeBuilder addRawAugmentGenTypeDefinition(final String augmentPackageName,
+            final String targetPackageName, final String targetSchemaNodeName, final AugmentationSchema augSchema) {
+        final String targetTypeName = parseToClassName(targetSchemaNodeName);
+        Map<String, GeneratedTypeBuilder> augmentBuilders = genTypeBuilders.get(augmentPackageName);
+        if (augmentBuilders == null) {
+            augmentBuilders = new HashMap<>();
+            genTypeBuilders.put(augmentPackageName, augmentBuilders);
+        }
+        final String augIdentifier = getAugmentIdentifier(augSchema.getUnknownSchemaNodes());
+        
+        final String augTypeName =  augIdentifier != null ? parseToClassName(augIdentifier): augGenTypeName(augmentBuilders, targetTypeName);
+        final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);
+        final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
+
+        final GeneratedTypeBuilder augTypeBuilder = new GeneratedTypeBuilderImpl(augmentPackageName, augTypeName);
+
+        augTypeBuilder.addImplementsType(Types.DATA_OBJECT);
+        augTypeBuilder.addImplementsType(Types.augmentationTypeFor(targetTypeRef));
+        addImplementedInterfaceFromUses(augSchema, augTypeBuilder);
+
+        augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);
+        augmentBuilders.put(augTypeName, augTypeBuilder);
+        return augTypeBuilder;
+    }
+
+    private String getAugmentIdentifier(List<UnknownSchemaNode> unknownSchemaNodes) {
+        String ret = null;
+        for (UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) {
+            QName nodeType = unknownSchemaNode.getNodeType();
+            if(AUGMENT_IDENTIFIER_NAME.equals(nodeType.getLocalName()) &&
+                    YANG_EXT_NAMESPACE.equals(nodeType.getNamespace().toString())) {
+                return unknownSchemaNode.getNodeParameter();
+            }
+        }
+        return ret;
+    }
+
+    /**
+     * Convert a container, list and choice subnodes (and recursivelly their
+     * subnodes) of augment to generated types
+     * 
+     * @param augBasePackageName
+     *            string with the augment package name
+     * @param augChildNodes
+     *            set of data schema nodes which represents child nodes of the
+     *            augment
+     * 
+     * @return list of <code>Type</code> which represents container, list and
+     *         choice subnodes of augment
+     */
+    private List<Type> augmentationBodyToGenTypes(final String augBasePackageName,
+            final Set<DataSchemaNode> augChildNodes) {
+        final List<Type> genTypes = new ArrayList<>();
+        final List<DataNodeIterator> augSchemaIts = new ArrayList<>();
+        for (final DataSchemaNode childNode : augChildNodes) {
+            if (childNode instanceof DataNodeContainer) {
+                augSchemaIts.add(new DataNodeIterator((DataNodeContainer) childNode));
+
+                if (childNode instanceof ContainerSchemaNode) {
+                    genTypes.add(containerToGenType(augBasePackageName, (ContainerSchemaNode) childNode));
+                } else if (childNode instanceof ListSchemaNode) {
+                    genTypes.addAll(listToGenType(augBasePackageName, (ListSchemaNode) childNode));
+                }
+            } else if (childNode instanceof ChoiceNode) {
+                final ChoiceNode choice = (ChoiceNode) childNode;
+                for (final ChoiceCaseNode caseNode : choice.getCases()) {
+                    augSchemaIts.add(new DataNodeIterator(caseNode));
+                }
+                genTypes.addAll(choiceToGeneratedType(augBasePackageName, (ChoiceNode) childNode));
+            }
+        }
+
+        for (final DataNodeIterator it : augSchemaIts) {
+            final List<ContainerSchemaNode> augContainers = it.allContainers();
+            final List<ListSchemaNode> augLists = it.allLists();
+            final List<ChoiceNode> augChoices = it.allChoices();
+
+            if (augContainers != null) {
+                for (final ContainerSchemaNode container : augContainers) {
+                    genTypes.add(containerToGenType(augBasePackageName, container));
+                }
+            }
+            if (augLists != null) {
+                for (final ListSchemaNode list : augLists) {
+                    genTypes.addAll(listToGenType(augBasePackageName, list));
+                }
+            }
+            if (augChoices != null) {
+                for (final ChoiceNode choice : augChoices) {
+                    genTypes.addAll(choiceToGeneratedType(augBasePackageName, choice));
+                }
+            }
+        }
+        return genTypes;
+    }
+
+    /**
+     * 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 String augGenTypeName(final Map<String, GeneratedTypeBuilder> builders, final String genTypeName) {
+        String augTypeName = genTypeName;
+
+        int index = 1;
+        while ((builders != null) && builders.containsKey(genTypeName + index)) {
+            index++;
+        }
+        augTypeName += index;
+        return augTypeName;
+    }
+
+    /**
+     * Converts <code>containerNode</code> to generated type. Firstly the
+     * generated type builder is created. The subnodes of
+     * <code>containerNode</code> are added as methods and the instance of
+     * <code>GeneratedType</code> is returned.
+     * 
+     * @param basePackageName
+     *            string contains the module package name
+     * @param containerNode
+     *            container schema node with the data about childs nodes and
+     *            schema paths
+     * @return generated type for <code>containerNode</code>
+     */
+    private GeneratedType containerToGenType(final String basePackageName, ContainerSchemaNode containerNode) {
+        if (containerNode == null) {
+            return null;
+        }
+
+        final String packageName = packageNameForGeneratedType(basePackageName, containerNode.getPath());
+        final Set<DataSchemaNode> schemaNodes = containerNode.getChildNodes();
+        final GeneratedTypeBuilder typeBuilder = addDefaultInterfaceDefinition(packageName, containerNode);
+
+        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
+        return typeBuilder.toInstance();
+    }
+
+    /**
+     * 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 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 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 GeneratedTypeBuilder resolveDataSchemaNodes(final String basePackageName,
+            final GeneratedTypeBuilder typeBuilder, final Set<DataSchemaNode> schemaNodes) {
+        if ((schemaNodes != null) && (typeBuilder != null)) {
+            for (final DataSchemaNode schemaNode : schemaNodes) {
+                if (schemaNode.isAugmenting() || schemaNode.isAddedByUses()) {
+                    continue;
+                }
+                addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+            }
+        }
+        return typeBuilder;
+    }
+
+    /**
+     * Adds the methods to <code>typeBuilder</code> what represents subnodes of
+     * node for which <code>typeBuilder</code> was created.
+     * 
+     * @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 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 GeneratedTypeBuilder augSchemaNodeToMethods(final String basePackageName,
+            final GeneratedTypeBuilder typeBuilder, final Set<DataSchemaNode> schemaNodes) {
+        if ((schemaNodes != null) && (typeBuilder != null)) {
+            for (final DataSchemaNode schemaNode : schemaNodes) {
+                if (schemaNode.isAugmenting()) {
+                    addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+                }
+            }
+        }
+        return typeBuilder;
+    }
+
+    /**
+     * Adds to <code>typeBuilder</code> a method which is derived from
+     * <code>schemaNode</code>.
+     * 
+     * @param basePackageName
+     *            string with the module package name
+     * @param schemaNode
+     *            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.
+     */
+    private void addSchemaNodeToBuilderAsMethod(final String basePackageName, final DataSchemaNode schemaNode,
+            final GeneratedTypeBuilder typeBuilder) {
+        if (schemaNode != null && typeBuilder != null) {
+            if (schemaNode instanceof LeafSchemaNode) {
+                resolveLeafSchemaNodeAsMethod(typeBuilder, (LeafSchemaNode) schemaNode);
+            } else if (schemaNode instanceof LeafListSchemaNode) {
+                resolveLeafListSchemaNode(typeBuilder, (LeafListSchemaNode) schemaNode);
+            } else if (schemaNode instanceof ContainerSchemaNode) {
+                resolveContainerSchemaNode(basePackageName, typeBuilder, (ContainerSchemaNode) schemaNode);
+            } else if (schemaNode instanceof ListSchemaNode) {
+                resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);
+            } else if (schemaNode instanceof ChoiceNode) {
+                resolveChoiceSchemaNode(basePackageName, typeBuilder, (ChoiceNode) schemaNode);
+            }
+        }
+    }
+
+    /**
+     * Creates a getter method for a choice node.
+     * 
+     * Firstly generated type builder for choice is created or found in
+     * {@link BindingGeneratorImpl#allGroupings allGroupings}. The package name
+     * in the builder is created as concatenation of module package name and
+     * names of all parent nodes. In the end the getter method for choice is
+     * added to <code>typeBuilder</code> and return type is set to choice
+     * builder.
+     * 
+     * @param basePackageName
+     *            string with the module package name
+     * @param typeBuilder
+     *            generated type builder to which is <code>choiceNode</code>
+     *            added as getter method
+     * @param choiceNode
+     *            choice node which is mapped as a getter method
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>typeBuilder</code> equals null</li>
+     *             <li>if <code>choiceNode</code> equals null</li>
+     *             </ul>
+     * 
+     */
+    private void resolveChoiceSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,
+            final ChoiceNode choiceNode) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (typeBuilder == null) {
+            throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");
+        }
+        if (choiceNode == null) {
+            throw new IllegalArgumentException("Choice Schema Node cannot be NULL!");
+        }
+
+        final String choiceName = choiceNode.getQName().getLocalName();
+        if (choiceName != null && !choiceNode.isAddedByUses()) {
+            final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath());
+            final GeneratedTypeBuilder choiceType = addDefaultInterfaceDefinition(packageName, choiceNode);
+            constructGetter(typeBuilder, choiceName, choiceNode.getDescription(), choiceType);
+        }
+    }
+
+    /**
+     * 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 basePackageName
+     *            string with the module package name
+     * @param choiceNode
+     *            choice node which is mapped to generated type. Also child
+     *            nodes - cases are mapped to generated types.
+     * @return list of generated types which contains generated type for choice
+     *         and generated types for all cases which aren't added do choice
+     *         through <i>uses</i>.
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>choiceNode</code> equals null</li>
+     *             </ul>
+     * 
+     */
+    private List<GeneratedType> choiceToGeneratedType(final String basePackageName, final ChoiceNode choiceNode) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (choiceNode == null) {
+            throw new IllegalArgumentException("Choice Schema Node cannot be NULL!");
+        }
+
+        final List<GeneratedType> generatedTypes = new ArrayList<>();
+        final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath());
+        final GeneratedTypeBuilder choiceTypeBuilder = addRawInterfaceDefinition(packageName, choiceNode);
+        choiceTypeBuilder.addImplementsType(Types.DATA_OBJECT);
+        final GeneratedType choiceType = choiceTypeBuilder.toInstance();
+
+        generatedTypes.add(choiceType);
+        final Set<ChoiceCaseNode> caseNodes = choiceNode.getCases();
+        if ((caseNodes != null) && !caseNodes.isEmpty()) {
+            generatedTypes.addAll(generateTypesFromChoiceCases(basePackageName, choiceType, caseNodes));
+        }
+        return generatedTypes;
+    }
+
+    /**
+     * 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 List<GeneratedType> generateTypesFromChoiceCases(final String basePackageName, final Type refChoiceType,
+            final Set<ChoiceCaseNode> caseNodes) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (refChoiceType == null) {
+            throw new IllegalArgumentException("Referenced Choice Type cannot be NULL!");
+        }
+        if (caseNodes == null) {
+            throw new IllegalArgumentException("Set of Choice Case Nodes cannot be NULL!");
+        }
+
+        final List<GeneratedType> generatedTypes = new ArrayList<>();
+        for (final ChoiceCaseNode caseNode : caseNodes) {
+            if (caseNode != null && !caseNode.isAddedByUses() && !caseNode.isAugmenting()) {
+                final String packageName = packageNameForGeneratedType(basePackageName, caseNode.getPath());
+                final GeneratedTypeBuilder caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
+                caseTypeBuilder.addImplementsType(refChoiceType);
+
+                final Set<DataSchemaNode> childNodes = caseNode.getChildNodes();
+                if (childNodes != null) {
+                    resolveDataSchemaNodes(basePackageName, caseTypeBuilder, childNodes);
+                }
+                generatedTypes.add(caseTypeBuilder.toInstance());
+            }
+        }
+
+        return generatedTypes;
+    }
+
+    /**
+     * 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 List<GeneratedType> generateTypesFromAugmentedChoiceCases(final String basePackageName,
+            final Type refChoiceType, final Set<ChoiceCaseNode> caseNodes) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (refChoiceType == null) {
+            throw new IllegalArgumentException("Referenced Choice Type cannot be NULL!");
+        }
+        if (caseNodes == null) {
+            throw new IllegalArgumentException("Set of Choice Case Nodes cannot be NULL!");
+        }
+
+        final List<GeneratedType> generatedTypes = new ArrayList<>();
+        for (final ChoiceCaseNode caseNode : caseNodes) {
+            if (caseNode != null && caseNode.isAugmenting()) {
+                final String packageName = packageNameForGeneratedType(basePackageName, caseNode.getPath());
+                final GeneratedTypeBuilder caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
+                caseTypeBuilder.addImplementsType(refChoiceType);
+
+                final Set<DataSchemaNode> childNodes = caseNode.getChildNodes();
+                if (childNodes != null) {
+                    resolveDataSchemaNodes(basePackageName, caseTypeBuilder, childNodes);
+                }
+                generatedTypes.add(caseTypeBuilder.toInstance());
+            }
+        }
+
+        return generatedTypes;
+    }
+
+    /**
+     * 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 boolean resolveLeafSchemaNodeAsMethod(final GeneratedTypeBuilder typeBuilder, final LeafSchemaNode leaf) {
+        if ((leaf != null) && (typeBuilder != null)) {
+            final String leafName = leaf.getQName().getLocalName();
+            String leafDesc = leaf.getDescription();
+            if (leafDesc == null) {
+                leafDesc = "";
+            }
+
+            if (leafName != null && !leaf.isAddedByUses()) {
+                final TypeDefinition<?> typeDef = leaf.getType();
+
+                Type returnType = null;
+                if (typeDef instanceof EnumTypeDefinition) {
+                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef);
+                    final EnumTypeDefinition enumTypeDef = enumTypeDefFromExtendedType(typeDef);
+                    final EnumBuilder enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, leafName,
+                            typeBuilder);
+
+                    if (enumBuilder != null) {
+                        returnType = new ReferencedTypeImpl(enumBuilder.getPackageName(), enumBuilder.getName());
+                    }
+                    ((TypeProviderImpl) typeProvider).putReferencedType(leaf.getPath(), returnType);
+                } else if (typeDef instanceof UnionType) {
+                    GeneratedTOBuilder genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName);
+                    if (genTOBuilder != null) {
+                        returnType = new ReferencedTypeImpl(genTOBuilder.getPackageName(), genTOBuilder.getName());
+                    }
+                } else if (typeDef instanceof BitsTypeDefinition) {
+                    GeneratedTOBuilder genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName);
+                    if (genTOBuilder != null) {
+                        returnType = new ReferencedTypeImpl(genTOBuilder.getPackageName(), genTOBuilder.getName());
+                    }
+                } else {
+                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef);
+                }
+                if (returnType != null) {
+                    constructGetter(typeBuilder, leafName, leafDesc, returnType);
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 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 boolean resolveLeafSchemaNodeAsProperty(final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf,
+            boolean isReadOnly) {
+        if ((leaf != null) && (toBuilder != null)) {
+            final String leafName = leaf.getQName().getLocalName();
+            String leafDesc = leaf.getDescription();
+            if (leafDesc == null) {
+                leafDesc = "";
+            }
+
+            if (leafName != null && !leaf.isAddedByUses()) {
+                final TypeDefinition<?> typeDef = leaf.getType();
+
+                // TODO: properly resolve enum types
+                final Type returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef);
+
+                if (returnType != null) {
+                    final GeneratedPropertyBuilder propBuilder = toBuilder.addProperty(parseToClassName(leafName));
+
+                    propBuilder.setReadOnly(isReadOnly);
+                    propBuilder.setReturnType(returnType);
+                    propBuilder.setComment(leafDesc);
+
+                    toBuilder.addEqualsIdentity(propBuilder);
+                    toBuilder.addHashIdentity(propBuilder);
+                    toBuilder.addToStringProperty(propBuilder);
+
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 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 boolean resolveLeafListSchemaNode(final GeneratedTypeBuilder typeBuilder, final LeafListSchemaNode node) {
+        if ((node != null) && (typeBuilder != null)) {
+            final String nodeName = node.getQName().getLocalName();
+            String nodeDesc = node.getDescription();
+            if (nodeDesc == null) {
+                nodeDesc = "";
+            }
+
+            if (nodeName != null && !node.isAddedByUses()) {
+                final TypeDefinition<?> type = node.getType();
+                final Type listType = Types.listTypeFor(typeProvider.javaTypeForSchemaDefinitionType(type));
+
+                constructGetter(typeBuilder, nodeName, nodeDesc, listType);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Creates a getter method for a container node.
+     * 
+     * Firstly generated type builder for container is created or found in
+     * {@link BindingGeneratorImpl#allGroupings allGroupings}. The package name
+     * in the builder is created as concatenation of module package name and
+     * names of all parent nodes. In the end the getter method for container is
+     * added to <code>typeBuilder</code> and return type is set to container
+     * type builder.
+     * 
+     * @param basePackageName
+     *            string with the module package name
+     * @param typeBuilder
+     *            generated type builder to which is <code>containerNode</code>
+     *            added as getter method
+     * @param containerNode
+     *            container schema node which is mapped as getter method to
+     *            <code>typeBuilder</code>
+     * @return boolean value
+     *         <ul>
+     *         <li>false - if <code>containerNode</code>,
+     *         <code>typeBuilder</code>, container node name equal null or
+     *         <code>containerNode</code> is added by uses</li>
+     *         <li>true - other cases</li>
+     *         </ul>
+     */
+    private boolean resolveContainerSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,
+            final ContainerSchemaNode containerNode) {
+        if ((containerNode != null) && (typeBuilder != null)) {
+            final String nodeName = containerNode.getQName().getLocalName();
+
+            if (nodeName != null && !containerNode.isAddedByUses()) {
+                final String packageName = packageNameForGeneratedType(basePackageName, containerNode.getPath());
+
+                final GeneratedTypeBuilder rawGenType = addDefaultInterfaceDefinition(packageName, containerNode);
+                constructGetter(typeBuilder, nodeName, containerNode.getDescription(), rawGenType);
+
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Creates a getter method for a list node.
+     * 
+     * Firstly generated type builder for list is created or found in
+     * {@link BindingGeneratorImpl#allGroupings allGroupings}. The package name
+     * in the builder is created as concatenation of module package name and
+     * names of all parent nodes. In the end the getter method for list is added
+     * to <code>typeBuilder</code> and return type is set to list type builder.
+     * 
+     * @param basePackageName
+     *            string with the module package name
+     * @param typeBuilder
+     *            generated type builder to which is <code></code> added as
+     *            getter method
+     * @param listNode
+     *            list schema node which is mapped as getter method to
+     *            <code>typeBuilder</code>
+     * @return boolean value
+     *         <ul>
+     *         <li>false - if <code>listNode</code>, <code>typeBuilder</code>,
+     *         list node name equal null or <code>listNode</code> is added by
+     *         uses</li>
+     *         <li>true - other cases</li>
+     *         </ul>
+     */
+    private boolean resolveListSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,
+            final ListSchemaNode listNode) {
+        if ((listNode != null) && (typeBuilder != null)) {
+            final String listName = listNode.getQName().getLocalName();
+
+            if (listName != null && !listNode.isAddedByUses()) {
+                final String packageName = packageNameForGeneratedType(basePackageName, listNode.getPath());
+                final GeneratedTypeBuilder rawGenType = addDefaultInterfaceDefinition(packageName, listNode);
+                constructGetter(typeBuilder, listName, listNode.getDescription(), Types.listTypeFor(rawGenType));
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 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
+     * @return generated type builder <code>schemaNode</code>
+     */
+    private GeneratedTypeBuilder addDefaultInterfaceDefinition(final String packageName, final SchemaNode schemaNode) {
+        final GeneratedTypeBuilder builder = addRawInterfaceDefinition(packageName, schemaNode, "");
+        builder.addImplementsType(Types.DATA_OBJECT);
+        if (!(schemaNode instanceof GroupingDefinition)) {
+            builder.addImplementsType(Types.augmentableTypeFor(builder));
+        }
+
+        if (schemaNode instanceof DataNodeContainer) {
+            addImplementedInterfaceFromUses((DataNodeContainer) schemaNode, builder);
+        }
+
+        return builder;
+    }
+
+    /**
+     * 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 GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode) {
+        return addRawInterfaceDefinition(packageName, schemaNode, "");
+    }
+
+    /**
+     * 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
+     * @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 nul</li>
+     *             </ul>
+     * 
+     */
+    private GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode,
+            final String prefix) {
+        if (schemaNode == null) {
+            throw new IllegalArgumentException("Data Schema Node cannot be NULL!");
+        }
+        if (packageName == null) {
+            throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");
+        }
+        if (schemaNode.getQName() == null) {
+            throw new IllegalArgumentException("QName for Data Schema Node cannot be NULL!");
+        }
+        final String schemaNodeName = schemaNode.getQName().getLocalName();
+        if (schemaNodeName == null) {
+            throw new IllegalArgumentException("Local Name of QName for Data Schema Node cannot be NULL!");
+        }
+
+        final String genTypeName;
+        if (prefix == null) {
+            genTypeName = parseToClassName(schemaNodeName);
+        } else {
+            genTypeName = prefix + parseToClassName(schemaNodeName);
+        }
+
+        final GeneratedTypeBuilder newType = new GeneratedTypeBuilderImpl(packageName, genTypeName);
+        if (!genTypeBuilders.containsKey(packageName)) {
+            final Map<String, GeneratedTypeBuilder> builders = new HashMap<>();
+            builders.put(genTypeName, newType);
+            genTypeBuilders.put(packageName, builders);
+        } else {
+            final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);
+            if (!builders.containsKey(genTypeName)) {
+                builders.put(genTypeName, newType);
+            }
+        }
+        return newType;
+    }
+
+    /**
+     * Creates the name of the getter method from <code>methodName</code>.
+     * 
+     * @param methodName
+     *            string with the name of the getter method
+     * @return string with the name of the getter method for
+     *         <code>methodName</code> in JAVA method format
+     */
+    private String getterMethodName(final String methodName) {
+        final StringBuilder method = new StringBuilder();
+        method.append("get");
+        method.append(parseToClassName(methodName));
+        return method.toString();
+    }
+
+    /**
+     * Creates the name of the setter method from <code>methodName</code>.
+     * 
+     * @param methodName
+     *            string with the name of the setter method
+     * @return string with the name of the setter method for
+     *         <code>methodName</code> in JAVA method format
+     */
+    private String setterMethodName(final String methodName) {
+        final StringBuilder method = new StringBuilder();
+        method.append("set");
+        method.append(parseToClassName(methodName));
+        return method.toString();
+    }
+
+    /**
+     * 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 MethodSignatureBuilder constructGetter(final GeneratedTypeBuilder interfaceBuilder,
+            final String schemaNodeName, final String comment, final Type returnType) {
+        final MethodSignatureBuilder getMethod = interfaceBuilder.addMethod(getterMethodName(schemaNodeName));
+
+        getMethod.setComment(comment);
+        getMethod.setReturnType(returnType);
+
+        return getMethod;
+    }
+
+    /**
+     * Creates a method signature builder as a part of
+     * <code>interfaceBuilder</code> for <code>schemaNodeName</code>
+     * 
+     * The method signature builder is created for the setter method of
+     * <code>schemaNodeName</code>. Also <code>comment</code>
+     * <code>parameterType</code> data are added to the builder. The return type
+     * of the method is set to <code>void</code>.
+     * 
+     * @param interfaceBuilder
+     *            generated type builder for which the setter method should be
+     *            created
+     * @param schemaNodeName
+     *            string with schema node name. The name will be the part of the
+     *            setter method name.
+     * @param comment
+     *            string with comment for the setter method
+     * @param parameterType
+     *            type which represents the type of the setter method input
+     *            parameter
+     * @return method signature builder which represents the setter method of
+     *         <code>interfaceBuilder</code>
+     */
+    private MethodSignatureBuilder constructSetter(final GeneratedTypeBuilder interfaceBuilder,
+            final String schemaNodeName, final String comment, final Type parameterType) {
+        final MethodSignatureBuilder setMethod = interfaceBuilder.addMethod(setterMethodName(schemaNodeName));
+
+        setMethod.setComment(comment);
+        setMethod.addParameter(parameterType, parseToValidParamName(schemaNodeName));
+        setMethod.setReturnType(Types.voidType());
+
+        return setMethod;
+    }
+
+    private List<Type> listToGenType(final String basePackageName, final ListSchemaNode list) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");
+        }
+        if (list == null) {
+            throw new IllegalArgumentException("List Schema Node cannot be NULL!");
+        }
+
+        final String packageName = packageNameForGeneratedType(basePackageName, list.getPath());
+        // final GeneratedTypeBuilder typeBuilder =
+        // resolveListTypeBuilder(packageName, list);
+        final GeneratedTypeBuilder typeBuilder = addDefaultInterfaceDefinition(packageName, list);
+
+        final List<String> listKeys = listKeys(list);
+        GeneratedTOBuilder genTOBuilder = resolveListKeyTOBuilder(packageName, list);
+        
+        
+        if(genTOBuilder != null) {
+            ParameterizedType identifierMarker = Types.parameterizedTypeFor( Types.typeForClass(Identifier.class), typeBuilder);
+            ParameterizedType identifiableMarker = Types.parameterizedTypeFor(Types.typeForClass(Identifiable.class), genTOBuilder);
+            genTOBuilder.addImplementsType(identifierMarker);
+            typeBuilder.addImplementsType(identifiableMarker);
+        }
+        final Set<DataSchemaNode> schemaNodes = list.getChildNodes();
+
+        for (final DataSchemaNode schemaNode : schemaNodes) {
+            if (schemaNode.isAugmenting()) {
+                continue;
+            }
+            addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder, genTOBuilder, listKeys);
+        }
+        return typeBuildersToGenTypes(typeBuilder, genTOBuilder);
+    }
+
+    /**
+     * 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
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>schemaNode</code> equals null</li>
+     *             <li>if <code>typeBuilder</code> equals null</li>
+     *             </ul>
+     */
+    private void addSchemaNodeToListBuilders(final String basePackageName, final DataSchemaNode schemaNode,
+            final GeneratedTypeBuilder typeBuilder, final GeneratedTOBuilder genTOBuilder, final List<String> listKeys) {
+        if (schemaNode == null) {
+            throw new IllegalArgumentException("Data Schema Node cannot be NULL!");
+        }
+
+        if (typeBuilder == null) {
+            throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");
+        }
+
+        if (schemaNode instanceof LeafSchemaNode) {
+            final LeafSchemaNode leaf = (LeafSchemaNode) schemaNode;
+            final String leafName = leaf.getQName().getLocalName();
+            if (!listKeys.contains(leafName)) {
+                resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);
+            } else {
+                resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true);
+            }
+        } else if (schemaNode instanceof LeafListSchemaNode) {
+            resolveLeafListSchemaNode(typeBuilder, (LeafListSchemaNode) schemaNode);
+        } else if (schemaNode instanceof ContainerSchemaNode) {
+            resolveContainerSchemaNode(basePackageName, typeBuilder, (ContainerSchemaNode) schemaNode);
+        } else if (schemaNode instanceof ListSchemaNode) {
+            resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);
+        }
+    }
+
+    private List<Type> typeBuildersToGenTypes(final GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder) {
+        final List<Type> genTypes = new ArrayList<>();
+        if (typeBuilder == null) {
+            throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");
+        }
+
+        if (genTOBuilder != null) {
+            final GeneratedTransferObject genTO = genTOBuilder.toInstance();
+            constructGetter(typeBuilder, "key", "Returns Primary Key of Yang List Type", genTO);
+            genTypes.add(genTO);
+        }
+        genTypes.add(typeBuilder.toInstance());
+        return genTypes;
+    }
+
+    /**
+     * 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 List<String> listKeys(final ListSchemaNode list) {
+        final List<String> listKeys = new ArrayList<>();
+
+        if (list.getKeyDefinition() != null) {
+            final List<QName> keyDefinitions = list.getKeyDefinition();
+
+            for (final QName keyDefinition : keyDefinitions) {
+                listKeys.add(keyDefinition.getLocalName());
+            }
+        }
+        return listKeys;
+    }
+
+
+    /**
+     * 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 GeneratedTOBuilder resolveListKeyTOBuilder(final String packageName, final ListSchemaNode list) {
+        GeneratedTOBuilder genTOBuilder = null;
+        if ((list.getKeyDefinition() != null) && (!list.getKeyDefinition().isEmpty())) {
+            if (list != null) {
+                final String listName = list.getQName().getLocalName() + "Key";
+                genTOBuilder = schemaNodeToTransferObjectBuilder(packageName, listName);
+            }
+        }
+        return genTOBuilder;
+
+    }
+
+    /**
+     * 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.
+     * 
+     * @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
+     * @return generated TO builder for <code>typeDef</code>
+     */
+    private GeneratedTOBuilder addTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,
+            String leafName) {
+        final String classNameFromLeaf = parseToClassName(leafName);
+        GeneratedTOBuilder genTOBuilder = null;
+        final String packageName = typeBuilder.getFullyQualifiedName();
+        if (typeDef instanceof UnionTypeDefinition) {
+            genTOBuilder = ((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForUnionTypeDefinition(packageName, typeDef,
+                    classNameFromLeaf);
+        } else if (typeDef instanceof BitsTypeDefinition) {
+            genTOBuilder = ((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForBitsTypeDefinition(packageName, typeDef,
+                    classNameFromLeaf);
+        }
+        if (genTOBuilder != null) {
+            typeBuilder.addEnclosingTransferObject(genTOBuilder);
+            return genTOBuilder;
+        }
+        return null;
+
+    }
+
+    /**
+     * 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 coresponding
+     * generated type from {@link BindingGeneratorImpl#allGroupings
+     * allGroupings} which is adde 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 GeneratedTypeBuilder addImplementedInterfaceFromUses(final DataNodeContainer dataNodeContainer,
+            final GeneratedTypeBuilder builder) {
+        for (UsesNode usesNode : dataNodeContainer.getUses()) {
+            if (usesNode.getGroupingPath() != null) {
+                GeneratedType genType = allGroupings.get(usesNode.getGroupingPath());
+                if (genType == null) {
+                    throw new IllegalStateException("Grouping " + usesNode.getGroupingPath() + "is not resolved for "
+                            + builder.getName());
+                }
+                builder.addImplementsType(genType);
+            }
+        }
+        return builder;
+    }
+
+}
index 964731d78206eab8eec72a94f11d3e0f88534088..8c72960c091fff35bf8d2695533455b27b16d165 100644 (file)
@@ -9,30 +9,87 @@ package org.opendaylight.yangtools.sal.binding.yang.types;
 \r
 import java.math.BigDecimal;\r
 import java.math.BigInteger;\r
+import java.math.BigDecimal;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
 import org.opendaylight.yangtools.binding.generator.util.Types;\r
 import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;\r
 import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+\r
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
 \r
 public final class BaseYangTypes {\r
-\r
+    /**\r
+     * mapping of basic built-in YANG types (keys) to JAVA\r
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.Type Type}. This\r
+     * map is filled with mapping data in static initialization block\r
+     */\r
     private static Map<String, Type> typeMap = new HashMap<String, Type>();\r
 \r
+    /**\r
+     * <code>Type</code> representation of <code>boolean</code> YANG type\r
+     */\r
     public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>empty</code> YANG type\r
+     */\r
     public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>int8</code> YANG type\r
+     */\r
     public static final Type INT8_TYPE = Types.typeForClass(Byte.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>int16</code> YANG type\r
+     */\r
     public static final Type INT16_TYPE = Types.typeForClass(Short.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>int32</code> YANG type\r
+     */\r
     public static final Type INT32_TYPE = Types.typeForClass(Integer.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>int64</code> YANG type\r
+     */\r
     public static final Type INT64_TYPE = Types.typeForClass(Long.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>string</code> YANG type\r
+     */\r
     public static final Type STRING_TYPE = Types.typeForClass(String.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>decimal64</code> YANG type\r
+     */\r
     public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>uint8</code> YANG type\r
+     */\r
     public static final Type UINT8_TYPE = Types.typeForClass(Short.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>uint16</code> YANG type\r
+     */\r
     public static final Type UINT16_TYPE = Types.typeForClass(Integer.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>uint32</code> YANG type\r
+     */\r
     public static final Type UINT32_TYPE = Types.typeForClass(Long.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>uint64</code> YANG type\r
+     */\r
     public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class);\r
+\r
+    /**\r
+     * <code>Type</code> representation of <code>binary</code> YANG type\r
+     */\r
     public static final Type BINARY_TYPE = Types.primitiveType("byte[]");\r
 \r
     static {\r
@@ -52,12 +109,29 @@ public final class BaseYangTypes {
     }\r
 \r
     public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {\r
-\r
+        /**\r
+         * Searches <code>Type</code> value to which is YANG <code>type</code>\r
+         * mapped.\r
+         * \r
+         * @param type\r
+         *            string with YANG type name\r
+         * @return java <code>Type</code> representation of <code>type</code>\r
+         */\r
         @Override\r
         public Type javaTypeForYangType(String type) {\r
             return typeMap.get(type);\r
         }\r
 \r
+        /**\r
+         * Searches <code>Type</code> value to which is YANG <code>type</code>\r
+         * mapped.\r
+         * \r
+         * @param type\r
+         *            type definition representation of YANG type\r
+         * @return java <code>Type</code> representation of <code>type</code>.\r
+         *          If <code>type</code> isn't found then <code>null</code> is\r
+         *          returned.\r
+         */\r
         @Override\r
         public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type) {\r
             if (type != null) {\r
index bb928f13d55dbc7e9b7fb2204188afab0041c485..d40483bf0f73d89b669cdb813830d0a4fc443db4 100644 (file)
@@ -22,56 +22,98 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
-import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
-//import org.opendaylight.yangtools.yang.model.util.GroupingDefinition;
-
 public class GroupingDefinitionDependencySort {
-    private static final Logger logger = LoggerFactory.getLogger(GroupingDefinitionDependencySort.class);
 
+    /**
+     * Sorts set <code>groupingDefinitions</code> according to the mutual
+     * dependencies.<br />
+     * 
+     * Elements of <code>groupingDefinitions</code> are firstly transformed to
+     * {@link org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node
+     * Node} interfaces and then are sorted by
+     * {@link org.opendaylight.yangtools.yang.parser.util.TopologicalSort#sort(Set)
+     * sort()} method of <code>TopologicalSort</code>.<br />
+     * <br />
+     * 
+     * 
+     * <i>Definition of dependency relation:<br />
+     * The first <code>GroupingDefinition</code> object (in this context)
+     * depends on second <code>GroupingDefinition</code> object if the first one
+     * contains in its set of <code>UsesNode</code> (obtained through
+     * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer#getUses()
+     * getUses} method) reference to the second one.</i>
+     * 
+     * @param groupingDefinitions
+     *            set of grouping definition which should be sorted according to
+     *            mutual dependencies
+     * @return list of grouping definitiond which are sorted by mutual
+     *         dependencies
+     * @throws IllegalArgumentException
+     *             if <code>groupingDefinitions</code>
+     * 
+     */
     public static List<GroupingDefinition> sort(final Set<GroupingDefinition> groupingDefinitions) {
         if (groupingDefinitions == null) {
-            logger.error("Set of grouping definitions cannot be NULL!");
             throw new IllegalArgumentException("Set of Type Definitions " + "cannot be NULL!");
         }
 
         final List<GroupingDefinition> resultGroupingDefinitions = new ArrayList<GroupingDefinition>();
-        final Set<Node> unsorted = groupingDefinitionsToGroupingNodes(groupingDefinitions);
+        final Set<Node> unsorted = groupingDefinitionsToNodes(groupingDefinitions);
         final List<Node> sortedNodes = TopologicalSort.sort(unsorted);
         for (Node node : sortedNodes) {
-            resultGroupingDefinitions.add(((GroupingNode) node).getGroupingDefinition());
+            NodeWrappedType nodeWrappedType = (NodeWrappedType) node;
+            resultGroupingDefinitions.add((GroupingDefinition) (nodeWrappedType.getWrappedType()));
         }
         return resultGroupingDefinitions;
 
     }
 
-    private static Set<Node> groupingDefinitionsToGroupingNodes(final Set<GroupingDefinition> groupingDefinitions) {
+    /**
+     * Wraps every grouping definition to node type and adds to every node
+     * information about dependencies.
+     * 
+     * The map with mapping from schema path (represents grouping definition) to
+     * node is created. For every created node (next <i>nodeFrom</i>) is for its
+     * wrapped grouping definition passed the set of its <i>uses nodes</i>
+     * through. For every uses node is found its wrapping node (next as
+     * <i>nodeTo</i>). This dependency relationship between nodeFrom and all
+     * found nodesTo is modeled with creating of one edge from nodeFrom to
+     * nodeTo.
+     * 
+     * 
+     * @param groupingDefinitions
+     *            set of goruping definition which will be wrapped to nodes
+     * 
+     * @return set of nodes where every one contains wrapped grouping definition
+     */
+    private static Set<Node> groupingDefinitionsToNodes(final Set<GroupingDefinition> groupingDefinitions) {
         final Map<SchemaPath, Node> nodeMap = Maps.newHashMap();
         final Set<Node> resultNodes = Sets.newHashSet();
 
         for (final GroupingDefinition groupingDefinition : groupingDefinitions) {
-            final Node node = new GroupingNode(groupingDefinition);
+            final Node node = new NodeWrappedType(groupingDefinition);
             nodeMap.put(groupingDefinition.getPath(), node);
             resultNodes.add(node);
         }
 
         for (final Node node : resultNodes) {
-            final GroupingNode groupingNode = (GroupingNode) node;
-            final GroupingDefinition groupingDefinition = groupingNode.getGroupingDefinition();
+            final NodeWrappedType nodeWrappedType = (NodeWrappedType) node;
+            final GroupingDefinition groupingDefinition = (GroupingDefinition) nodeWrappedType.getWrappedType();
 
             Set<UsesNode> usesNodes = getAllUsesNodes(groupingDefinition);
+
             for (UsesNode usesNode : usesNodes) {
                 SchemaPath schemaPath = usesNode.getGroupingPath();
                 if (schemaPath != null) {
                     Node nodeTo = nodeMap.get(schemaPath);
                     if (nodeTo != null) {
-                        groupingNode.addEdge(nodeTo);
+                        nodeWrappedType.addEdge(nodeTo);
                     }
+                
 
                 }
             }
@@ -80,6 +122,16 @@ public class GroupingDefinitionDependencySort {
         return resultNodes;
     }
 
+    /**
+     * Returns the set of the uses nodes which are get from uses in
+     * <code>container</code>, from uses in groupings inside
+     * <code>container</code> and from uses inside child nodes of the
+     * <code>container</code>.
+     * 
+     * @param container
+     *            data node container which can contain some uses of grouping
+     * @return set of uses nodes which were find in <code>container</code>.
+     */
     private static Set<UsesNode> getAllUsesNodes(DataNodeContainer container) {
         Set<UsesNode> ret = new HashSet<>();
         ret.addAll(container.getUses());
@@ -88,12 +140,12 @@ public class GroupingDefinitionDependencySort {
         for (GroupingDefinition groupingDefinition : groupings) {
             ret.addAll(getAllUsesNodes(groupingDefinition));
         }
-        Set<DataSchemaNode> children = container.getChildNodes();
-        for (DataSchemaNode dataSchemaNode : children) {
-            if (dataSchemaNode instanceof DataNodeContainer) {
-                ret.addAll(getAllUsesNodes((DataNodeContainer) dataSchemaNode));
-            } else if (dataSchemaNode instanceof ChoiceNode) {
-                Set<ChoiceCaseNode> cases = ((ChoiceNode) dataSchemaNode).getCases();
+        Set<DataSchemaNode> childNodes = container.getChildNodes();
+        for (DataSchemaNode childNode : childNodes) {
+            if (childNode instanceof DataNodeContainer) {
+                ret.addAll(getAllUsesNodes((DataNodeContainer) childNode));
+            } else if (childNode instanceof ChoiceNode) {
+                Set<ChoiceCaseNode> cases = ((ChoiceNode) childNode).getCases();
                 for (ChoiceCaseNode choiceCaseNode : cases) {
                     ret.addAll(getAllUsesNodes(choiceCaseNode));
                 }
@@ -105,40 +157,4 @@ public class GroupingDefinitionDependencySort {
 
     }
 
-    private static final class GroupingNode extends NodeImpl {
-        private final GroupingDefinition groupingDefinition;
-
-        GroupingNode(GroupingDefinition groupingDefinition) {
-            this.groupingDefinition = groupingDefinition;
-        }
-
-        GroupingDefinition getGroupingDefinition() {
-            return groupingDefinition;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-            if (!(o instanceof GroupingNode)) {
-                return false;
-            }
-            GroupingNode groupingNode = (GroupingNode) o;
-            if (!groupingDefinition.equals(groupingNode.groupingDefinition)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            return groupingDefinition.hashCode();
-        }
-
-        @Override
-        public String toString() {
-            return "GroupingNode{" + "groupingType=" + groupingDefinition + '}';
-        }
-    }
 }
diff --git a/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/NodeWrappedType.java b/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/NodeWrappedType.java
new file mode 100644 (file)
index 0000000..bc6b150
--- /dev/null
@@ -0,0 +1,55 @@
+package org.opendaylight.yangtools.sal.binding.yang.types;
+
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
+
+public final class NodeWrappedType extends NodeImpl {
+    /**
+     * The payload which is saved inside Node
+     */
+    private final Object wrappedType;
+
+    /**
+     * Create new instance of class <code>NodeWrappedType</code>.
+     * 
+     * @param wrappedType
+     *            object with payload data
+     */
+    NodeWrappedType(Object wrappedType) {
+        this.wrappedType = wrappedType;
+    }
+
+    /**
+     * Gets payload from class
+     * 
+     * @return object with <code>wrappedType</code>
+     */
+    Object getWrappedType() {
+        return wrappedType;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof NodeWrappedType)) {
+            return false;
+        }
+        NodeWrappedType nodeWrappedType = (NodeWrappedType) o;
+        if (!wrappedType.equals(nodeWrappedType.wrappedType)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return wrappedType.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return "NodeWrappedType{" + "wrappedType=" + wrappedType + '}';
+    }
+
+}
index 381bff5d4b2f250c6ab46ce94901be32848edb53..4e6d2632e2f999531c8eeb12a59d0145d76f5a32 100644 (file)
@@ -55,11 +55,30 @@ import org.opendaylight.yangtools.yang.model.util.UnionType;
 import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
 
 public final class TypeProviderImpl implements TypeProvider {
-
+    /**
+     * Contains the schema data red from YANG files.
+     */
     private final SchemaContext schemaContext;
+
+    /**
+     * The outter map maps module names to the map of the types for the module.
+     * The inner map maps the name of the concrete type to the JAVA <code>Type</code> (usually it is generated TO).
+     */
     private Map<String, Map<String, Type>> genTypeDefsContextMap;
+
+    /**
+     * The map which maps schema paths to JAVA <code>Type</code>.
+     */
     private final Map<SchemaPath, Type> referencedTypes;
 
+    /**
+     * Creates new instance of class <code>TypeProviderImpl</code>.
+     * 
+     * @param schemaContext
+     *            contains the schema data red from YANG files
+     * @throws IllegalArgumentException
+     *             if <code>schemaContext</code> equal null.
+     */
     public TypeProviderImpl(final SchemaContext schemaContext) {
         if (schemaContext == null) {
             throw new IllegalArgumentException("Schema Context cannot be null!");
@@ -71,6 +90,20 @@ public final class TypeProviderImpl implements TypeProvider {
         resolveTypeDefsFromContext();
     }
 
+    /**
+     * Puts <code>refType</code> to map with key <code>refTypePath</code>
+     * 
+     * @param refTypePath
+     *            schema path used as the map key
+     * @param refType
+     *            type which represents the map value
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>refTypePath</code> equal null</li>
+     *             <li>if <code>refType</code> equal null</li>
+     *             </ul>
+     * 
+     */
     public void putReferencedType(final SchemaPath refTypePath, final Type refType) {
         if (refTypePath == null) {
             throw new IllegalArgumentException("Path reference of " + "Enumeration Type Definition cannot be NULL!");
@@ -82,11 +115,15 @@ public final class TypeProviderImpl implements TypeProvider {
         referencedTypes.put(refTypePath, refType);
     }
 
-    /*
-     * (non-Javadoc)
+    /**
+     * 
+     * Converts basic YANG type <code>type</code> to JAVA <code>Type</code>.
      * 
+     * @param type
+     *            string with YANG name of type
+     * @returns JAVA <code>Type</code> for YANG type <code>type</code>
      * @see org.opendaylight.controller.yang.model.type.provider.TypeProvider#
-     * javaTypeForYangType(java.lang.String)
+     *      javaTypeForYangType(java.lang.String)
      */
     @Override
     public Type javaTypeForYangType(String type) {
@@ -94,6 +131,19 @@ public final class TypeProviderImpl implements TypeProvider {
         return t;
     }
 
+    /**
+     * Converts schema definition type <code>typeDefinition</code> to JAVA
+     * <code>Type</code>
+     * 
+     * @param typeDefinition
+     *            type definition which is converted to JAVA type
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>typeDefinition</code> equal null</li>
+     *             <li>if Q name of <code>typeDefinition</code> equal null</li>
+     *             <li>if name of <code>typeDefinition</code> equal null</li>
+     *             </ul>
+     */
     @Override
     public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> typeDefinition) {
         Type returnType = null;
@@ -116,10 +166,10 @@ public final class TypeProviderImpl implements TypeProvider {
                 returnType = provideTypeForLeafref(leafref);
             } else if (baseTypeDef instanceof IdentityrefTypeDefinition) {
                 final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition) baseTypeDef;
-                returnType = returnTypeForIdentityref(idref);
+                returnType = provideTypeForIdentityref(idref);
             } else if (baseTypeDef instanceof EnumTypeDefinition) {
                 final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) baseTypeDef;
-                returnType = resolveEnumFromTypeDefinition(enumTypeDef, typedefName);
+                returnType = provideTypeForEnum(enumTypeDef, typedefName);
             } else {
                 final Module module = findParentModuleForTypeDefinition(schemaContext, typeDefinition);
                 if (module != null) {
@@ -139,7 +189,7 @@ public final class TypeProviderImpl implements TypeProvider {
                 returnType = provideTypeForLeafref(leafref);
             } else if (typeDefinition instanceof IdentityrefTypeDefinition) {
                 final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition) typeDefinition;
-                returnType = returnTypeForIdentityref(idref);
+                returnType = provideTypeForIdentityref(idref);
             } else {
                 returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER.javaTypeForSchemaDefinitionType(typeDefinition);
             }
@@ -153,7 +203,22 @@ public final class TypeProviderImpl implements TypeProvider {
         return returnType;
     }
 
-    private Type returnTypeForIdentityref(IdentityrefTypeDefinition idref) {
+    /**
+     * Seeks for identity reference <code>idref</code> the JAVA
+     * <code>type</code>.<br />
+     * <br />
+     * 
+     * <i>Example:<br />
+     * If identy which is referenced via <code>idref</code> has name <b>Idn</b>
+     * then returning type is <b>{@code Class<? extends Idn>}</b></i>
+     * 
+     * @param idref
+     *            identityref type definition for which JAVA <code>Type</code>
+     *            is sought
+     * @return JAVA <code>Type</code> of the identity which is refrenced through
+     *         <code>idref</code>
+     */
+    private Type provideTypeForIdentityref(IdentityrefTypeDefinition idref) {
         QName baseIdQName = idref.getIdentity();
         Module module = schemaContext.findModuleByNamespace(baseIdQName.getNamespace());
         IdentitySchemaNode identity = null;
@@ -176,6 +241,21 @@ public final class TypeProviderImpl implements TypeProvider {
         return returnType;
     }
 
+    /**
+     * Converts <code>typeDefinition</code> to concrete JAVA <code>Type</code>.
+     * 
+     * @param typeDefinition
+     *            type definition which should be converted to JAVA
+     *            <code>Type</code>
+     * @return JAVA <code>Type</code> which represents
+     *         <code>typeDefinition</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>typeDefinition</code> equal null</li>
+     *             <li>if Q name of <code>typeDefinition</code></li>
+     *             <li>if name of <code>typeDefinition</code></li>
+     *             </ul>
+     */
     public Type generatedTypeForExtendedDefinitionType(final TypeDefinition<?> typeDefinition) {
         Type returnType = null;
         if (typeDefinition == null) {
@@ -185,7 +265,7 @@ public final class TypeProviderImpl implements TypeProvider {
             throw new IllegalArgumentException(
                     "Type Definition cannot have non specified QName (QName cannot be NULL!)");
         }
-        if (typeDefinition.getQName() == null) {
+        if (typeDefinition.getQName().getLocalName() == null) {
             throw new IllegalArgumentException("Type Definitions Local Name cannot be NULL!");
         }
 
@@ -207,6 +287,16 @@ public final class TypeProviderImpl implements TypeProvider {
         return returnType;
     }
 
+    /**
+     * Gets base type definition for <code>extendTypeDef</code>. The method is
+     * recursivelly called until non <code>ExtendedType</code> type is found.
+     * 
+     * @param extendTypeDef
+     *            type definition for which is the base type definition sought
+     * @return type definition which is base type for <code>extendTypeDef</code>
+     * @throws IllegalArgumentException
+     *             if <code>extendTypeDef</code> equal null
+     */
     private TypeDefinition<?> baseTypeDefForExtendedType(final TypeDefinition<?> extendTypeDef) {
         if (extendTypeDef == null) {
             throw new IllegalArgumentException("Type Definiition reference cannot be NULL!");
@@ -220,6 +310,23 @@ public final class TypeProviderImpl implements TypeProvider {
 
     }
 
+    /**
+     * Converts <code>leafrefType</code> to JAVA <code>Type</code>.
+     * 
+     * The path of <code>leafrefType</code> is followed to find referenced node
+     * and its <code>Type</code> is returned.
+     * 
+     * @param leafrefType
+     *            leafref type definition for which is the type sought
+     * @return JAVA <code>Type</code> of data schema node which is referenced in
+     *         <code>leafrefType</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>leafrefType</code> equal null</li>
+     *             <li>if path statement of <code>leafrefType</code> equal null</li>
+     *             </ul>
+     * 
+     */
     public Type provideTypeForLeafref(final LeafrefTypeDefinition leafrefType) {
         Type returnType = null;
         if (leafrefType == null) {
@@ -259,6 +366,19 @@ public final class TypeProviderImpl implements TypeProvider {
         return returnType;
     }
 
+    /**
+     * Checks if <code>dataNode</code> is <code>LeafSchemaNode</code> and if it
+     * so then checks if it is of type <code>EnumTypeDefinition</code>.
+     * 
+     * @param dataNode
+     *            data schema node for which is checked if it is leaf and if it
+     *            is of enum type
+     * @return boolean value
+     *         <ul>
+     *         <li>true - if <code>dataNode</code> is leaf of type enumeration</li>
+     *         <li>false - other cases</li>
+     *         </ul>
+     */
     private boolean leafContainsEnumDefinition(final DataSchemaNode dataNode) {
         if (dataNode instanceof LeafSchemaNode) {
             final LeafSchemaNode leaf = (LeafSchemaNode) dataNode;
@@ -269,6 +389,20 @@ public final class TypeProviderImpl implements TypeProvider {
         return false;
     }
 
+    /**
+     * Checks if <code>dataNode</code> is <code>LeafListSchemaNode</code> and if
+     * it so then checks if it is of type <code>EnumTypeDefinition</code>.
+     * 
+     * @param dataNode
+     *            data schema node for which is checked if it is leaflist and if
+     *            it is of enum type
+     * @return boolean value
+     *         <ul>
+     *         <li>true - if <code>dataNode</code> is leaflist of type
+     *         enumeration</li>
+     *         <li>false - other cases</li>
+     *         </ul>
+     */
     private boolean leafListContainsEnumDefinition(final DataSchemaNode dataNode) {
         if (dataNode instanceof LeafListSchemaNode) {
             final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode;
@@ -279,7 +413,26 @@ public final class TypeProviderImpl implements TypeProvider {
         return false;
     }
 
-    private Enumeration resolveEnumFromTypeDefinition(final EnumTypeDefinition enumTypeDef, final String enumName) {
+    /**
+     * Converts <code>enumTypeDef</code> to
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.Enumeration
+     * enumeration}.
+     * 
+     * @param enumTypeDef
+     *            enumeration type definition which is converted to enumeration
+     * @param enumName
+     *            string with name which is used as the enumeration name
+     * @return enumeration type which is built with data (name, enum values)
+     *         from <code>enumTypeDef</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>enumTypeDef</code> equals null</li>
+     *             <li>if enum values of <code>enumTypeDef</code> equal null</li>
+     *             <li>if Q name of <code>enumTypeDef</code> equal null</li>
+     *             <li>if name of <code>enumTypeDef</code> equal null</li>
+     *             </ul>
+     */
+    private Enumeration provideTypeForEnum(final EnumTypeDefinition enumTypeDef, final String enumName) {
         if (enumTypeDef == null) {
             throw new IllegalArgumentException("EnumTypeDefinition reference cannot be NULL!");
         }
@@ -303,7 +456,30 @@ public final class TypeProviderImpl implements TypeProvider {
         return enumBuilder.toInstance(null);
     }
 
-    private EnumBuilder resolveInnerEnumFromTypeDefinition(final EnumTypeDefinition enumTypeDef, final String enumName,
+    /**
+     * Adds enumeration to <code>typeBuilder</code>. The enumeration data are
+     * taken from <code>enumTypeDef</code>.
+     * 
+     * @param enumTypeDef
+     *            enumeration type definition is source of enumeration data for
+     *            <code>typeBuilder</code>
+     * @param enumName
+     *            string with the name of enumeration
+     * @param typeBuilder
+     *            generated type builder to which is enumeration added
+     * @return enumeration type which contains enumeration data form
+     *         <code>enumTypeDef</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>enumTypeDef</code> equals null</li>
+     *             <li>if enum values of <code>enumTypeDef</code> equal null</li>
+     *             <li>if Q name of <code>enumTypeDef</code> equal null</li>
+     *             <li>if name of <code>enumTypeDef</code> equal null</li>
+     *             <li>if name of <code>typeBuilder</code> equal null</li>
+     *             </ul>
+     * 
+     */
+    private Enumeration addInnerEnumerationToTypeBuilder(final EnumTypeDefinition enumTypeDef, final String enumName,
             final GeneratedTypeBuilder typeBuilder) {
         if (enumTypeDef == null) {
             throw new IllegalArgumentException("EnumTypeDefinition reference cannot be NULL!");
@@ -322,13 +498,23 @@ public final class TypeProviderImpl implements TypeProvider {
         }
 
         final String enumerationName = parseToClassName(enumName);
-        final EnumBuilder enumBuilder = typeBuilder.addEnumeration(enumerationName);
 
+        final EnumBuilder enumBuilder = typeBuilder.addEnumeration(enumerationName);
         updateEnumPairsFromEnumTypeDef(enumTypeDef, enumBuilder);
-
-        return enumBuilder;
+        return enumBuilder.toInstance(enumBuilder);
     }
 
+    /**
+     * Updates <code>enumBuilder</code> with data from <code>enumTypeDef</code>.
+     * Specifically this data represents list of value-name pairs.
+     * 
+     * @param enumTypeDef
+     *            enum type definition as source of enum data for
+     *            <code>enumBuilder</code>
+     * @param enumBuilder
+     *            enum builder to which are saved enum data from
+     *            <code>enumTypeDef</code>
+     */
     private void updateEnumPairsFromEnumTypeDef(final EnumTypeDefinition enumTypeDef, final EnumBuilder enumBuilder) {
         if (enumBuilder != null) {
             final List<EnumPair> enums = enumTypeDef.getValues();
@@ -350,6 +536,13 @@ public final class TypeProviderImpl implements TypeProvider {
         }
     }
 
+    /**
+     * Converts <code>dataNode</code> to JAVA <code>Type</code>.
+     * 
+     * @param dataNode
+     *            contains information about YANG type
+     * @return JAVA <code>Type</code> representation of <code>dataNode</code>
+     */
     private Type resolveTypeFromDataSchemaNode(final DataSchemaNode dataNode) {
         Type returnType = null;
         if (dataNode != null) {
@@ -364,6 +557,20 @@ public final class TypeProviderImpl implements TypeProvider {
         return returnType;
     }
 
+    /**
+     * Passes through all modules and through all its type definitions and
+     * convert it to generated types.
+     * 
+     * The modules are firstly sorted by mutual dependencies. The modules are
+     * sequentially passed. All type definitions of a module are at the
+     * beginning sorted so that type definition with less amount of references
+     * to other type definition are processed first.<br />
+     * For each module is created mapping record in the map
+     * {@link TypeProviderImpl#genTypeDefsContextMap genTypeDefsContextMap}
+     * which map current module name to the map which maps type names to
+     * returned types (generated types).
+     * 
+     */
     private void resolveTypeDefsFromContext() {
         final Set<Module> modules = schemaContext.getModules();
         if (modules == null) {
@@ -397,6 +604,21 @@ public final class TypeProviderImpl implements TypeProvider {
         }
     }
 
+    /**
+     * 
+     * @param basePackageName
+     *            string with name of package to which the module belongs
+     * @param moduleName
+     *            string with the name of the module for to which the
+     *            <code>typedef</code> belongs
+     * @param typedef
+     *            type definition of the node for which should be creted JAVA
+     *            <code>Type</code> (usually generated TO)
+     * @return JAVA <code>Type</code> representation of <code>typedef</code> or
+     *         <code>null</code> value if <code>basePackageName</code> or
+     *         <code>modulName</code> or <code>typedef</code> or Q name of
+     *         <code>typedef</code> equals <code>null</code>
+     */
     private Type typedefToGeneratedType(final String basePackageName, final String moduleName,
             final TypeDefinition<?> typedef) {
         if ((basePackageName != null) && (moduleName != null) && (typedef != null) && (typedef.getQName() != null)) {
@@ -407,21 +629,20 @@ public final class TypeProviderImpl implements TypeProvider {
                     && !(innerTypeDefinition instanceof IdentityrefTypeDefinition)) {
                 Type returnType = null;
                 if (innerTypeDefinition instanceof ExtendedType) {
-                    ExtendedType extendedTypeDef = (ExtendedType) innerTypeDefinition;
-                    returnType = resolveExtendedTypeFromTypeDef(extendedTypeDef, basePackageName, typedefName,
-                            moduleName);
+                    ExtendedType innerExtendedType = (ExtendedType) innerTypeDefinition;
+                    returnType = provideGeneratedTOFromExtendedType(innerExtendedType, basePackageName, typedefName);
                 } else if (innerTypeDefinition instanceof UnionTypeDefinition) {
-                    final GeneratedTOBuilder genTOBuilder = addUnionGeneratedTypeDefinition(basePackageName, typedef,
-                            typedefName);
+                    final GeneratedTOBuilder genTOBuilder = provideGeneratedTOBuilderForUnionTypeDefinition(
+                            basePackageName, typedef, typedefName);
                     returnType = genTOBuilder.toInstance();
                 } else if (innerTypeDefinition instanceof EnumTypeDefinition) {
                     final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) innerTypeDefinition;
-                    returnType = resolveEnumFromTypeDefinition(enumTypeDef, typedefName);
+                    returnType = provideTypeForEnum(enumTypeDef, typedefName);
 
                 } else if (innerTypeDefinition instanceof BitsTypeDefinition) {
                     final BitsTypeDefinition bitsTypeDefinition = (BitsTypeDefinition) innerTypeDefinition;
-                    final GeneratedTOBuilder genTOBuilder = bitsTypedefToTransferObject(basePackageName,
-                            bitsTypeDefinition, typedefName);
+                    final GeneratedTOBuilder genTOBuilder = provideGeneratedTOBuilderForBitsTypeDefinition(
+                            basePackageName, bitsTypeDefinition, typedefName);
                     returnType = genTOBuilder.toInstance();
 
                 } else {
@@ -442,6 +663,17 @@ public final class TypeProviderImpl implements TypeProvider {
         return null;
     }
 
+    /**
+     * Wraps base YANG type to generated TO.
+     * 
+     * @param basePackageName
+     *            string with name of package to which the module belongs
+     * @param typedef
+     *            type definition which is converted to the TO
+     * @param javaType
+     *            JAVA <code>Type</code> to which is <code>typedef</code> mapped
+     * @return generated transfer object which represent<code>javaType</code>
+     */
     private GeneratedTransferObject wrapJavaTypeIntoTO(final String basePackageName, final TypeDefinition<?> typedef,
             final Type javaType) {
         if (javaType != null) {
@@ -467,7 +699,27 @@ public final class TypeProviderImpl implements TypeProvider {
         return null;
     }
 
-    public GeneratedTOBuilder addUnionGeneratedTypeDefinition(final String basePackageName,
+    /**
+     * Converts <code>typedef</code> to generated TO with
+     * <code>typeDefName</code>. Every union type from <code>typedef</code> is
+     * added to generated TO builder as property.
+     * 
+     * @param basePackageName
+     *            string with name of package to which the module belongs
+     * @param typedef
+     *            type definition which should be of type
+     *            <code>UnionTypeDefinition</code>
+     * @param typeDefName
+     *            string with name for generated TO
+     * @return generated TO builder which represents <code>typedef</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>typedef</code> equals null</li>
+     *             <li>if Q name of <code>typedef</code> equals null</li>
+     *             </ul>
+     */
+    public GeneratedTOBuilder provideGeneratedTOBuilderForUnionTypeDefinition(final String basePackageName,
             final TypeDefinition<?> typedef, String typeDefName) {
         if (basePackageName == null) {
             throw new IllegalArgumentException("Base Package Name cannot be NULL!");
@@ -482,15 +734,9 @@ public final class TypeProviderImpl implements TypeProvider {
 
         final TypeDefinition<?> baseTypeDefinition = typedef.getBaseType();
         if ((baseTypeDefinition != null) && (baseTypeDefinition instanceof UnionTypeDefinition)) {
-            final Module parentModule = findParentModuleForTypeDefinition(schemaContext, typedef);
             final UnionTypeDefinition unionTypeDef = (UnionTypeDefinition) baseTypeDefinition;
             final List<TypeDefinition<?>> unionTypes = unionTypeDef.getTypes();
 
-            Map<String, Type> genTOsMap = null;
-            if (parentModule != null && parentModule.getName() != null) {
-                genTOsMap = genTypeDefsContextMap.get(parentModule.getName());
-            }
-
             final GeneratedTOBuilder unionGenTransObject;
             if (typeDefName != null && !typeDefName.isEmpty()) {
                 final String typeName = parseToClassName(typeDefName);
@@ -529,10 +775,9 @@ public final class TypeProviderImpl implements TypeProvider {
                         }
                     }
                 } else if (unionType instanceof EnumTypeDefinition) {
-                    final EnumBuilder enumBuilder = resolveInnerEnumFromTypeDefinition((EnumTypeDefinition) unionType,
+                    final Enumeration enumeration = addInnerEnumerationToTypeBuilder((EnumTypeDefinition) unionType,
                             typeName, unionGenTransObject);
-                    final Type enumRefType = new ReferencedTypeImpl(enumBuilder.getPackageName(), enumBuilder.getName());
-                    updateUnionTypeAsProperty(unionGenTransObject, enumRefType, typeName);
+                    updateUnionTypeAsProperty(unionGenTransObject, enumeration, typeName);
                 } else {
                     final Type javaType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
                             .javaTypeForSchemaDefinitionType(unionType);
@@ -545,12 +790,31 @@ public final class TypeProviderImpl implements TypeProvider {
                 addStringRegExAsConstant(unionGenTransObject, regularExpressions);
             }
 
-            genTOsMap.put(typedef.getQName().getLocalName(), unionGenTransObject.toInstance());
+            Map<String, Type> genTOsMap = null;
+            final Module parentModule = findParentModuleForTypeDefinition(schemaContext, typedef);
+            if (parentModule != null && parentModule.getName() != null) {
+                genTOsMap = genTypeDefsContextMap.get(parentModule.getName());
+                genTOsMap.put(typedef.getQName().getLocalName(), unionGenTransObject.toInstance());
+            }
+
             return unionGenTransObject;
         }
         return null;
     }
 
+    /**
+     * Adds a new property with the name <code>propertyName</code> and with type
+     * <code>type</code> to <code>unonGenTransObject</code>.
+     * 
+     * @param unionGenTransObject
+     *            generated TO to which should be property added
+     * @param type
+     *            JAVA <code>type</code> of the property which should be added
+     *            to <code>unionGentransObject</code>
+     * @param propertyName
+     *            string with name of property which should be added to
+     *            <code>unionGentransObject</code>
+     */
     private void updateUnionTypeAsProperty(final GeneratedTOBuilder unionGenTransObject, final Type type,
             final String propertyName) {
         if (unionGenTransObject != null && type != null) {
@@ -559,15 +823,23 @@ public final class TypeProviderImpl implements TypeProvider {
                         .addProperty(parseToValidParamName(propertyName));
                 propBuilder.setReturnType(type);
 
-                if (!(type instanceof Enumeration)) {
-                    unionGenTransObject.addEqualsIdentity(propBuilder);
-                    unionGenTransObject.addHashIdentity(propBuilder);
-                    unionGenTransObject.addToStringProperty(propBuilder);
-                }
+                unionGenTransObject.addEqualsIdentity(propBuilder);
+                unionGenTransObject.addHashIdentity(propBuilder);
+                unionGenTransObject.addToStringProperty(propBuilder);
             }
         }
     }
 
+    /**
+     * Converts <code>typedef</code> to the generated TO builder.
+     * 
+     * @param basePackageName
+     *            string with name of package to which the module belongs
+     * @param typedef
+     *            type definition from which is the generated TO builder created
+     * @return generated TO builder which contains data from
+     *         <code>typedef</code> and <code>basePackageName</code>
+     */
     private GeneratedTOBuilder typedefToTransferObject(final String basePackageName, final TypeDefinition<?> typedef) {
 
         final String packageName = packageNameForGeneratedType(basePackageName, typedef.getPath());
@@ -582,7 +854,27 @@ public final class TypeProviderImpl implements TypeProvider {
         return null;
     }
 
-    public GeneratedTOBuilder bitsTypedefToTransferObject(final String basePackageName,
+    /**
+     * Converts <code>typeDef</code> which should be of the type
+     * <code>BitsTypeDefinition</code> to <code>GeneratedTOBuilder</code>.
+     * 
+     * All the bits of the typeDef are added to returning generated TO as
+     * properties.
+     * 
+     * @param basePackageName
+     *            string with name of package to which the module belongs
+     * @param typeDef
+     *            type definition from which is the generated TO builder created
+     * @param typeDefName
+     *            string with the name for generated TO builder
+     * @return generated TO builder which represents <code>typeDef</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>typeDef</code> equals null</li>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             </ul>
+     */
+    public GeneratedTOBuilder provideGeneratedTOBuilderForBitsTypeDefinition(final String basePackageName,
             final TypeDefinition<?> typeDef, String typeDefName) {
 
         if (typeDef == null) {
@@ -616,6 +908,17 @@ public final class TypeProviderImpl implements TypeProvider {
         return null;
     }
 
+    /**
+     * Converts the pattern constraints from <code>typedef</code> to the list of
+     * the strings which represents these constraints.
+     * 
+     * @param typedef
+     *            extended type in which are the pattern constraints sought
+     * @return list of strings which represents the constraint patterns
+     * @throws IllegalArgumentException
+     *             if <code>typedef</code> equals null
+     * 
+     */
     private List<String> resolveRegExpressionsFromTypedef(ExtendedType typedef) {
         final List<String> regExps = new ArrayList<String>();
         if (typedef == null) {
@@ -637,6 +940,22 @@ public final class TypeProviderImpl implements TypeProvider {
         return regExps;
     }
 
+    /**
+     * 
+     * Adds to the <code>genTOBuilder</code> the constant which contains regular
+     * expressions from the <code>regularExpressions</code>
+     * 
+     * @param genTOBuilder
+     *            generated TO builder to which are
+     *            <code>regular expressions</code> added
+     * @param regularExpressions
+     *            list of string which represent regular expressions
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>genTOBuilder</code> equals null</li>
+     *             <li>if <code>regularExpressions</code> equals null</li>
+     *             </ul>
+     */
     private void addStringRegExAsConstant(GeneratedTOBuilder genTOBuilder, List<String> regularExpressions) {
         if (genTOBuilder == null)
             throw new IllegalArgumentException("genTOBuilder can't be null");
@@ -649,10 +968,35 @@ public final class TypeProviderImpl implements TypeProvider {
         }
     }
 
-    private GeneratedTransferObject resolveExtendedTypeFromTypeDef(final ExtendedType extendedType,
-            final String basePackageName, final String typedefName, final String moduleName) {
+    /**
+     * Creates generated TO with data about inner extended type
+     * <code>innerExtendedType</code>, about the package name
+     * <code>typedefName</code> and about the generated TO name
+     * <code>typedefName</code>.
+     * 
+     * It is supposed that <code>innerExtendedType</code> is already present in
+     * {@link TypeProviderImpl#genTypeDefsContextMap genTypeDefsContextMap} to
+     * be possible set it as extended type for the returning generated TO.
+     * 
+     * @param innerExtendedType
+     *            extended type which is part of some other extended type
+     * @param basePackageName
+     *            string with the package name of the module
+     * @param typedefName
+     *            string with the name for the generated TO
+     * @return generated TO which extends generated TO for
+     *         <code>innerExtendedType</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>extendedType</code> equals null</li>
+     *             <li>if <code>basePackageName</code> equals null</li>
+     *             <li>if <code>typedefName</code> equals null</li>
+     *             </ul>
+     */
+    private GeneratedTransferObject provideGeneratedTOFromExtendedType(final ExtendedType innerExtendedType,
+            final String basePackageName, final String typedefName) {
 
-        if (extendedType == null) {
+        if (innerExtendedType == null) {
             throw new IllegalArgumentException("Extended type cannot be NULL!");
         }
         if (basePackageName == null) {
@@ -662,19 +1006,18 @@ public final class TypeProviderImpl implements TypeProvider {
             throw new IllegalArgumentException("String with type definition name cannot be NULL!");
         }
 
-        final String typeDefName = parseToClassName(typedefName);
-        final String lowTypeDef = extendedType.getQName().getLocalName();
-        final GeneratedTOBuilder genTOBuilder = new GeneratedTOBuilderImpl(basePackageName, typeDefName);
-
-        final Module parentModule = findParentModuleForTypeDefinition(schemaContext, extendedType);
+        final String classTypedefName = parseToClassName(typedefName);
+        final String innerTypeDef = innerExtendedType.getQName().getLocalName();
+        final GeneratedTOBuilder genTOBuilder = new GeneratedTOBuilderImpl(basePackageName, classTypedefName);
 
         Map<String, Type> typeMap = null;
+        final Module parentModule = findParentModuleForTypeDefinition(schemaContext, innerExtendedType);
         if (parentModule != null) {
             typeMap = genTypeDefsContextMap.get(parentModule.getName());
         }
 
         if (typeMap != null) {
-            Type type = typeMap.get(lowTypeDef);
+            Type type = typeMap.get(innerTypeDef);
             if (type instanceof GeneratedTransferObject) {
                 genTOBuilder.setExtendsType((GeneratedTransferObject) type);
             }
@@ -684,15 +1027,15 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     /**
-     * The method find out for each type definition how many immersion (depth)
-     * is necessary to get to the base type. Every type definition is inserted
-     * to the map which key is depth and value is list of type definitions with
+     * Finds out for each type definition how many immersion (depth) is
+     * necessary to get to the base type. Every type definition is inserted to
+     * the map which key is depth and value is list of type definitions with
      * equal depth. In next step are lists from this map concatenated to one
      * list in ascending order according to their depth. All type definitions
      * are in the list behind all type definitions on which depends.
      * 
      * @param unsortedTypeDefinitions
-     *            represents list of type definitions
+     *            list of type definitions which should be sorted by depth
      * @return list of type definitions sorted according their each other
      *         dependencies (type definitions which are depend on other type
      *         definitions are in list behind them).
@@ -722,13 +1065,13 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     /**
-     * The method return how many immersion is necessary to get from type
-     * definition to base type.
+     * Returns how many immersion is necessary to get from the type definition
+     * to the base type.
      * 
      * @param typeDefinition
-     *            is type definition for which is depth looked for.
-     * @return how many immersion is necessary to get from type definition to
-     *         base type
+     *            type definition for which is depth sought.
+     * @return number of immersions which are necessary to get from the type
+     *         definition to the base type
      */
     private int getTypeDefinitionDepth(final TypeDefinition<?> typeDefinition) {
         if (typeDefinition == null) {
index 2558873f773441ffbb430430759e53cdfd4aac66..c23a46563a32817d5fe3569adf1b2fb95df20ec7 100644 (file)
@@ -16,50 +16,62 @@ import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
-import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
 public class UnionDependencySort {
-    private static final Logger logger = LoggerFactory
-            .getLogger(UnionDependencySort.class);
-
-    public static List<ExtendedType> sort(
-            final Set<TypeDefinition<?>> typeDefinitions) {
+    private static final Logger logger = LoggerFactory.getLogger(UnionDependencySort.class);
+
+    /**
+     * Sorts union types by mutual dependencies.
+     * 
+     * At the beginning the union types are selected from
+     * <code>typeDefinitions</code> and wrapped to nodes. The nodes are sorted
+     * and then the wrapped payload is extracted.
+     * 
+     * @param typeDefinitions
+     *            set of type definitions.
+     * @return list of extended type which are sorted by mutual dependencies
+     * @throws IllegalArgumentException
+     *             if <code>typeDefinitions</code> equals <code>null</code>
+     */
+    public static List<ExtendedType> sort(final Set<TypeDefinition<?>> typeDefinitions) {
         if (typeDefinitions == null) {
             logger.error("Set of Type Definitions cannot be NULL!");
-            throw new IllegalArgumentException("Set of Type Definitions " +
-                    "cannot be NULL!");
+            throw new IllegalArgumentException("Set of Type Definitions " + "cannot be NULL!");
         }
 
-        final Set<ExtendedType> extUnionTypes =
-                unionsFromTypeDefinitions(typeDefinitions);
+        final Set<ExtendedType> extUnionTypes = unionsFromTypeDefinitions(typeDefinitions);
 
-        final Set<Node> unsorted = unionTypesToUnionNodes(extUnionTypes);
+        final Set<Node> unsorted = unionTypesToNodes(extUnionTypes);
 
         final List<Node> sortedNodes = TopologicalSort.sort(unsorted);
         return Lists.transform(sortedNodes, new Function<Node, ExtendedType>() {
             @Override
             public ExtendedType apply(Node input) {
-                return ((UnionNode) input).getUnionType();
+                return (ExtendedType) (((NodeWrappedType) input).getWrappedType());
             }
         });
     }
 
-    private static Set<ExtendedType> unionsFromTypeDefinitions(
-            final Set<TypeDefinition<?>> typeDefinitions) {
+    /**
+     * Extracts only union types from <code>typeDefinitions</code> set.
+     * 
+     * @param typeDefinitions
+     *            set of all type definitions
+     * @return set of extended type which are union type definition
+     */
+    private static Set<ExtendedType> unionsFromTypeDefinitions(final Set<TypeDefinition<?>> typeDefinitions) {
         final Set<ExtendedType> unions = Sets.newHashSet();
 
         for (final TypeDefinition<?> typedef : typeDefinitions) {
             if ((typedef != null) && (typedef.getBaseType() != null)) {
-                if (typedef instanceof ExtendedType
-                        && typedef.getBaseType() instanceof UnionTypeDefinition) {
+                if (typedef instanceof ExtendedType && typedef.getBaseType() instanceof UnionTypeDefinition) {
                     unions.add((ExtendedType) typedef);
                 }
             }
@@ -67,29 +79,45 @@ public class UnionDependencySort {
         return unions;
     }
 
-    private static Set<Node> unionTypesToUnionNodes(
-            final Set<ExtendedType> extUnionTypes) {
+    /**
+     * Wraps every extended type which represents union to node type and adds to
+     * every node information about dependencies.
+     * 
+     * The mapping from union type to node is created. For every created node
+     * (next <i>nodeFrom</i>) is for its wrapped union type passed the list of
+     * inner types through and only those inner types which represent union type
+     * are next considered. For every inner union type is found its wrapping
+     * node (next as <i>nodeTo</i>). This dependency relationship between
+     * nodeFrom and all found nodesTo is modeled with creating of one edge from
+     * nodeFrom to nodeTo.
+     * 
+     * 
+     * @param extUnionTypes
+     *            set of extended types which represents union types
+     * @return set of nodes which contains wrapped union types set of node where
+     *         each one contains wrapped one union type
+     */
+    private static Set<Node> unionTypesToNodes(final Set<ExtendedType> extUnionTypes) {
         final Map<ExtendedType, Node> nodeMap = Maps.newHashMap();
         final Set<Node> resultNodes = Sets.newHashSet();
 
         for (final ExtendedType unionType : extUnionTypes) {
-            final Node node = new UnionNode(unionType);
+            final Node node = new NodeWrappedType(unionType);
             nodeMap.put(unionType, node);
             resultNodes.add(node);
         }
 
         for (final Node node : resultNodes) {
-            final UnionNode unionNode = (UnionNode) node;
-            final ExtendedType extUnionType = unionNode.getUnionType();
+            final NodeWrappedType nodeFrom = (NodeWrappedType) node;
+            final ExtendedType extUnionType = (ExtendedType) nodeFrom.getWrappedType();
 
-            final UnionTypeDefinition unionType = (UnionTypeDefinition)
-                    extUnionType.getBaseType();
+            final UnionTypeDefinition unionType = (UnionTypeDefinition) extUnionType.getBaseType();
 
             final List<TypeDefinition<?>> innerTypes = unionType.getTypes();
             for (final TypeDefinition<?> typedef : innerTypes) {
                 if (extUnionTypes.contains(typedef)) {
                     final Node toNode = nodeMap.get(typedef);
-                    unionNode.addEdge(toNode);
+                    nodeFrom.addEdge(toNode);
                 }
             }
         }
@@ -97,66 +125,4 @@ public class UnionDependencySort {
         return resultNodes;
     }
 
-    private static UnionNode unionTypeToUnionNode(
-            final ExtendedType extUnionType,
-            final Set<ExtendedType> extUnionTypes) {
-        final UnionNode node = new UnionNode(extUnionType);
-
-        if (extUnionType.getBaseType() instanceof UnionTypeDefinition) {
-            final UnionTypeDefinition unionType = (UnionTypeDefinition)
-                    extUnionType.getBaseType();
-
-            final List<TypeDefinition<?>> innerTypes = unionType.getTypes();
-            for (final TypeDefinition<?> typedef : innerTypes) {
-                if ((typedef != null) && (typedef instanceof ExtendedType)
-                        && (typedef.getBaseType() instanceof UnionTypeDefinition)) {
-                    if (extUnionTypes.contains(typedef)) {
-                        node.addEdge(new UnionNode((ExtendedType) typedef));
-                    }
-                }
-            }
-        }
-
-        return node;
-    }
-
-    @VisibleForTesting
-    static final class UnionNode extends NodeImpl {
-        private final ExtendedType unionType;
-
-        UnionNode(ExtendedType unionType) {
-            this.unionType = unionType;
-        }
-
-        ExtendedType getUnionType() {
-            return unionType;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-            if (!(o instanceof UnionNode)) {
-                return false;
-            }
-            UnionNode unionNode = (UnionNode) o;
-            if (!unionType.equals(unionNode.unionType)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            return unionType.hashCode();
-        }
-
-        @Override
-        public String toString() {
-            return "UnionNode{" +
-                    "unionType=" + unionType +
-                    '}';
-        }
-    }
 }
index cf3ff19dc64ea6edb2552767302fef8b6466de2c..5707c78053b3635b8252554cc8e32f59a2b701cb 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.binding.generator.util;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-\r
-public class AbstractBaseType implements Type {\r
-\r
-    private final String packageName;\r
-    private final String name;\r
-\r
-    @Override\r
-    public String getPackageName() {\r
-        return packageName;\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public String getFullyQualifiedName() {\r
-        if (packageName.isEmpty()) {\r
-            return name;\r
-        } else {\r
-            return packageName + "." + name;\r
-        }\r
-    }\r
-\r
-    protected AbstractBaseType(String pkName, String name) {\r
-        this.packageName = pkName;\r
-        this.name = name;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-        result = prime * result\r
-                + ((packageName == null) ? 0 : packageName.hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj)\r
-            return true;\r
-        if (obj == null)\r
-            return false;\r
-        if (getClass() != obj.getClass())\r
-            return false;\r
-        Type other = (Type) obj;\r
-        if (name == null) {\r
-            if (other.getName() != null)\r
-                return false;\r
-        } else if (!name.equals(other.getName()))\r
-            return false;\r
-        if (packageName == null) {\r
-            if (other.getPackageName() != null)\r
-                return false;\r
-        } else if (!packageName.equals(other.getPackageName()))\r
-            return false;\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        if (packageName.isEmpty()) {\r
-            return "Type (" + name + ")";\r
-        }\r
-        return "Type (" + packageName + "." + name + ")";\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.binding.generator.util;
+
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+/**
+ * It is used only as ancestor for other <code>Type</code>s
+ * 
+ */
+public class AbstractBaseType implements Type {
+
+    /**
+     * Name of the package to which this <code>Type</code> belongs.
+     */
+    private final String packageName;
+
+    /**
+     * Name of this <code>Type</code>.
+     */
+    private final String name;
+
+    @Override
+    public String getPackageName() {
+        return packageName;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getFullyQualifiedName() {
+        if (packageName.isEmpty()) {
+            return name;
+        } else {
+            return packageName + "." + name;
+        }
+    }
+
+    /**
+     * Constructs the instance of this class with the concrete package name type
+     * name.
+     * 
+     * @param pkName
+     *            string with the package name to which this <code>Type</code>
+     *            belongs
+     * @param name
+     *            string with the name for this <code>Type</code>
+     */
+    protected AbstractBaseType(String pkName, String name) {
+        this.packageName = pkName;
+        this.name = name;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Type other = (Type) obj;
+        if (name == null) {
+            if (other.getName() != null)
+                return false;
+        } else if (!name.equals(other.getName()))
+            return false;
+        if (packageName == null) {
+            if (other.getPackageName() != null)
+                return false;
+        } else if (!packageName.equals(other.getPackageName()))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        if (packageName.isEmpty()) {
+            return "Type (" + name + ")";
+        }
+        return "Type (" + packageName + "." + name + ")";
+    }
+}
index 2c75e5d377db87593c0a55b96b080b81af3ab258..3a0d74c8c4d3887f8a7ce62736d791d2cbe9bec8 100644 (file)
@@ -10,12 +10,20 @@ import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;\r
 import org.opendaylight.yangtools.yang.common.QName;\r
 import org.opendaylight.yangtools.yang.model.api.Module;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;\r
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
 \r
+/**\r
+ * Contains the methods for converting strings to valid JAVA language strings\r
+ * (package names, class names, attribute names).\r
+ * \r
+ * \r
+ */\r
 public final class BindingGeneratorUtil {\r
 \r
+    /**\r
+     * Array of strings values which represents JAVA reserved words.\r
+     */\r
     private static final String[] SET_VALUES = new String[] { "abstract", "assert", "boolean", "break", "byte", "case",\r
             "catch", "char", "class", "const", "continue", "default", "double", "do", "else", "enum", "extends",\r
             "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int",\r
@@ -23,12 +31,29 @@ public final class BindingGeneratorUtil {
             "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient",\r
             "true", "try", "void", "volatile", "while" };\r
 \r
+    /**\r
+     * Impossible to instantiate this class. All of the methods or attributes\r
+     * are static.\r
+     */\r
     private BindingGeneratorUtil() {\r
     }\r
 \r
-    public static final Set<String> JAVA_RESERVED_WORDS = new HashSet<String>(Arrays.asList(SET_VALUES));\r
-\r
-    public static String validateJavaPackage(final String packageName) {\r
+    /**\r
+     * Hash set of words which are reserved in JAVA language.\r
+     */\r
+    private static final Set<String> JAVA_RESERVED_WORDS = new HashSet<String>(Arrays.asList(SET_VALUES));\r
+\r
+    /**\r
+     * Converts string <code>packageName</code> to valid JAVA package name.\r
+     * \r
+     * If some words of package name are digits of JAVA reserved words they are\r
+     * prefixed with underscore character.\r
+     * \r
+     * @param packageName\r
+     *            string which contains words separated by point.\r
+     * @return package name which contains words separated by point.\r
+     */\r
+    private static String validateJavaPackage(final String packageName) {\r
         if (packageName != null) {\r
             final String[] packNameParts = packageName.split("\\.");\r
             if (packNameParts != null) {\r
@@ -51,6 +76,16 @@ public final class BindingGeneratorUtil {
         return packageName;\r
     }\r
 \r
+    /**\r
+     * Converts <code>parameterName</code> to valid JAVA parameter name.\r
+     * \r
+     * If the <code>parameterName</code> is one of the JAVA reserved words then\r
+     * it is prefixed with underscore character.\r
+     * \r
+     * @param parameterName\r
+     *            string with the parameter name\r
+     * @return string with the admissible parameter name\r
+     */\r
     public static String validateParameterName(final String parameterName) {\r
         if (parameterName != null) {\r
             if (JAVA_RESERVED_WORDS.contains(parameterName)) {\r
@@ -60,9 +95,22 @@ public final class BindingGeneratorUtil {
         return parameterName;\r
     }\r
 \r
+    /**\r
+     * Creates generated TO builder from <code>packageName</code> and\r
+     * <code>transObjectName</code>.\r
+     * \r
+     * @param packageName\r
+     *            string with name of package to which the returned object\r
+     *            belongs\r
+     * @param transObjectName\r
+     *            string with name which the returned object has\r
+     * @return generated TO builder or <code>null</code> value if\r
+     *         <code>packageName</code> or <code>transObjectName</code> equal\r
+     *         <code>null</code>\r
+     */\r
     public static GeneratedTOBuilder schemaNodeToTransferObjectBuilder(final String packageName,\r
-            final SchemaNode schemaNode, final String transObjectName) {\r
-        if (packageName != null && schemaNode != null && transObjectName != null) {\r
+            final String transObjectName) {\r
+        if (packageName != null && transObjectName != null) {\r
 \r
             final String genTOName = BindingGeneratorUtil.parseToClassName(transObjectName);\r
             final GeneratedTOBuilder newType = new GeneratedTOBuilderImpl(packageName, genTOName);\r
@@ -73,6 +121,25 @@ public final class BindingGeneratorUtil {
         return null;\r
     }\r
 \r
+    /**\r
+     * Converts module name to valid JAVA package name.\r
+     * \r
+     * The package name consists of:\r
+     * <ul>\r
+     * <li>prefix - <i>org.opendaylight.yang.gen.v</i></li>\r
+     * <li>module YANG version - <i>org.opendaylight.yang.gen.v</i></li>\r
+     * <li>module namespace - invalid characters are replaced with dots</li>\r
+     * <li>revision prefix - <i>.rev</i></li>\r
+     * <li>revision - YYYYMMDD (MM and DD aren't spread to the whole length)</li>\r
+     * </ul>\r
+     * \r
+     * @param module\r
+     *            module which contains data about namespace and revision date\r
+     * @return string with the valid JAVA package name\r
+     * @throws IllegalArgumentException\r
+     *             if the revision date of the <code>module</code> equals\r
+     *             <code>null</code>\r
+     */\r
     public static String moduleNamespaceToPackageName(final Module module) {\r
         final StringBuilder packageNameBuilder = new StringBuilder();\r
 \r
@@ -109,6 +176,21 @@ public final class BindingGeneratorUtil {
         return validateJavaPackage(packageNameBuilder.toString());\r
     }\r
 \r
+    /**\r
+     * Creates package name from specified <code>basePackageName</code> (package\r
+     * name for module) and <code>schemaPath</code>.\r
+     * \r
+     * Resulting package name is concatenation of <code>basePackageName</code>\r
+     * and all local names of YANG nodes which are parents of some node for\r
+     * which <code>schemaPath</code> is specified.\r
+     * \r
+     * @param basePackageName\r
+     *            string with package name of the module\r
+     * @param schemaPath\r
+     *            list of names of YANG nodes which are parents of some node +\r
+     *            name of this node\r
+     * @return string with valid JAVA package name\r
+     */\r
     public static String packageNameForGeneratedType(final String basePackageName, final SchemaPath schemaPath) {\r
         if (basePackageName == null) {\r
             throw new IllegalArgumentException("Base Package Name cannot be NULL!");\r
@@ -132,6 +214,21 @@ public final class BindingGeneratorUtil {
         return validateJavaPackage(builder.toString());\r
     }\r
 \r
+    /**\r
+     * Generates the package name for type definition from\r
+     * <code>typeDefinition</code> and <code>basePackageName</code>.\r
+     * \r
+     * @param basePackageName\r
+     *            string with the package name of the module\r
+     * @param typeDefinition\r
+     *            type definition for which the package name will be generated *\r
+     * @return string with valid JAVA package name\r
+     * @throws IllegalArgumentException\r
+     *             <ul>\r
+     *             <li>if <code>basePackageName</code> equals <code>null</code></li>\r
+     *             <li>if <code>typeDefinition</code> equals <code>null</code></li>\r
+     *             </ul>\r
+     */\r
     public static String packageNameForTypeDefinition(final String basePackageName,\r
             final TypeDefinition<?> typeDefinition) {\r
         if (basePackageName == null) {\r
@@ -146,6 +243,16 @@ public final class BindingGeneratorUtil {
         return validateJavaPackage(builder.toString());\r
     }\r
 \r
+    /**\r
+     * Converts <code>token</code> to string which is in accordance with best\r
+     * practices for JAVA class names.\r
+     * \r
+     * @param token\r
+     *            string which contains characters which should be converted to\r
+     *            JAVA class name\r
+     * @return string which is in accordance with best practices for JAVA class\r
+     *         name.\r
+     */\r
     public static String parseToClassName(String token) {\r
         token = token.replace(".", "");\r
         String correctStr = parseToCamelCase(token);\r
@@ -161,6 +268,16 @@ public final class BindingGeneratorUtil {
         return correctStr;\r
     }\r
 \r
+    /**\r
+     * Converts <code>token</code> to string which is in accordance with best\r
+     * practices for JAVA parameter names.\r
+     * \r
+     * @param token\r
+     *            string which contains characters which should be converted to\r
+     *            JAVA parameter name\r
+     * @return string which is in accordance with best practices for JAVA\r
+     *         parameter name.\r
+     */\r
     public static String parseToValidParamName(final String token) {\r
         final String validToken = token.replace(".", "");\r
         String correctStr = parseToCamelCase(validToken);\r
@@ -171,6 +288,14 @@ public final class BindingGeneratorUtil {
         return validateParameterName(correctStr);\r
     }\r
 \r
+    /**\r
+     * Converts <code>token</code> to capital letters and removes invalid\r
+     * characters.\r
+     * \r
+     * @param token\r
+     *            string with characters which should be conversed to capital\r
+     * @return string with capital letters\r
+     */\r
     public static String convertToCapitalLetters(final String token) {\r
         String convertedStr = token.replace(" ", "_");\r
         convertedStr = convertedStr.replace(".", "_");\r
@@ -178,13 +303,25 @@ public final class BindingGeneratorUtil {
         return convertedStr;\r
     }\r
 \r
+    /**\r
+     * \r
+     * Converts string <code>token</code> to the cammel case format.\r
+     * \r
+     * @param token\r
+     *            string which should be converted to the cammel case format\r
+     * @return string in the cammel case format\r
+     * @throws NullPointerException\r
+     *             - if <code>token</code> equals null\r
+     * @throws IllegalArgumentException\r
+     *             - if <code>token</code> without white spaces is empty\r
+     */\r
     private static String parseToCamelCase(String token) {\r
         if (token == null) {\r
             throw new NullPointerException("Name can not be null");\r
         }\r
 \r
         String correctStr = token.trim();\r
-        if (correctStr.length() == 0) {\r
+        if (correctStr.isEmpty()) {\r
             throw new IllegalArgumentException("Name can not be emty");\r
         }\r
 \r
@@ -194,6 +331,20 @@ public final class BindingGeneratorUtil {
         return correctStr;\r
     }\r
 \r
+    /**\r
+     * Replaces all the occurances of the <code>removalChar</code> in the\r
+     * <code>text</code> with empty string and converts following character to\r
+     * upper case.\r
+     * \r
+     * @param text\r
+     *            string with source text which should be converted\r
+     * @param removalChar\r
+     *            character which is sought in the <code>text</code>\r
+     * @return string which doesn't contain <code>removalChar</code> and has\r
+     *         following characters converted to upper case\r
+     * @throws IllegalArgumentException\r
+     *             if the length of the returning string has length 0\r
+     */\r
     private static String replaceWithCamelCase(String text, char removalChar) {\r
         StringBuilder sb = new StringBuilder(text);\r
         String toBeRemoved = String.valueOf(removalChar);\r
@@ -204,7 +355,7 @@ public final class BindingGeneratorUtil {
             // check if 'toBeRemoved' character is not the only character in\r
             // 'text'\r
             if (sb.length() == 0) {\r
-                throw new IllegalArgumentException("Name can not be '" + toBeRemoved + "'");\r
+                throw new IllegalArgumentException("The resulting string can not be empty");\r
             }\r
             String replacement = String.valueOf(sb.charAt(toBeRemovedPos)).toUpperCase();\r
             sb.setCharAt(toBeRemovedPos, replacement.charAt(0));\r
index ed1c0e993797b2f40f3c62106d3d56f828f345f5..c3c48d850fc2450ccc9c98a69dc830d20fcb0d25 100644 (file)
@@ -7,8 +7,22 @@
  */
 package org.opendaylight.yangtools.binding.generator.util;
 
+/**
+ * 
+ * Wraps combination of <code>packageName</code> and <code>name</code> to the
+ * object representation
+ * 
+ */
 public final class ReferencedTypeImpl extends AbstractBaseType {
 
+    /**
+     * Creates instance of this class with concrete package name and type name
+     * 
+     * @param packageName
+     *            string with the package name
+     * @param name
+     *            string with the name for referenced type
+     */
     public ReferencedTypeImpl(String packageName, String name) {
         super(packageName, name);
     }
index 9154f1087bdc9487a18923eca83e355178558bd9..0cbe98cb0c0c07393d432895916f2acac109babc 100644 (file)
@@ -1,9 +1,20 @@
 package org.opendaylight.yangtools.binding.generator.util;
 
+/**
+ * 
+ * Contains constants used in relations with <code>Type</code>.
+ */
 public final class TypeConstants {
 
+    /**
+     * Name of the class constant which hold list of the regular expression
+     * strings.
+     */
     public static final String PATTERN_CONSTANT_NAME = "PATTERN_CONSTANTS";
 
+    /**
+     * Creation of new instance is prohibited.
+     */
     private TypeConstants() {
     }
 }
index d4735dba3f1a7752a331492dd5f3c5a7f588b5da..bd447c2204e6234587ce27ba259ec8863609ad9d 100644 (file)
@@ -28,17 +28,37 @@ public final class Types {
     private static final Type MAP_TYPE = typeForClass(Map.class);
     public static final Type DATA_OBJECT = typeForClass(DataObject.class);
 
+    /**
+     * Creates the instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ConcreteType
+     * ConcreteType} which represents JAVA <code>void</code> type.
+     * 
+     * @return <code>ConcreteType</code> instance which represents JAVA
+     *         <code>void</code>
+     */
     public static ConcreteType voidType() {
         return new ConcreteTypeImpl(Void.class.getPackage().getName(), Void.class.getSimpleName());
     }
 
+    /**
+     * Creates the instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ConcreteType
+     * ConcreteType} which represents primitive JAVA type for which package
+     * doesn't exist.
+     * 
+     * @param primitiveType
+     *            string containing programaticall construction based on
+     *            primitive type (e.g byte[])
+     * @return <code>ConcreteType</code> instance which represents programatic
+     *         construction with primitive JAVA type
+     */
     public static final Type primitiveType(final String primitiveType) {
         return new ConcreteTypeImpl("", primitiveType);
     }
 
     /**
      * Returns an instance of {@link ConcreteType} describing the class
-     *
+     * 
      * @param cls
      *            Class to describe
      * @return Description of class
@@ -50,7 +70,7 @@ public final class Types {
     /**
      * Returns an instance of {@link ParameterizedType} describing the typed
      * {@link Map}<K,V>
-     *
+     * 
      * @param keyType
      *            Key Type
      * @param valueType
@@ -64,7 +84,7 @@ public final class Types {
     /**
      * Returns an instance of {@link ParameterizedType} describing the typed
      * {@link Set}<V> with concrete type of value.
-     *
+     * 
      * @param valueType
      *            Value Type
      * @return Description of generic type instance of Set
@@ -76,7 +96,7 @@ public final class Types {
     /**
      * Returns an instance of {@link ParameterizedType} describing the typed
      * {@link List}<V> with concrete type of value.
-     *
+     * 
      * @param valueType
      *            Value Type
      * @return Description of type instance of List
@@ -85,6 +105,13 @@ public final class Types {
         return parameterizedTypeFor(LIST_TYPE, valueType);
     }
 
+    /**
+     * Creates generated transfer object for
+     * {@link org.opendaylight.yangtools.yang.binding.BaseIdentity BaseIdentity}
+     * 
+     * @return generated transfer object which is used as extension when YANG
+     *         <code>identity</code> is mapped to generated TO
+     */
     public static GeneratedTransferObject getBaseIdentityTO() {
         Class<BaseIdentity> cls = BaseIdentity.class;
         GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(cls.getPackage().getName(), cls.getSimpleName());
@@ -92,37 +119,107 @@ public final class Types {
     }
 
     /**
-     *
+     * Creates instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
+     * ParameterizedType}
+     * 
      * @param type
+     *            JAVA <code>Type</code> for raw type
      * @param parameters
-     * @return
+     *            JAVA <code>Type</code>s for actual parameter types
+     * @return <code>ParametrizedType</code> reprezentation of <code>type</code>
+     *         and its parameters <code>parameters</code>
      */
     public static ParameterizedType parameterizedTypeFor(Type type, Type... parameters) {
         return new ParametrizedTypeImpl(type, parameters);
     }
 
+    /**
+     * Creates instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.WildcardType
+     * WildcardType}
+     * 
+     * @param packageName
+     *            string with the package name
+     * @param typeName
+     *            string with the type name
+     * @return <code>WildcardType</code> reprezentation of
+     *         <code>packageName</code> and <code>typeName</code>
+     */
     public static WildcardType wildcardTypeFor(String packageName, String typeName) {
         return new WildcardTypeImpl(packageName, typeName);
     }
 
+    /**
+     * Creates instance of
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
+     * ParameterizedType} where raw type is
+     * {@link org.opendaylight.yangtools.yang.binding.Augmentable} and actual
+     * parameter is <code>valueType</code>.
+     * 
+     * @param valueType
+     *            JAVA <code>Type</code> with actual parameter
+     * @return <code>ParametrizedType</code> reprezentation of raw type
+     *         <code>Augmentable</code> with actual parameter
+     *         <code>valueType</code>
+     */
     public static ParameterizedType augmentableTypeFor(Type valueType) {
         final Type augmentable = typeForClass(Augmentable.class);
         return parameterizedTypeFor(augmentable, valueType);
     }
 
+    /**
+     * Creates instance of
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
+     * ParameterizedType} where raw type is
+     * {@link org.opendaylight.yangtools.yang.binding.Augmentation} and actual
+     * parameter is <code>valueType</code>.
+     * 
+     * @param valueType
+     *            JAVA <code>Type</code> with actual parameter
+     * @return <code>ParametrizedType</code> reprezentation of raw type
+     *         <code>Augmentation</code> with actual parameter
+     *         <code>valueType</code>
+     */
     public static ParameterizedType augmentationTypeFor(Type valueType) {
         final Type augmentation = typeForClass(Augmentation.class);
         return parameterizedTypeFor(augmentation, valueType);
     }
 
+    /**
+     * 
+     * Represents concrete JAVA type.
+     * 
+     */
     private static class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType {
+        /**
+         * Creates instance of this class with package <code>pkName</code> and
+         * with the type name <code>name</code>.
+         * 
+         * @param pkName
+         *            string with package name
+         * @param name
+         *            string with the name of the type
+         */
         private ConcreteTypeImpl(String pkName, String name) {
             super(pkName, name);
         }
     }
 
+    /**
+     * 
+     * Represents parametrized JAVA type.
+     * 
+     */
     private static class ParametrizedTypeImpl extends AbstractBaseType implements ParameterizedType {
+        /**
+         * Array of JAVA actual type parameters.
+         */
         private Type[] actualTypes;
+
+        /**
+         * JAVA raw type (like List, Set, Map...)
+         */
         private Type rawType;
 
         @Override
@@ -136,6 +233,15 @@ public final class Types {
             return rawType;
         }
 
+        /**
+         * Creates instance of this class with concrete rawType and array of
+         * actual parameters.
+         * 
+         * @param rawType
+         *            JAVA <code>Type</code> for raw type
+         * @param actTypes
+         *            array of actual parameters
+         */
         public ParametrizedTypeImpl(Type rawType, Type[] actTypes) {
             super(rawType.getPackageName(), rawType.getName());
             this.rawType = rawType;
@@ -144,7 +250,20 @@ public final class Types {
 
     }
 
+    /**
+     * 
+     * Represents JAVA bounded wildcard type.
+     * 
+     */
     private static class WildcardTypeImpl extends AbstractBaseType implements WildcardType {
+        /**
+         * Creates instance of this class with concrete package and type name.
+         * 
+         * @param packageName
+         *            string with the package name
+         * @param typeName
+         *            string with the name of type
+         */
         public WildcardTypeImpl(String packageName, String typeName) {
             super(packageName, typeName);
         }
index 11bee9f8a9d82bbb3fe9bcd1b845f973b9abfd5f..1ef58b9ec9d169f29d734ceb5f7ab2de465726e9 100644 (file)
@@ -23,7 +23,7 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
     private final String name;
     private final List<Enumeration.Pair> values;
     private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<>();
-    
+
     public EnumerationBuilderImpl(final String packageName, final String name) {
         super(packageName, name);
         this.packageName = packageName;
@@ -41,7 +41,7 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
         }
         return null;
     }
-    
+
     @Override
     public void addValue(final String name, final Integer value) {
         values.add(new EnumPairImpl(name, value));
@@ -51,7 +51,7 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
     public Enumeration toInstance(final Type definingType) {
         return new EnumerationImpl(definingType, annotationBuilders, packageName, name, values);
     }
-    
+
     /*
      * (non-Javadoc)
      * 
@@ -62,8 +62,7 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
         final int prime = 31;
         int result = 1;
         result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result
-                + ((packageName == null) ? 0 : packageName.hashCode());
+        result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
         return result;
     }
 
@@ -212,17 +211,15 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
         private final String name;
         private final List<Pair> values;
         private List<AnnotationType> annotations = new ArrayList<>();
-        
-        public EnumerationImpl(final Type definingType,
-                final List<AnnotationTypeBuilder> annotationBuilders,
-                final String packageName, final String name,
-                final List<Pair> values) {
+
+        public EnumerationImpl(final Type definingType, final List<AnnotationTypeBuilder> annotationBuilders,
+                final String packageName, final String name, final List<Pair> values) {
             super();
             this.definingType = definingType;
             for (final AnnotationTypeBuilder builder : annotationBuilders) {
                 annotations.add(builder.toInstance());
             }
-            this.annotations = Collections.unmodifiableList(annotations); 
+            this.annotations = Collections.unmodifiableList(annotations);
             this.packageName = packageName;
             this.name = name;
             this.values = Collections.unmodifiableList(values);
@@ -252,7 +249,7 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
         public List<Pair> getValues() {
             return values;
         }
-        
+
         @Override
         public List<AnnotationType> getAnnotations() {
             return annotations;
@@ -282,6 +279,7 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
                 }
                 ++i;
             }
+            builder.append("\n}");
             return builder.toString();
         }
 
@@ -295,10 +293,8 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
             final int prime = 31;
             int result = 1;
             result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result
-                    + ((packageName == null) ? 0 : packageName.hashCode());
-            result = prime * result
-                    + ((values == null) ? 0 : values.hashCode());
+            result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
+            result = prime * result + ((values == null) ? 0 : values.hashCode());
 
             return result;
         }
index 571c301b009ec2b6d2b315f3b5c383f194e705aa..dab7ace248a22fc58e06abf5b1a18478c16e6d0c 100644 (file)
@@ -8,10 +8,28 @@ import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;\r
 import org.opendaylight.yangtools.yang.binding.DataObject;\r
 \r
+/**\r
+ * \r
+ * Transformator of the data from the virtual form to JAVA programming language.\r
+ * The result source code represent java class. For generation of the source\r
+ * code is used the template written in XTEND language.\r
+ * \r
+ */\r
 public final class BuilderGenerator implements CodeGenerator {\r
 \r
+    /**\r
+     * Constant used as sufix for builder name.\r
+     */\r
     public static final String BUILDER = "Builder";\r
 \r
+    /**\r
+     * Passes via list of implemented types in <code>type</code>.\r
+     * \r
+     * @param type\r
+     *            JAVA <code>Type</code>\r
+     * @return boolean value which is true if any of implemented types is of the\r
+     *         type <code>Augmentable</code>.\r
+     */\r
     @Override\r
     public boolean isAcceptable(Type type) {\r
         if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
@@ -29,6 +47,11 @@ public final class BuilderGenerator implements CodeGenerator {
         return false;\r
     }\r
 \r
+    /**\r
+     * Generates JAVA source code for generated type <code>Type</code>. The code\r
+     * is generated according to the template source code template which is\r
+     * written in XTEND language.\r
+     */\r
     @Override\r
     public String generate(Type type) {\r
         if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
index 6ffc912ebfd7d781da432f2992efe4aab0149968..5f842a29ffe1ae661dec30eb4a381b125c994c6e 100644 (file)
@@ -14,21 +14,70 @@ import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature
 import org.opendaylight.yangtools.sal.binding.model.api.Type
 import org.opendaylight.yangtools.yang.binding.Augmentable
 
+/**
+ * Template for generating JAVA builder classes. 
+ */
 class BuilderTemplate {
 
+       /**
+        * Constant with prefix for getter methods.
+        */
     val static GET_PREFIX = "get"
+    
+    /**
+     * Constant with the name of the concrete package prefix. 
+     */
     val static JAVA_UTIL = "java.util"
+    
+    /**
+     * Constant with the name of the concrete JAVA type
+     */
     val static HASH_MAP = "HashMap"
+    
+    /**
+     * Constant with the name of the concrete JAVA interface.
+     */
     val static MAP = "Map"
+    
+    /**
+     * Constant with the name of the concrete method.
+     */
     val static GET_AUGMENTATION_METHOD_NAME = "getAugmentation"
+    
+    /**
+     * Constant with the suffix for builder classes.
+     */
     val static BUILDER = 'Builder'
+    
+    /**
+     * Constant with suffix for the classes which are generated from the builder classes.
+     */
     val static IMPL = 'Impl'
     
+    /**
+     * Reference to type for which is generated builder class
+     */
     val GeneratedType genType
+    
+    /**
+     * Map of imports. The keys are type names and the values are package names.
+     */
     val Map<String, String> imports
+    
+    /**
+     * Generated property is set if among methods is found one with the name GET_AUGMENTATION_METHOD_NAME
+     */
     var GeneratedProperty augmentField
+    
+    /**
+     * Set of class attributes (fields) which are derived from the getter methods names
+     */
     val Set<GeneratedProperty> fields
     
+    /**
+     * Constructs new instance of this class.
+     * @throws IllegalArgumentException if <code>genType</code> equals <code>null</code>
+     */
     new(GeneratedType genType) {
         if (genType == null) {
             throw new IllegalArgumentException("Generated type reference cannot be NULL!")
@@ -39,6 +88,12 @@ class BuilderTemplate {
         this.fields = createFieldsFromMethods(createMethods)
     }
     
+    /**
+     * Returns set of method signature instances which contains all the methods of the <code>genType</code>
+     * and all the methods of the implemented interfaces.
+     * 
+     * @returns set of method signature instances
+     */
     def private Set<MethodSignature> createMethods() {
         val Set<MethodSignature> methods = new LinkedHashSet
         methods.addAll(genType.methodDefinitions)
@@ -46,6 +101,13 @@ class BuilderTemplate {
         return methods
     }
     
+    /**
+     * Adds to the <code>methods</code> set all the methods of the <code>implementedIfcs</code> 
+     * and recursivelly their implemented interfaces.
+     * 
+     * @param methods set of method signatures
+     * @param implementedIfcs list of implemented interfaces
+     */
     def private void storeMethodsOfImplementedIfcs(Set<MethodSignature> methods, List<Type> implementedIfcs) {
         if (implementedIfcs == null || implementedIfcs.empty) {
             return
@@ -76,6 +138,14 @@ class BuilderTemplate {
         }
     }
     
+    /**
+     * Adds to the <code>imports</code> map the package <code>typePackageName</code>.
+     * 
+     * @param typePackageName 
+     * string with the name of the package which is added to <code>imports</code> as a value
+     * @param typeName 
+     * string with the name of the package which is added to <code>imports</code> as a key
+     */
     def private void addToImports(String typePackageName,String typeName) {
         if (typePackageName.startsWith("java.lang") || typePackageName.isEmpty()) {
             return
@@ -85,20 +155,43 @@ class BuilderTemplate {
         }
     }
     
+    /**
+     * Returns the first element of the list <code>elements</code>.
+     * 
+     * @param list of elements
+     */
     def private <E> first(List<E> elements) {
         elements.get(0)
     }
     
+    /**
+     * Returns the name of the package from <code>fullyQualifiedName</code>.
+     * 
+     * @param fullyQualifiedName string with fully qualified type name (package + type)
+     * @return string with the package name
+     */
     def private String getPackage(String fullyQualifiedName) {
         val lastDotIndex = fullyQualifiedName.lastIndexOf(Constants.DOT)
         return if (lastDotIndex == -1) "" else fullyQualifiedName.substring(0, lastDotIndex)
     }
 
+       /**
+        * Returns the name of tye type from <code>fullyQualifiedName</code>
+        * 
+        * @param fullyQualifiedName string with fully qualified type name (package + type)
+        * @return string with the name of the type
+        */
     def private String getName(String fullyQualifiedName) {
         val lastDotIndex = fullyQualifiedName.lastIndexOf(Constants.DOT)
         return if (lastDotIndex == -1) fullyQualifiedName else fullyQualifiedName.substring(lastDotIndex + 1)
     }
     
+    /**
+     * Creates set of generated property instances from getter <code>methods</code>.
+     * 
+     * @param set of method signature instances which should be transformed to list of properties 
+     * @return set of generated property instances which represents the getter <code>methods</code>
+     */
     def private createFieldsFromMethods(Set<MethodSignature> methods) {
         val Set<GeneratedProperty> result = new LinkedHashSet
 
@@ -115,6 +208,18 @@ class BuilderTemplate {
         return result
     }
     
+    /**
+     * Creates generated property instance from the getter <code>method</code> name and return type.
+     * 
+     * @param method method signature from which is the method name and return type obtained
+     * @return generated property instance for the getter <code>method</code>
+     * @throws IllegalArgumentException<ul>
+     *         <li>if the <code>method</code> equals <code>null</code></li>
+     *         <li>if the name of the <code>method</code> equals <code>null</code></li>
+     *         <li>if the name of the <code>method</code> is empty</li>
+     *         <li>if the return type of the <code>method</code> equals <code>null</code></li>
+     * </ul>
+     */
     def private GeneratedProperty createFieldFromGetter(MethodSignature method) {
         if (method == null || method.name == null || method.name.empty || method.returnType == null) {
             throw new IllegalArgumentException("Method, method name, method return type reference cannot be NULL or empty!")
@@ -127,12 +232,22 @@ class BuilderTemplate {
         }
     }
 
+       /**
+        * Builds string which contains JAVA source code.
+        * 
+        * @return string with JAVA source code
+        */
     def String generate() {
         val body = generateBody
         val pkgAndImports = generatePkgAndImports
         return pkgAndImports.toString + body.toString
     }
     
+    /**
+     * Template method which generates JAVA class body for builder class and for IMPL class. 
+     * 
+     * @return string with JAVA source code
+     */
     def private generateBody() '''
         public class «genType.name»«BUILDER» {
         
@@ -157,6 +272,12 @@ class BuilderTemplate {
         }
     '''
 
+       /**
+        * Template method which generates class attributes.
+        * 
+        * @param boolean value which specify whether field is|isn't final
+        * @return string with class attributes and their types
+        */
     def private generateFields(boolean _final) '''
         «IF !fields.empty»
             «FOR f : fields»
@@ -168,6 +289,11 @@ class BuilderTemplate {
         «ENDIF»
     '''
 
+       /**
+        * Template method which generates setter methods
+        * 
+        * @return string with the setter methods 
+        */
     def private generateSetters() '''
         «FOR field : fields SEPARATOR '\n'»
             public «genType.name»«BUILDER» set«field.name.toFirstUpper»(«field.returnType.resolveName» «field.name») {
@@ -184,6 +310,11 @@ class BuilderTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generate constructor for IMPL class.
+     * 
+     * @return string with IMPL class constructor
+     */
     def private generateConstructor() '''
         private «genType.name»«IMPL»() {
             «IF !fields.empty»
@@ -197,6 +328,11 @@ class BuilderTemplate {
         }
     '''
     
+    /**
+     * Template method which generate getter methods for IMPL class.
+     * 
+     * @return string with getter methods
+     */
     def private generateGetters() '''
         «IF !fields.empty»
             «FOR field : fields SEPARATOR '\n'»
@@ -219,6 +355,11 @@ class BuilderTemplate {
         «ENDIF»
     '''    
     
+    /**
+     * Template method which generate package name line and import lines.
+     * 
+     * @result string with package and import lines in JAVA format
+     */
     def private generatePkgAndImports() '''
         package «genType.packageName»;
         
@@ -231,6 +372,12 @@ class BuilderTemplate {
         
     '''
     
+    /**
+     * Adds package to imports if it is necessary and returns necessary type name (with or without package name)
+     * 
+     * @param type JAVA <code>Type</code>
+     * @return string with the type name (with or without package name)
+     */
     def private resolveName(Type type) {
         GeneratorUtil.putTypeIntoImports(genType, type, imports);
         GeneratorUtil.getExplicitType(genType, type, imports)
index af55ac813fe9c2146af94dcac4c49fc01d376311..c58a781761b3a5bf595570b8afd841dd0f6eb4db 100644 (file)
@@ -10,14 +10,41 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
 import org.opendaylight.yangtools.sal.binding.model.api.Type
 import org.opendaylight.yangtools.binding.generator.util.Types
 
+/**
+ * Template for generating JAVA class. 
+ */
 class ClassTemplate {
     
+    /**
+     * Generated transfer object for which class JAVA file is generated
+     */
     val GeneratedTransferObject genTO
+    
+    /**
+     * Map of imports for this <code>genTO</code>.
+     */
     val Map<String, String> imports
+    
+    /**
+     * List of generated property instances which represents class attributes.
+     */
     val List<GeneratedProperty> fields
+    
+    /**
+     * List of enumeration which are generated as JAVA enum type.
+     */
     val List<Enumeration> enums
+    
+    /**
+     * List of constant instances which are generated as JAVA public static final attributes.
+     */
     val List<Constant> consts
     
+    /**
+     * Creates instance of this class with concrete <code>genTO</code>.
+     * 
+     * @param genTO generated transfer object which will be transformed to JAVA class source code
+     */
     new(GeneratedTransferObject genTO) {
         if (genTO == null) {
             throw new IllegalArgumentException("Generated transfer object reference cannot be NULL!")
@@ -30,16 +57,32 @@ class ClassTemplate {
         this.consts = genTO.constantDefinitions
     }
     
+    /**
+     * Generates JAVA class source code (package name + class body).
+     * 
+     * @return string with JAVA class source code
+     */
     def String generate() {
         val body = generateBody(false)
         val pkgAndImports = generatePkgAndImports
         return pkgAndImports.toString + body.toString
     }
     
+    /**
+     * Generates JAVA class source code (class body only).
+     * 
+     * @return string with JAVA class body source code
+     */
     def generateAsInnerClass() {
         return generateBody(true)
     }
     
+    /**
+     * Template method which generates class body.
+     * 
+     * @param isInnerClass boolean value which specify if generated class is|isn't inner
+     * @return string with class source code in JAVA format
+     */
     def private generateBody(boolean isInnerClass) '''
         «genTO.comment.generateComment»
         «generateClassDeclaration(isInnerClass)» {
@@ -69,6 +112,12 @@ class ClassTemplate {
         }
     '''
     
+    /**
+     * Template method which generates JAVA comments.
+     * 
+     * @param string with the comment for whole JAVA class
+     * @return string with comment in JAVA format
+     */
     def private generateComment(String comment) '''
         «IF comment != null && !comment.empty»
             /*
@@ -77,6 +126,12 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates JAVA class declaration.
+     * 
+     * @param isInnerClass boolean value which specify if generated class is|isn't inner
+     * @return string with class declaration in JAVA format
+     */
     def private generateClassDeclaration(boolean isInnerClass) '''
         public«
         IF (isInnerClass)»«
@@ -97,6 +152,11 @@ class ClassTemplate {
         ENDIF
     »'''
     
+    /**
+     * Template method which generates JAVA enum type.
+     * 
+     * @return string with inner enum source code in JAVA format
+     */
     def private generateEnums() '''
         «IF !enums.empty»
             «FOR e : enums SEPARATOR "\n"»
@@ -106,6 +166,11 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method wich generates JAVA constants.
+     * 
+     * @return string with constants in JAVA format 
+     */
     def private generateConstants() '''
         «IF !consts.empty»
             «FOR c : consts»
@@ -130,6 +195,11 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates JAVA static initialization block.
+     * 
+     * @return string with static initialization block in JAVA format
+     */
     def private generateStaticInicializationBlock() '''
         static {
             for (String regEx : «TypeConstants.PATTERN_CONSTANT_NAME») {
@@ -137,6 +207,12 @@ class ClassTemplate {
             }
         }
     '''
+    
+    /**
+     * Template method which generates JAVA class attributes.
+     * 
+     * @return string with the class attributes in JAVA format
+     */
     def private generateFields() '''
         «IF !fields.empty»
             «FOR f : fields»
@@ -145,6 +221,11 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates JAVA constructor(s).
+     * 
+     * @return string with the class constructor(s) in JAVA format
+     */
     def private generateConstructor() '''
         «val genTOTopParent = GeneratorUtil.getTopParrentTransportObject(genTO)»
         «val properties = GeneratorUtil.resolveReadOnlyPropertiesFromTO(genTO.properties)»
@@ -183,21 +264,43 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates the getter method for <code>field</code>
+     * 
+     * @param field 
+     * generated property with data about field which is generated as the getter method
+     * @return string with the getter method source code in JAVA format 
+     */     
     def private generateGetter(GeneratedProperty field) {
         val prefix = if(field.returnType.equals(Types.typeForClass(Boolean))) "is" else "get"
     '''
         public «field.returnType.resolveName» «prefix»«field.name.toFirstUpper»() {
             return «field.fieldName»;
+
         }
     '''
     }
-    def private generateSetter(GeneratedProperty field) '''
+    /**
+     * Template method which generates the setter method for <code>field</code>
+     * 
+     * @param field 
+     * generated property with data about field which is generated as the setter method
+     * @return string with the setter method source code in JAVA format 
+     */
+     def private generateSetter(GeneratedProperty field) '''
         «val type = field.returnType.resolveName»
         public void set«field.name.toFirstUpper»(«type» «field.fieldName») {
             this.«field.fieldName» = «field.fieldName»;
         }
     '''
     
+    /**
+     * Template method which generates method parameters with their types from <code>parameters</code>.
+     * 
+     * @param parameters
+     * group of generated property instances which are transformed to the method parameters
+     * @return string with the list of the method parameters with their types in JAVA format
+     */
     def private generateParameters(Iterable<GeneratedProperty> parameters) '''«
         IF !parameters.empty»«
             FOR parameter : parameters SEPARATOR ", "»«
@@ -206,6 +309,13 @@ class ClassTemplate {
         ENDIF
     »'''
     
+    /**
+     * Template method which generates sequence of the names of the class attributes from <code>parameters</code>.
+     * 
+     * @param parameters 
+     * group of generated property instances which are transformed to the sequence of parameter names
+     * @return string with the list of the parameter names of the <code>parameters</code> 
+     */
     def private generateParameterNames(Iterable<GeneratedProperty> parameters) '''«
         IF !parameters.empty»«
             FOR parameter : parameters SEPARATOR ", "»«
@@ -214,6 +324,11 @@ class ClassTemplate {
         ENDIF
     »'''
     
+    /**
+     * Template method which generates the method <code>hashCode()</code>.
+     * 
+     * @return string with the <code>hashCode()</code> method definition in JAVA format
+     */
     def private generateHashCode() '''
         «IF !genTO.hashCodeIdentifiers.empty»
             @Override
@@ -227,6 +342,12 @@ class ClassTemplate {
             }
         «ENDIF»
     '''
+    
+    /**
+     * Template method which generates the method <code>equals()</code>.
+     * 
+     * @return string with the <code>equals()</code> method definition in JAVA format     
+     */
     def private generateEquals() '''
         «IF !genTO.equalsIdentifiers.empty»
             @Override
@@ -256,6 +377,11 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates the method <code>toString()</code>.
+     * 
+     * @return string with the <code>toString()</code> method definition in JAVA format     
+     */
     def private generateToString() '''
         «IF !genTO.toStringIdentifiers.empty»
             @Override
@@ -274,6 +400,11 @@ class ClassTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generate package name line and import lines.
+     * 
+     * @result string with package and import lines in JAVA format
+     */
     def private generatePkgAndImports() '''
         package «genTO.packageName»;
         
@@ -285,7 +416,13 @@ class ClassTemplate {
         «ENDIF»
         
     '''
-    
+
+    /**
+     * Adds package to imports if it is necessary and returns necessary type name (with or without package name)
+     * 
+        * @param type JAVA <code>Type</code> 
+     * @return string with the type name (with or without package name)
+     */    
     def private resolveName(Type type) {
         GeneratorUtil.putTypeIntoImports(genTO, type, imports);
         GeneratorUtil.getExplicitType(genTO, type, imports)
index 05b093b31c158c016b070bb55af98756fa9e350f..a3f07e0f8dd48526f893054e78a7b39d4d696cd5 100644 (file)
@@ -7,48 +7,25 @@
  */
 package org.opendaylight.yangtools.sal.java.api.generator;
 
+/**
+ * 
+ * Various constants when generating JAVA source code.
+ * 
+ */
 final class Constants {
-    public static final String IFC = "interface";
-    public static final String CLASS = "class";
-    public static final String PKG = "package";
-    public static final String ENUM = "enum";
-
-    public static final String LCB = "{";
-    public static final String RCB = "}";
-
-    public static final String LB = "(";
-    public static final String RB = ")";
-
-    public static final String LSB = "[";
-    public static final String RSB = "]";
 
-    public static final String GAP = " ";
     public static final String COMMA = ",";
     public static final String DOT = ".";
-    public static final String ASTERISK = "*";
-    public static final String NL = "\n";
-    public static final String SC = ";";
-    public static final String TAB = "    ";
-    public static final String ASSIGN = "=";
-    public static final String DOUBLE_QUOTE = "\"";
 
-    public static final String PUBLIC = "public";
-    public static final String PRIVATE = "private";
-    public static final String PROTECTED = "protected";
-    public static final String STATIC = "static";
-    public static final String ABSTRACT = "abstract";
-    public static final String FINAL = "final";
-    public static final String EXTENDS = "extends";
-    public static final String IMPLEMENTS = "implements";
-
-    public static final String ENUMERATION_NAME = "value";
-    public static final String ENUMERATION_TYPE = "int";
-
-    public static final String STRING_PATTERN_LIST = "STRING_PATTERNS";
+    /**
+     * Name of the class constant which contains list of <code>Pattern</code>
+     * instances.
+     */
     public static final String MEMBER_PATTERN_LIST = "patterns";
 
-    public static final String NO_INDENT = "";
-
+    /**
+     * It doesn't have the sense to create the instances of this class.
+     */
     private Constants() {
     }
 }
index b32993b040436df70f8d40edecf85711be5e9e54..6cee013b1e8e352e296a59de772a90c38faf77c2 100644 (file)
@@ -1,36 +1,48 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.java.api.generator;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-\r
-public class EnumGenerator implements CodeGenerator {\r
-\r
-    @Override\r
-    public boolean isAcceptable(Type type) {\r
-        return type instanceof Enumeration;\r
-    }\r
-\r
-    @Override\r
-    public String generate(Type type) {\r
-        if (type instanceof Enumeration) {\r
-            final Enumeration enums = (Enumeration) type;\r
-            final EnumTemplate enumTemplate = new EnumTemplate(enums);\r
-            return enumTemplate.generate();\r
-        }\r
-        return "";\r
-    }\r
-\r
-    @Override\r
-    public String getUnitName(Type type) {\r
-        return type.getName();\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.sal.java.api.generator;
+
+import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+/**
+ * 
+ * Transformator of the data from the virtual form to JAVA source code. The
+ * result source code represents JAVA enumeration. For generation of the source
+ * code is used the template written in XTEND language.
+ * 
+ */
+public class EnumGenerator implements CodeGenerator {
+
+    @Override
+    public boolean isAcceptable(Type type) {
+        return type instanceof Enumeration;
+    }
+
+    /**
+     * Generates JAVA source code for generated type <code>Type</code>. The code
+     * is generated according to the template source code template which is
+     * written in XTEND language.
+     */
+    @Override
+    public String generate(Type type) {
+        if (type instanceof Enumeration) {
+            final Enumeration enums = (Enumeration) type;
+            final EnumTemplate enumTemplate = new EnumTemplate(enums);
+            return enumTemplate.generate();
+        }
+        return "";
+    }
+
+    @Override
+    public String getUnitName(Type type) {
+        return type.getName();
+    }
+
+}
index 741835d28f4c91970459646fb55e9f7e010e5abf..60cbb2955364920ab5d780727a7755b39dcdd96d 100644 (file)
@@ -1,25 +1,50 @@
 package org.opendaylight.yangtools.sal.java.api.generator
 
 import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
-
+/**
+ * Template for generating JAVA enumeration type. 
+ */
 class EnumTemplate {
     
+    /**
+     * Enumeration which will be transformed to JAVA source code for enumeration
+     */
     val Enumeration enums
     
+    /**
+     * Constructs instance of this class with concrete <code>enums</code>.
+     * 
+     * @param enumeration which will be transformed to JAVA source code 
+     */
     new(Enumeration enums) {
         this.enums = enums
     }
     
+    /**
+     * Generates JAVA source code for the enumeration with the package name.
+     * 
+     * @return JAVA source code for enumeration and for the package name 
+     */
     def String generate() {
         val body = generateBody
         val pkg = generatePkg
         return pkg.toString + body.toString
     }
     
+    /**
+     * Generates only JAVA enumeration source code.
+     * 
+     * @return string with JAVA enumeration source code
+     */
     def generateAsInnerClass() {
         return generateBody
     }
     
+    /**
+     * Template method which generates enumeration body (declaration + enumeration items).
+     * 
+     * @return string with the enumeration body 
+     */
     def private generateBody() '''
         public enum «enums.name» {
         «FOR v : enums.values SEPARATOR ",\n"»
@@ -34,6 +59,11 @@ class EnumTemplate {
         }
     '''
     
+    /**
+     * Template method which generates the package name line.
+     * 
+     * @return string with the package name line   
+     */
     def private generatePkg() '''
         package «enums.packageName»;
         
index 895b1972c8bdcaa5f504d33d4fa10177d4b32d25..ea33be2e9ffc4af319e1828aefd9d1a5cff9fb7f 100644 (file)
@@ -20,21 +20,51 @@ import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * Generates files with JAVA source codes for every specified type.
+ * 
+ */
 public final class GeneratorJavaFile {
 
     private static final Logger log = LoggerFactory.getLogger(GeneratorJavaFile.class);
+
+    /**
+     * List of <code>CodeGenerator</code> instances.
+     */
     private final List<CodeGenerator> generators = new ArrayList<>();
 
+    /**
+     * Set of <code>Type</code> instances for which the JAVA code is generated.
+     */
     private final Set<? extends Type> types;
 
+    /**
+     * Creates instance of this class with the set of <code>types</code> for
+     * which the JAVA code is generated.
+     * 
+     * The instances of concrete JAVA code generator are created.
+     * 
+     * @param types
+     *            set of types for which JAVA code should be generated
+     */
     public GeneratorJavaFile(final Set<? extends Type> types) {
-       this.types = types;
-       generators.add(new InterfaceGenerator());
-       generators.add(new TOGenerator());
-       generators.add(new EnumGenerator());
-       generators.add(new BuilderGenerator());
+        this.types = types;
+        generators.add(new InterfaceGenerator());
+        generators.add(new TOGenerator());
+        generators.add(new EnumGenerator());
+        generators.add(new BuilderGenerator());
     }
 
+    /**
+     * Generates list of files with JAVA source code. Only the suitable code
+     * generator is used to generate the source code for the concrete type.
+     * 
+     * @param parentDirectory
+     *            directory to which the output source codes should be generated
+     * @return list of output files
+     * @throws IOException
+     *             if the error during writting to the file occures
+     */
     public List<File> generateToFile(final File parentDirectory) throws IOException {
         final List<File> result = new ArrayList<>();
         for (Type type : types) {
@@ -48,6 +78,28 @@ public final class GeneratorJavaFile {
         return result;
     }
 
+    /**
+     * Generates <code>File</code> for <code>type</code>. All files are stored
+     * to subfolders of base directory <code>parentDir</code>. Subdirectories
+     * are generated according to packages to which the type belongs (e. g. if
+     * type belongs to the package <i>org.pcg</i> then in <code>parentDir</code>
+     * is created directory <i>org</i> which contains <i>pcg</i>).
+     * 
+     * @param parentDir
+     *            directory where should be the new file generated
+     * @param type
+     *            JAVA <code>Type</code> for which should be JAVA source code
+     *            generated
+     * @param generator
+     *            code generator which is used for generating of the source code
+     * @return file which contains JAVA source code
+     * @throws IOException
+     *             if the error during writting to the file occures
+     * @throws IllegalArgumentException
+     *             if <code>type</code> equals <code>null</code>
+     * @throws IllegalStateException
+     *             if string with generated code is empty
+     */
     private File generateTypeToJavaFile(final File parentDir, final Type type, final CodeGenerator generator)
             throws IOException {
         if (parentDir == null) {
@@ -67,7 +119,7 @@ public final class GeneratorJavaFile {
         if (!packageDir.exists()) {
             packageDir.mkdirs();
         }
-        
+
         if (generator.isAcceptable(type)) {
             String generatedCode = generator.generate(type);
             if (generatedCode.isEmpty()) {
@@ -87,7 +139,20 @@ public final class GeneratorJavaFile {
         }
         return null;
     }
-    
+
+    /**
+     * Creates the package directory path as concatenation of
+     * <code>parentDirectory</code> and parsed <code>packageName</code>. The
+     * parsing of <code>packageName</code> is realized as replacement of the
+     * package name dots with the file system separator.
+     * 
+     * @param parentDirectory
+     *            <code>File</code> object with reference to parent directory
+     * @param packageName
+     *            string with the name of the package
+     * @return <code>File</code> object which refers to the new directory for
+     *         package <code>packageName</code>
+     */
     private File packageToDirectory(final File parentDirectory, final String packageName) {
         if (packageName == null) {
             throw new IllegalArgumentException("Package Name cannot be NULL!");
index 7a7da13123904d5dfefedcae925494d41ae93561..f4cab6242f39774bffd6bdbb2431bd9782a054b3 100644 (file)
@@ -25,12 +25,26 @@ import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.WildcardType;
 
-
 public final class GeneratorUtil {
 
+    /**
+     * It doesn't have the sense to create the instances of this class.
+     */
     private GeneratorUtil() {
     }
 
+    /**
+     * Returns the map of imports. The map maps the type name to the package
+     * name. To the map are added packages for <code>genType</code> and for all
+     * enclosed types, constants, methods (parameter types, return values),
+     * implemented types.
+     * 
+     * @param genType
+     *            generated type for which the map of the imports is created
+     * @return map of the necessary imports
+     * @throws IllegalArgumentException
+     *             if <code>genType</code> equals <code>null</code>
+     */
     public static Map<String, String> createImports(GeneratedType genType) {
         if (genType == null) {
             throw new IllegalArgumentException("Generated Type cannot be NULL!");
@@ -98,6 +112,34 @@ public final class GeneratorUtil {
         return imports;
     }
 
+    /**
+     * Evaluates if it is necessary to add the package name for
+     * <code>type</code> to the map of imports for <code>parentGenType</code>.
+     * If it is so the package name is saved to the map <code>imports</code>.
+     * 
+     * @param parentGenType
+     *            generated type for which is the map of the necessary imports
+     *            built
+     * @param type
+     *            JAVA <code>Type</code> for which is the necessary of the
+     *            package import evaluated
+     * @param imports
+     *            map of the imports for <code>parentGenType</code>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the <code>parentGenType</code> equals
+     *             <code>null</code></li>
+     *             <li>if the name of <code>parentGenType</code> equals
+     *             <code>null</code></li>
+     *             <li>if the name of the package of <code>parentGenType</code>
+     *             equals <code>null</code></li>
+     *             <li>if the <code>type</code> equals <code>null</code></li>
+     *             <li>if the name of <code>type</code> equals <code>null</code>
+     *             </li>
+     *             <li>if the name of the package of <code>type</code> equals
+     *             <code>null</code></li>
+     *             </ul>
+     */
     public static void putTypeIntoImports(final GeneratedType parentGenType, final Type type,
             final Map<String, String> imports) {
         if (parentGenType == null) {
@@ -140,6 +182,27 @@ public final class GeneratorUtil {
         }
     }
 
+    /**
+     * Checks if the constant with the name <code>constName</code> is in the
+     * list of the constant definition for <code>genTO</code>.
+     * 
+     * @param constName
+     *            string with the name of constant which is sought
+     * @param genTO
+     *            generated transfer object in which is <code>constName</code>
+     *            sought
+     * @return boolean value
+     *         <ul>
+     *         <li>true - if <code>constName</code> is in the list of the
+     *         constant definition for <code>genTO</code></li>
+     *         <li>false - in other cases</li>
+     *         </ul>
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>constName</code> equals <code>null</code></li>
+     *             <li>if <code>genTO</code> equals <code>null</code></li>
+     *             </ul>
+     */
     public static boolean isConstantInTO(String constName, GeneratedTransferObject genTO) {
         if (constName == null || genTO == null)
             throw new IllegalArgumentException();
@@ -153,6 +216,16 @@ public final class GeneratorUtil {
         return false;
     }
 
+    /**
+     * Creates the map which maps the type name to package name and contains
+     * only package names for enclosed types of <code>genType</code> and
+     * recursivelly their enclosed types.
+     * 
+     * @param genType
+     *            JAVA <code>Type</code> for which is the map created
+     * @return map of the package names for all the enclosed types and
+     *         recursivelly their enclosed types
+     */
     public static Map<String, String> createChildImports(GeneratedType genType) {
         Map<String, String> childImports = new LinkedHashMap<>();
         List<GeneratedType> childGeneratedTypes = genType.getEnclosedTypes();
@@ -165,7 +238,32 @@ public final class GeneratorUtil {
         return childImports;
     }
 
-    public static String getExplicitType(final GeneratedType parentGenType, final Type type, final Map<String, String> imports) {
+    /**
+     * Builds the string which contains either the full path to the type
+     * (package name with type) or only type name if the package is among
+     * <code>imports</code>.
+     * 
+     * @param parentGenType
+     *            generated type which contains <code>type</code>
+     * @param type
+     *            JAVA <code>Type</code> for which is the string with type info
+     *            generated
+     * @param imports
+     *            map of necessary imports for <code>parentGenType</code>
+     * @return string with type name for <code>type</code> in the full format or
+     *         in the short format
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if the <code>type</code> equals <code>null</code></li>
+     *             <li>if the name of the <code>type</code> equals
+     *             <code>null</code></li>
+     *             <li>if the name of the package of the <code>type</code>
+     *             equals <code>null</code></li>
+     *             <li>if the <code>imports</code> equals <code>null</code></li>
+     *             </ul>
+     */
+    public static String getExplicitType(final GeneratedType parentGenType, final Type type,
+            final Map<String, String> imports) {
         if (type == null) {
             throw new IllegalArgumentException("Type parameter MUST be specified and cannot be NULL!");
         }
@@ -220,7 +318,20 @@ public final class GeneratorUtil {
         }
     }
 
-    private static String getParameters(final GeneratedType parentGenType, final Type[] pTypes, Map<String, String> availableImports) {
+    /**
+     * Generates the string with all actual type parameters from
+     * <code>pTypes</code>
+     * 
+     * @param parentGenType
+     *            generated type for which is the JAVA code generated
+     * @param pTypes
+     *            array of <code>Type</code> instances = actual type parameters
+     * @param availableImports
+     *            map of imports for <code>parentGenType</code>
+     * @return string with all actual type parameters from <code>pTypes</code>
+     */
+    private static String getParameters(final GeneratedType parentGenType, final Type[] pTypes,
+            Map<String, String> availableImports) {
         final StringBuilder builder = new StringBuilder();
         for (int i = 0; i < pTypes.length; i++) {
             final Type t = pTypes[i];
@@ -247,15 +358,16 @@ public final class GeneratorUtil {
     }
 
     /**
-     * The method returns reference to highest (top parent) Generated Transfer
-     * Object.
-     *
+     * Returns the reference to highest (top parent) Generated Transfer Object.
+     * 
      * @param childTransportObject
      *            is generated transfer object which can be extended by other
      *            generated transfer object
      * @return in first case that <code>childTransportObject</code> isn't
      *         extended then <code>childTransportObject</code> is returned. In
      *         second case the method is recursive called until first case.
+     * @throws IllegalArgumentException
+     *             if <code>childTransportObject</code> equals <code>null</code>
      */
     public static GeneratedTransferObject getTopParrentTransportObject(GeneratedTransferObject childTransportObject) {
         if (childTransportObject == null) {
@@ -269,11 +381,11 @@ public final class GeneratorUtil {
     }
 
     /**
-     * The method selects from input list of properties only those which have
-     * read only attribute set to true.
-     *
+     * Selects from input list of properties only those which have read only
+     * attribute set to true.
+     * 
      * @param properties
-     *            contains list of properties of generated transfer object
+     *            list of properties of generated transfer object
      * @return subset of <code>properties</code> which have read only attribute
      *         set to true
      */
@@ -290,12 +402,14 @@ public final class GeneratorUtil {
     }
 
     /**
-     * The method returns the list of the properties of all extending generated
+     * Returns the list of the read only properties of all extending generated
      * transfer object from <code>genTO</code> to highest parent generated
      * transfer object
-     *
+     * 
      * @param genTO
-     * @return the list of all properties from actual to highest parent
+     *            generated transfer object for which is the list of read only
+     *            properties generated
+     * @return list of all read only properties from actual to highest parent
      *         generated transfer object. In case when extension exists the
      *         method is recursive called.
      */
index c2f610d8dbdcdd5a7e3dbcdc7c1b27d45fc93338..3f03b36e4230264cf5ed43e0fccae440943783fe 100644 (file)
@@ -1,37 +1,48 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.java.api.generator;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-\r
-public final class InterfaceGenerator implements CodeGenerator {\r
-\r
-    @Override\r
-    public boolean isAcceptable(Type type) {\r
-        return type instanceof GeneratedType && !(type instanceof GeneratedTransferObject);\r
-    }\r
-\r
-    @Override\r
-    public String generate(Type type) {\r
-        if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
-            final GeneratedType genType = (GeneratedType) type;\r
-            final InterfaceTemplate interfaceTemplate = new InterfaceTemplate(genType);\r
-            return interfaceTemplate.generate();\r
-        }\r
-        return "";\r
-    }\r
-\r
-    @Override\r
-    public String getUnitName(Type type) {\r
-        return type.getName();\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.sal.java.api.generator;
+
+/**
+ * 
+ * Transformator of the data from the virtual form to JAVA source code. The result source code represents JAVA interface. For
+ * generating of the source code is used the template written in XTEND language.
+ * 
+ */
+import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+public final class InterfaceGenerator implements CodeGenerator {
+
+    @Override
+    public boolean isAcceptable(Type type) {
+        return type instanceof GeneratedType && !(type instanceof GeneratedTransferObject);
+    }
+
+    /**
+     * Generates JAVA source code for generated type <code>Type</code>. The code
+     * is generated according to the template source code template which is
+     * written in XTEND language.
+     */
+    @Override
+    public String generate(Type type) {
+        if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            final GeneratedType genType = (GeneratedType) type;
+            final InterfaceTemplate interfaceTemplate = new InterfaceTemplate(genType);
+            return interfaceTemplate.generate();
+        }
+        return "";
+    }
+
+    @Override
+    public String getUnitName(Type type) {
+        return type.getName();
+    }
+
+}
index ce3a91ba7446c88315c4b8194686d9161a734394..d49edf9f5ee503932ac18c363d5d6eb5e2b660a9 100644 (file)
@@ -10,16 +10,47 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature
 import org.opendaylight.yangtools.sal.binding.model.api.Type
 import java.util.LinkedHashMap
-
+/**
+ * Template for generating JAVA interfaces. 
+ */
 class InterfaceTemplate {
     
+    /**
+     * Generated type which is transformed to interface JAVA file.
+     */
     val GeneratedType genType
+    
+    /**
+     * Map of imports for this <code>genTO</code>.
+     */
     val Map<String, String> imports
+    
+    /**
+     * List of constant instances which are generated as JAVA public static final attributes.
+     */
     val List<Constant> consts
+    
+    /**
+     * List of method signatures which are generated as method declarations.
+     */
     val List<MethodSignature> methods
+    
+    /**
+     * List of enumeration which are generated as JAVA enum type.
+     */
     val List<Enumeration> enums
+    
+    /**
+     * List of generated types which are enclosed inside <code>genType</code>
+     */
     val List<GeneratedType> enclosedGeneratedTypes
     
+    /**
+     * Creates the instance of this class which is used for generating the interface file source 
+     * code from <code>genType</code>.
+     * 
+     * @throws IllegalArgumentException if <code>genType</code> equals <code>null</code>
+     */
     new(GeneratedType genType) {
         if (genType == null) {
             throw new IllegalArgumentException("Generated type reference cannot be NULL!")
@@ -33,12 +64,22 @@ class InterfaceTemplate {
         enclosedGeneratedTypes = genType.enclosedTypes
     }
     
+    /**
+     * Generates the source code for interface with package name, imports and interface body.
+     * 
+     * @return string with the code for the interface file in JAVA format
+     */
     def String generate() {
         val body = generateBody
         val pkgAndImports = generatePkgAndImports
         return pkgAndImports.toString + body.toString
     }
     
+    /**
+     * Template method which generate the whole body of the interface.
+     * 
+     * @return string with code for interface body in JAVA format
+     */
     def private generateBody() '''
         «genType.comment.generateComment»
         «generateIfcDeclaration» {
@@ -55,6 +96,13 @@ class InterfaceTemplate {
         
     '''
     
+    /**
+     * Template method which generates JAVA comment.
+     * 
+     * @param comment 
+     * string with the comment for whole JAVA interface
+     * @return string with comment in JAVA format
+     */
     def private generateComment(String comment) '''
         «IF comment != null && !comment.empty»
             /*
@@ -63,6 +111,11 @@ class InterfaceTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates the interface name declaration.
+     * 
+     * @return string with the code for the interface declaration in JAVA format
+     */
     def private generateIfcDeclaration() '''
         public interface «genType.name»«
         IF (!genType.implements.empty)»«
@@ -73,6 +126,11 @@ class InterfaceTemplate {
         ENDIF
     »'''
     
+    /**
+     * Template method which generates inner classes inside this interface.
+     * 
+     * @return string with the source code for inner classes in JAVA format
+     */
     def private generateInnerClasses() '''
         «IF !enclosedGeneratedTypes.empty»
             «FOR innerClass : enclosedGeneratedTypes SEPARATOR "\n"»
@@ -83,7 +141,12 @@ class InterfaceTemplate {
             «ENDFOR»
         «ENDIF»
     '''
-    
+
+    /**
+     * Template method which generates JAVA enum type.
+     * 
+     * @return string with inner enum source code in JAVA format
+     */    
     def private generateEnums() '''
         «IF !enums.empty»
             «FOR e : enums SEPARATOR "\n"»
@@ -93,6 +156,11 @@ class InterfaceTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method wich generates JAVA constants.
+     * 
+     * @return string with constants in JAVA format 
+     */    
     def private generateConstants() '''
         «IF !consts.empty»
             «FOR c : consts»
@@ -102,7 +170,12 @@ class InterfaceTemplate {
             «ENDFOR»
         «ENDIF»
     '''
-    
+
+    /**
+     * Template method which generates the declaration of the methods.
+     * 
+     * @return string with the declaration of methods source code in JAVA format 
+     */    
     def private generateMethods() '''
         «IF !methods.empty»
             «FOR m : methods SEPARATOR "\n"»
@@ -112,6 +185,13 @@ class InterfaceTemplate {
         «ENDIF»
     '''
     
+    /**
+     * Template method which generates method parameters with their types from <code>parameters</code>.
+     * 
+     * @param parameters
+     * list of parameter instances which are transformed to the method parameters
+     * @return string with the list of the method parameters with their types in JAVA format
+     */
     def private generateParameters(List<MethodSignature.Parameter> parameters) '''«
         IF !parameters.empty»«
             FOR parameter : parameters SEPARATOR ", "»«
@@ -120,18 +200,13 @@ class InterfaceTemplate {
         ENDIF
     »'''
     
-    def private generatePkgAndImports() '''
-        package «genType.packageName»;
-        
-        
-        «IF !imports.empty»
-            «FOR entry : resolveImports.entrySet»
-                import «entry.value».«entry.key»;
-            «ENDFOR»
-        «ENDIF»
-        
-    '''
-    
+
+    /**
+     * Template method which generates the map of all the required imports for and imports 
+     * from extended type (and recursivelly so on).
+     * 
+     * @return map which maps type name to package name   
+     */
     def private Map<String, String> resolveImports() {
         val innerTypeImports = GeneratorUtil.createChildImports(genType)
         val Map<String, String> resolvedImports = new LinkedHashMap
@@ -145,6 +220,29 @@ class InterfaceTemplate {
         return resolvedImports
     }
     
+    /**
+     * Template method which generate package name line and import lines.
+     * 
+     * @result string with package and import lines in JAVA format
+     */    
+    def private generatePkgAndImports() '''
+        package «genType.packageName»;
+        
+        
+        «IF !imports.empty»
+            «FOR entry : resolveImports.entrySet»
+                import «entry.value».«entry.key»;
+            «ENDFOR»
+        «ENDIF»
+        
+    '''    
+    
+    /**
+     * Adds package to imports if it is necessary and returns necessary type name (with or without package name)
+     *  
+     * @param type JAVA <code>Type</code> 
+     * @return string with the type name (with or without package name)
+     */      
     def private resolveName(Type type) {
         GeneratorUtil.putTypeIntoImports(genType, type, imports);
         GeneratorUtil.getExplicitType(genType, type, imports)
index 230fb3b89002b94d18e33864e35df6a8797d9203..0299b1b64499d1dce5b082b9f5edb2f0b09ddddc 100644 (file)
@@ -1,36 +1,48 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.java.api.generator;\r
-\r
-import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
-\r
-public final class TOGenerator implements CodeGenerator {\r
-\r
-    @Override\r
-    public String generate(Type type) {\r
-        if (type instanceof GeneratedTransferObject) {\r
-            final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
-            final ClassTemplate template = new ClassTemplate(genTO);\r
-            return template.generate();\r
-        }\r
-        return "";\r
-    }\r
-\r
-    @Override\r
-    public boolean isAcceptable(Type type) {\r
-        return type instanceof GeneratedTransferObject;\r
-    }\r
-\r
-    @Override\r
-    public String getUnitName(Type type) {\r
-        return type.getName();\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.sal.java.api.generator;
+
+import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+/**
+ * 
+ * Transformator of the data from the virtual form to JAVA source code. The
+ * result source code represents JAVA class. For generating of the source code
+ * is used the template written in XTEND language.
+ * 
+ */
+public final class TOGenerator implements CodeGenerator {
+
+    /**
+     * Generates JAVA source code for generated type <code>Type</code>. The code
+     * is generated according to the template source code template which is
+     * written in XTEND language.
+     */
+    @Override
+    public String generate(Type type) {
+        if (type instanceof GeneratedTransferObject) {
+            final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+            final ClassTemplate template = new ClassTemplate(genTO);
+            return template.generate();
+        }
+        return "";
+    }
+
+    @Override
+    public boolean isAcceptable(Type type) {
+        return type instanceof GeneratedTransferObject;
+    }
+
+    @Override
+    public String getUnitName(Type type) {
+        return type.getName();
+    }
+
+}
index df6a5f6ebbe04d052f33951e7557afc53abc0896..e0dff52be93cf7c24ef1ccf464d1a40db22712d0 100644 (file)
@@ -1,37 +1,51 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.sal.binding.model.api;\r
-\r
-import java.io.IOException;\r
-\r
-/**\r
- *\r
- *\r
- */\r
-public interface CodeGenerator {\r
-\r
-    /**\r
-     * @param type Input type to be processed\r
-     * @return generated code\r
-     * @throws IOException\r
-     */\r
-    String generate(Type type);\r
-\r
-    /**\r
-     * @param type Input type to be processed\r
-     * @return true if type is acceptable for processing.\r
-     */\r
-    boolean isAcceptable(Type type);\r
-\r
-    /**\r
-     * @param type Input type to be processed\r
-     * @return name of generated unit\r
-     */\r
-    String getUnitName(Type type);\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.sal.binding.model.api;
+
+import java.io.IOException;
+
+/**
+ * Transformates virtual data to the concrete code in programming language.
+ * 
+ */
+public interface CodeGenerator {
+
+    /**
+     * Generates code for <code>type</code>.
+     * 
+     * @param type
+     *            Input type to be processed
+     * @return generated JAVA code
+     * @throws IOException
+     */
+    String generate(Type type);
+
+    /**
+     * Checks if the concrete instance of <code>type</code> fit to concrete
+     * implementation of this interface.
+     * 
+     * (e. g. method return true if in <code>EnumGenerator</code> (which
+     * implements this interface) has input parameter of type Enumeration (which
+     * is subtype of Type)
+     * 
+     * @param type
+     *            Input type to be processed
+     * @return true if type is acceptable for processing.
+     */
+    boolean isAcceptable(Type type);
+
+    /**
+     * Returns name of <code>type</code> parameter.
+     * 
+     * @param type
+     *            Input type to be processed
+     * @return name of generated unit
+     */
+    String getUnitName(Type type);
+
+}
index 1bc2f76057801efcb5d0f7b127263eaf79f2346d..7d5054a2276d77623868ea2d5e0c92167db9a2c3 100644 (file)
@@ -10,41 +10,53 @@ package org.opendaylight.yangtools.sal.binding.model.api;
 import java.util.List;
 
 /**
- *
+ * Interface provide methods for reading data of enumeration class.
  */
 public interface Enumeration extends Type {
 
     /**
-     *
-     * @return
+     * 
+     * Returns list of annotation definitions associated with enumeration type.
+     * 
+     * @return list of annotation definitions associated with enumeration type.
+     * 
      */
     public List<AnnotationType> getAnnotations();
 
-    /**
-     *
-     * @return
-     */
     public Type getDefiningType();
 
     /**
-     *
-     * @return
+     * Returns list of the couples - name and value.
+     * 
+     * @return list of the enumeration pairs.
      */
     public List<Pair> getValues();
 
     /**
-     *
-     * @return
+     * Formats enumeration according to rules of the programming language.
+     * 
+     * @return string with source code in some programming language
      */
     public String toFormattedString();
 
     /**
-     *
+     * Interface is used for reading enumeration item. It means item's name and
+     * its value.
      */
     interface Pair {
 
+        /**
+         * Returns the name of the enumeration item.
+         * 
+         * @return the name of the enumeration item.
+         */
         public String getName();
 
+        /**
+         * Returns value of the enumeration item.
+         * 
+         * @return the value of the enumeration item.
+         */
         public Integer getValue();
     }
 }
index eeafccd48c3dc99bc8019599d6219f0f81b50a4d..094b85738a677ebf9839f1d2bb78686f31d2a951 100644 (file)
@@ -1,5 +1,11 @@
 package org.opendaylight.yangtools.sal.binding.model.api;
 
-public interface WildcardType extends Type  {
+/**
+ * 
+ * Marker interface which assign to object property that it is bounded wildcard
+ * type.
+ * 
+ */
+public interface WildcardType extends Type {
 
 }