Fixing sonar issues 4 44/1144/3
authorJozef Gloncak <jgloncak@cisco.com>
Tue, 10 Sep 2013 06:23:14 +0000 (08:23 +0200)
committerJozef Gloncak <jgloncak@cisco.com>
Tue, 10 Sep 2013 12:18:29 +0000 (14:18 +0200)
+ unit test Int8Test.java for Int8.java was added

Change-Id: Ia89f741fd46be332a8e212352798eff47eb6215c
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
55 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.xtend
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/AbstractNodeTO.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/CompositeNodeTOImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/MutableSimpleNodeTOImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/NodeModificationBuilderImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/NodeUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/NodeModificationBuilderImplTest.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesMojo.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java
yang/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/GenerateSourcesTest.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/AugmentationSchema.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Deviation.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ExtensionDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ListSchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/RevisionAwareXPath.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/EnumTypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/IdentityTypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/InstanceIdentifierTypeDefinition.java
yang/yang-model-util/.gitignore [new file with mode: 0644]
yang/yang-model-util/pom.xml
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSignedInteger.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractUnsignedInteger.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseConstraints.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BinaryType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BitsType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BooleanType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Decimal64.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EmptyType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EnumerationType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/IdentityrefType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/InstanceIdentifier.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int16.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int32.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int64.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int8.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RevisionAwareXPathImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/StringType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint16.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint32.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint64.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint8.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/UnionType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/UnknownType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/YangTypesConverter.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/Int8Test.java [new file with mode: 0644]
yang/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/model/parser/api/YangModelParser.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/Comparators.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/RefineUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/TypesResolutionTest.java

index 838406c545e718f984dfbc0df70b96f34ba2da7a..364785dede5fbf0a198a59dce14754f6517d912d 100644 (file)
@@ -53,7 +53,6 @@ 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.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;
 import static com.google.common.base.Preconditions.*;
@@ -62,28 +61,29 @@ import static org.opendaylight.yangtools.binding.generator.util.BindingGenerator
 import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.*;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;
 import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 
 public 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;
+       private Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders;
 
-    /**
+       /**
      * Provide methods for converting YANG types to JAVA types.
      */
-    private var TypeProvider typeProvider;
+       private var TypeProvider typeProvider;
 
-    /**
+       /**
      * Holds reference to schema context to resolve data of augmented elemnt
      * when creating augmentation builder
      */
-    private var SchemaContext schemaContext;
+       private var 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
@@ -91,21 +91,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * Schema node the object of type <code>Type</code> is required. So in this
      * case is used this map.
      */
-    private val allGroupings = new HashMap<SchemaPath, GeneratedType>();
+       private val allGroupings = new HashMap<SchemaPath, GeneratedType>();
 
-    private val yangToJavaMapping = new HashMap<SchemaPath, Type>();
+       private val yangToJavaMapping = new HashMap<SchemaPath, Type>();
 
-    /**
+       /**
      * Constant with the concrete name of namespace.
      */
-    private val static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";
+       private val static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";
 
-    /**
+       /**
      * Constant with the concrete name of identifier.
      */
-    private val static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";
+       private val static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";
 
-    /**
+       /**
      * Resolves generated types from <code>context</code> schema nodes of all
      * modules.
      *
@@ -123,17 +123,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @throws IllegalStateException
      *             if <code>context</code> contain no modules
      */
-    override generateTypes(SchemaContext context) {
-        checkArgument(context !== null, "Schema Context reference cannot be NULL.");
-        checkState(context.modules !== null, "Schema Context does not contain defined modules.");
-        val List<Type> generatedTypes = new ArrayList();
-        schemaContext = context;
-        typeProvider = new TypeProviderImpl(context);
-        val Set<Module> modules = context.modules;
-        return generateTypes(context, modules);
-    }
-
-    /**
+       override generateTypes(SchemaContext context) {
+               checkArgument(context !== null, "Schema Context reference cannot be NULL.");
+               checkState(context.modules !== null, "Schema Context does not contain defined modules.");
+               val List<Type> generatedTypes = new ArrayList();
+               schemaContext = context;
+               typeProvider = new TypeProviderImpl(context);
+               val Set<Module> modules = context.modules;
+               return generateTypes(context, modules);
+       }
+
+       /**
      * Resolves generated types from <code>context</code> schema nodes only for
      * modules specified in <code>modules</code>
      *
@@ -161,47 +161,47 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @throws IllegalStateException
      *             if <code>context</code> contain no modules
      */
-    override generateTypes(SchemaContext context, Set<Module> modules) {
-        checkArgument(context !== null, "Schema Context reference cannot be NULL.");
-        checkState(context.modules !== null, "Schema Context does not contain defined modules.");
-        checkArgument(modules !== null, "Set of Modules cannot be NULL.");
-
-        val List<Type> filteredGenTypes = new ArrayList();
-
-        schemaContext = context;
-        typeProvider = new TypeProviderImpl(context);
-        val contextModules = ModuleDependencySort.sort(context.modules);
-        genTypeBuilders = new HashMap();
-
-        for (contextModule : contextModules) {
-            val List<Type> generatedTypes = new ArrayList();
-            generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));
-            generatedTypes.addAll(allGroupingsToGenTypes(contextModule));
-            if (false == contextModule.childNodes.isEmpty()) {
-                generatedTypes.add(moduleToDataType(contextModule));
-            }
-            generatedTypes.addAll(allContainersToGenTypes(contextModule));
-            generatedTypes.addAll(allListsToGenTypes(contextModule));
-            generatedTypes.addAll(allChoicesToGenTypes(contextModule));
-            generatedTypes.addAll(allRPCMethodsToGenType(contextModule));
-            generatedTypes.addAll(allNotificationsToGenType(contextModule));
-            generatedTypes.addAll(allIdentitiesToGenTypes(contextModule, context));
-
-            if (modules.contains(contextModule)) {
-                filteredGenTypes.addAll(generatedTypes);
-            }
-        }
-        for (contextModule : contextModules) {
-            val generatedTypes = (allAugmentsToGenTypes(contextModule));
-            if (modules.contains(contextModule)) {
-                filteredGenTypes.addAll(generatedTypes);
-            }
-
-        }
-        return filteredGenTypes;
-    }
-
-    /**
+       override generateTypes(SchemaContext context, Set<Module> modules) {
+               checkArgument(context !== null, "Schema Context reference cannot be NULL.");
+               checkState(context.modules !== null, "Schema Context does not contain defined modules.");
+               checkArgument(modules !== null, "Set of Modules cannot be NULL.");
+
+               val List<Type> filteredGenTypes = new ArrayList();
+
+               schemaContext = context;
+               typeProvider = new TypeProviderImpl(context);
+               val contextModules = ModuleDependencySort.sort(context.modules);
+               genTypeBuilders = new HashMap();
+
+               for (contextModule : contextModules) {
+                       val List<Type> generatedTypes = new ArrayList();
+                       generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));
+                       generatedTypes.addAll(allGroupingsToGenTypes(contextModule));
+                       if (false == contextModule.childNodes.isEmpty()) {
+                               generatedTypes.add(moduleToDataType(contextModule));
+                       }
+                       generatedTypes.addAll(allContainersToGenTypes(contextModule));
+                       generatedTypes.addAll(allListsToGenTypes(contextModule));
+                       generatedTypes.addAll(allChoicesToGenTypes(contextModule));
+                       generatedTypes.addAll(allRPCMethodsToGenType(contextModule));
+                       generatedTypes.addAll(allNotificationsToGenType(contextModule));
+                       generatedTypes.addAll(allIdentitiesToGenTypes(contextModule, context));
+
+                       if (modules.contains(contextModule)) {
+                               filteredGenTypes.addAll(generatedTypes);
+                       }
+               }
+               for (contextModule : contextModules) {
+                       val generatedTypes = (allAugmentsToGenTypes(contextModule));
+                       if (modules.contains(contextModule)) {
+                               filteredGenTypes.addAll(generatedTypes);
+                       }
+
+               }
+               return filteredGenTypes;
+       }
+
+       /**
      * Converts all extended type definitions of module to the list of
      * <code>Type</code> objects.
      *
@@ -217,25 +217,25 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<Type> allTypeDefinitionsToGenTypes(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-        val Set<TypeDefinition<?>> typeDefinitions = module.typeDefinitions;
-        checkState(typeDefinitions !== null, '''Type Definitions for module Â«module.name» cannot be NULL.''');
-
-        val List<Type> generatedTypes = new ArrayList();
-        for (TypeDefinition<?> typedef : typeDefinitions) {
-            if (typedef !== null) {
-                val type = (typeProvider as TypeProviderImpl).generatedTypeForExtendedDefinitionType(typedef, typedef);
-                if ((type !== null) && !generatedTypes.contains(type)) {
-                    generatedTypes.add(type);
-                }
-            }
-        }
-        return generatedTypes;
-    }
-
-    /**
+       private def List<Type> allTypeDefinitionsToGenTypes(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+               val Set<TypeDefinition<?>> typeDefinitions = module.typeDefinitions;
+               checkState(typeDefinitions !== null, '''Type Definitions for module Â«module.name» cannot be NULL.''');
+
+               val List<Type> generatedTypes = new ArrayList();
+               for (TypeDefinition<?> typedef : typeDefinitions) {
+                       if (typedef !== null) {
+                               val type = (typeProvider as TypeProviderImpl).generatedTypeForExtendedDefinitionType(typedef, 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.
      *
@@ -252,29 +252,29 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<Type> allContainersToGenTypes(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-
-        if (module.childNodes === null) {
-            throw new IllegalArgumentException(
-                "Reference to Set of Child Nodes in module " + module.name + " cannot be NULL.");
-        }
-
-        val List<Type> generatedTypes = new ArrayList();
-        val it = new DataNodeIterator(module);
-        val List<ContainerSchemaNode> schemaContainers = it.allContainers();
-        val basePackageName = moduleNamespaceToPackageName(module);
-        for (container : schemaContainers) {
-            if (!container.isAddedByUses()) {
-                generatedTypes.add(containerToGenType(basePackageName, container));
-            }
-        }
-        return generatedTypes;
-    }
-
-    /**
+       private def List<Type> allContainersToGenTypes(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+
+               if (module.childNodes === null) {
+                       throw new IllegalArgumentException(
+                               "Reference to Set of Child Nodes in module " + module.name + " cannot be NULL.");
+               }
+
+               val List<Type> generatedTypes = new ArrayList();
+               val it = new DataNodeIterator(module);
+               val List<ContainerSchemaNode> schemaContainers = it.allContainers();
+               val basePackageName = moduleNamespaceToPackageName(module);
+               for (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.
      *
@@ -291,30 +291,30 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<Type> allListsToGenTypes(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-
-        if (module.childNodes === null) {
-            throw new IllegalArgumentException(
-                "Reference to Set of Child Nodes in module " + module.name + " cannot be NULL.");
-        }
-
-        val List<Type> generatedTypes = new ArrayList();
-        val it = new DataNodeIterator(module);
-        val List<ListSchemaNode> schemaLists = it.allLists();
-        val basePackageName = moduleNamespaceToPackageName(module);
-        if (schemaLists !== null) {
-            for (list : schemaLists) {
-                if (!list.isAddedByUses()) {
-                    generatedTypes.addAll(listToGenType(basePackageName, list));
-                }
-            }
-        }
-        return generatedTypes;
-    }
-
-    /**
+       private def List<Type> allListsToGenTypes(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+
+               if (module.childNodes === null) {
+                       throw new IllegalArgumentException(
+                               "Reference to Set of Child Nodes in module " + module.name + " cannot be NULL.");
+               }
+
+               val List<Type> generatedTypes = new ArrayList();
+               val it = new DataNodeIterator(module);
+               val List<ListSchemaNode> schemaLists = it.allLists();
+               val basePackageName = moduleNamespaceToPackageName(module);
+               if (schemaLists !== null) {
+                       for (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.
      *
@@ -330,24 +330,24 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<GeneratedType> allChoicesToGenTypes(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-
-        val it = new DataNodeIterator(module);
-        val choiceNodes = it.allChoices();
-        val basePackageName = moduleNamespaceToPackageName(module);
-
-        val List<GeneratedType> generatedTypes = new ArrayList();
-        for (choice : choiceNodes) {
-            if ((choice !== null) && !choice.isAddedByUses()) {
-                generatedTypes.addAll(choiceToGeneratedType(basePackageName, choice));
-            }
-        }
-        return generatedTypes;
-    }
-
-    /**
+       private def List<GeneratedType> allChoicesToGenTypes(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+
+               val it = new DataNodeIterator(module);
+               val choiceNodes = it.allChoices();
+               val basePackageName = moduleNamespaceToPackageName(module);
+
+               val List<GeneratedType> generatedTypes = new ArrayList();
+               for (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.
      *
@@ -364,24 +364,24 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<Type> allAugmentsToGenTypes(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-        if (module.childNodes === null) {
-            throw new IllegalArgumentException(
-                "Reference to Set of Augmentation Definitions in module " + module.name + " cannot be NULL.");
-        }
-
-        val List<Type> generatedTypes = new ArrayList();
-        val basePackageName = moduleNamespaceToPackageName(module);
-        val List<AugmentationSchema> augmentations = resolveAugmentations(module);
-        for (augment : augmentations) {
-            generatedTypes.addAll(augmentationToGenTypes(basePackageName, augment));
-        }
-        return generatedTypes;
-    }
-
-    /**
+       private def List<Type> allAugmentsToGenTypes(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+               if (module.childNodes === null) {
+                       throw new IllegalArgumentException(
+                               "Reference to Set of Augmentation Definitions in module " + module.name + " cannot be NULL.");
+               }
+
+               val List<Type> generatedTypes = new ArrayList();
+               val basePackageName = moduleNamespaceToPackageName(module);
+               val List<AugmentationSchema> augmentations = resolveAugmentations(module);
+               for (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.
@@ -397,25 +397,25 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<AugmentationSchema> resolveAugmentations(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-        checkState(module.augmentations !== null, "Augmentations Set cannot be NULL.");
-
-        val Set<AugmentationSchema> augmentations = module.augmentations;
-        val List<AugmentationSchema> sortedAugmentations = new ArrayList(augmentations);
-        Collections.sort(sortedAugmentations,
-            [ augSchema1, augSchema2 |
-                if (augSchema1.targetPath.path.size() > augSchema2.targetPath.path.size()) {
-                    return 1;
-                } else if (augSchema1.targetPath.path.size() < augSchema2.targetPath.path.size()) {
-                    return -1;
-                }
-                return 0;
-            ]);
-        return sortedAugmentations;
-    }
-
-    /**
+       private def List<AugmentationSchema> resolveAugmentations(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+               checkState(module.augmentations !== null, "Augmentations Set cannot be NULL.");
+
+               val Set<AugmentationSchema> augmentations = module.augmentations;
+               val List<AugmentationSchema> sortedAugmentations = new ArrayList(augmentations);
+               Collections.sort(sortedAugmentations,
+                       [ augSchema1, augSchema2 |
+                               if (augSchema1.targetPath.path.size() > augSchema2.targetPath.path.size()) {
+                                       return 1;
+                               } else if (augSchema1.targetPath.path.size() < augSchema2.targetPath.path.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 vally
      * obtained reference to <code>GeneratedType</code> object.
@@ -429,22 +429,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             if the module equals null
      *
      */
-    private def GeneratedType moduleToDataType(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-
-        val moduleDataTypeBuilder = moduleTypeBuilder(module, "Data");
-        addImplementedInterfaceFromUses(module, moduleDataTypeBuilder);
-        moduleDataTypeBuilder.addImplementsType(DATA_ROOT);
-
-        val basePackageName = moduleNamespaceToPackageName(module);
-        if (moduleDataTypeBuilder !== null) {
-            val Set<DataSchemaNode> dataNodes = module.childNodes;
-            resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder, dataNodes);
-        }
-        return moduleDataTypeBuilder.toInstance();
-    }
-
-    /**
+       private def GeneratedType moduleToDataType(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+
+               val moduleDataTypeBuilder = moduleTypeBuilder(module, "Data");
+               addImplementedInterfaceFromUses(module, moduleDataTypeBuilder);
+               moduleDataTypeBuilder.addImplementsType(DATA_ROOT);
+
+               val basePackageName = moduleNamespaceToPackageName(module);
+               if (moduleDataTypeBuilder !== null) {
+                       val Set<DataSchemaNode> dataNodes = module.childNodes;
+                       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.
@@ -462,91 +462,91 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<Type> allRPCMethodsToGenType(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-
-        if (module.childNodes === null) {
-            throw new IllegalArgumentException(
-                "Reference to Set of RPC Method Definitions in module " + module.name + " cannot be NULL.");
-        }
-
-        val basePackageName = moduleNamespaceToPackageName(module);
-        val Set<RpcDefinition> rpcDefinitions = module.rpcs;
-
-        if (rpcDefinitions.isEmpty()) {
-            return Collections.emptyList();
-        }
-
-        val List<Type> genRPCTypes = new ArrayList();
-        val interfaceBuilder = moduleTypeBuilder(module, "Service");
-        interfaceBuilder.addImplementsType(Types.typeForClass(RpcService));
-        for (rpc : rpcDefinitions) {
-            if (rpc !== null) {
-
-                val rpcName = parseToClassName(rpc.QName.localName);
-                val rpcMethodName = parseToValidParamName(rpcName);
-                val method = interfaceBuilder.addMethod(rpcMethodName);
-
-                val rpcInOut = new ArrayList();
-
-                val input = rpc.input;
-                val output = rpc.output;
-
-                if (input !== null) {
-                    rpcInOut.add(new DataNodeIterator(input));
-                    val inType = addRawInterfaceDefinition(basePackageName, input, rpcName);
-                    addImplementedInterfaceFromUses(input, inType);
-                    inType.addImplementsType(DATA_OBJECT);
-                    inType.addImplementsType(augmentable(inType));
-                    resolveDataSchemaNodes(basePackageName, inType, input.childNodes);
-                    val inTypeInstance = inType.toInstance();
-                    genRPCTypes.add(inTypeInstance);
-                    method.addParameter(inTypeInstance, "input");
-                }
-
-                var Type outTypeInstance = VOID;
-                if (output !== null) {
-                    rpcInOut.add(new DataNodeIterator(output));
-                    val outType = addRawInterfaceDefinition(basePackageName, output, rpcName);
-                    addImplementedInterfaceFromUses(output, outType);
-                    outType.addImplementsType(DATA_OBJECT);
-                    outType.addImplementsType(augmentable(outType));
-
-                    resolveDataSchemaNodes(basePackageName, outType, output.childNodes);
-                    outTypeInstance = outType.toInstance();
-                    genRPCTypes.add(outTypeInstance);
-
-                }
-
-                val rpcRes = Types.parameterizedTypeFor(Types.typeForClass(RpcResult), outTypeInstance);
-                method.setReturnType(Types.parameterizedTypeFor(FUTURE, rpcRes));
-                for (iter : rpcInOut) {
-                    val List<ContainerSchemaNode> nContainers = iter.allContainers();
-                    if ((nContainers !== null) && !nContainers.isEmpty()) {
-                        for (container : nContainers) {
-                            if (!container.isAddedByUses()) {
-                                genRPCTypes.add(containerToGenType(basePackageName, container));
-                            }
-                        }
-                    }
-                    val List<ListSchemaNode> nLists = iter.allLists();
-                    if ((nLists !== null) && !nLists.isEmpty()) {
-                        for (list : nLists) {
-                            if (!list.isAddedByUses()) {
-                                genRPCTypes.addAll(listToGenType(basePackageName, list));
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        genRPCTypes.add(interfaceBuilder.toInstance());
-        return genRPCTypes;
-    }
-
-    /**
+       private def List<Type> allRPCMethodsToGenType(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+
+               if (module.childNodes === null) {
+                       throw new IllegalArgumentException(
+                               "Reference to Set of RPC Method Definitions in module " + module.name + " cannot be NULL.");
+               }
+
+               val basePackageName = moduleNamespaceToPackageName(module);
+               val Set<RpcDefinition> rpcDefinitions = module.rpcs;
+
+               if (rpcDefinitions.isEmpty()) {
+                       return Collections.emptyList();
+               }
+
+               val List<Type> genRPCTypes = new ArrayList();
+               val interfaceBuilder = moduleTypeBuilder(module, "Service");
+               interfaceBuilder.addImplementsType(Types.typeForClass(RpcService));
+               for (rpc : rpcDefinitions) {
+                       if (rpc !== null) {
+
+                               val rpcName = parseToClassName(rpc.QName.localName);
+                               val rpcMethodName = parseToValidParamName(rpcName);
+                               val method = interfaceBuilder.addMethod(rpcMethodName);
+
+                               val rpcInOut = new ArrayList();
+
+                               val input = rpc.input;
+                               val output = rpc.output;
+
+                               if (input !== null) {
+                                       rpcInOut.add(new DataNodeIterator(input));
+                                       val inType = addRawInterfaceDefinition(basePackageName, input, rpcName);
+                                       addImplementedInterfaceFromUses(input, inType);
+                                       inType.addImplementsType(DATA_OBJECT);
+                                       inType.addImplementsType(augmentable(inType));
+                                       resolveDataSchemaNodes(basePackageName, inType, input.childNodes);
+                                       val inTypeInstance = inType.toInstance();
+                                       genRPCTypes.add(inTypeInstance);
+                                       method.addParameter(inTypeInstance, "input");
+                               }
+
+                               var Type outTypeInstance = VOID;
+                               if (output !== null) {
+                                       rpcInOut.add(new DataNodeIterator(output));
+                                       val outType = addRawInterfaceDefinition(basePackageName, output, rpcName);
+                                       addImplementedInterfaceFromUses(output, outType);
+                                       outType.addImplementsType(DATA_OBJECT);
+                                       outType.addImplementsType(augmentable(outType));
+
+                                       resolveDataSchemaNodes(basePackageName, outType, output.childNodes);
+                                       outTypeInstance = outType.toInstance();
+                                       genRPCTypes.add(outTypeInstance);
+
+                               }
+
+                               val rpcRes = Types.parameterizedTypeFor(Types.typeForClass(RpcResult), outTypeInstance);
+                               method.setReturnType(Types.parameterizedTypeFor(FUTURE, rpcRes));
+                               for (iter : rpcInOut) {
+                                       val List<ContainerSchemaNode> nContainers = iter.allContainers();
+                                       if ((nContainers !== null) && !nContainers.isEmpty()) {
+                                               for (container : nContainers) {
+                                                       if (!container.isAddedByUses()) {
+                                                               genRPCTypes.add(containerToGenType(basePackageName, container));
+                                                       }
+                                               }
+                                       }
+                                       val List<ListSchemaNode> nLists = iter.allLists();
+                                       if ((nLists !== null) && !nLists.isEmpty()) {
+                                               for (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.
@@ -564,59 +564,59 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<Type> allNotificationsToGenType(Module module) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-
-        checkArgument(module.name !== null, "Module name cannot be NULL.");
-
-        if (module.childNodes === null) {
-            throw new IllegalArgumentException(
-                "Reference to Set of Notification Definitions in module " + module.name + " cannot be NULL.");
-        }
-        val notifications = module.notifications;
-        if(notifications.isEmpty()) return Collections.emptyList();
-
-        val listenerInterface = moduleTypeBuilder(module, "Listener");
-        listenerInterface.addImplementsType(BindingTypes.NOTIFICATION_LISTENER);
-
-        val basePackageName = moduleNamespaceToPackageName(module);
-        val List<Type> generatedTypes = new ArrayList();
-
-        for (notification : notifications) {
-            if (notification !== null) {
-                val iter = new DataNodeIterator(notification);
-
-                // Containers
-                for (node : iter.allContainers()) {
-                    if (!node.isAddedByUses()) {
-                        generatedTypes.add(containerToGenType(basePackageName, node));
-                    }
-                }
-
-                // Lists
-                for (node : iter.allLists()) {
-                    if (!node.isAddedByUses()) {
-                        generatedTypes.addAll(listToGenType(basePackageName, node));
-                    }
-                }
-                val notificationInterface = addDefaultInterfaceDefinition(basePackageName, notification);
-                notificationInterface.addImplementsType(NOTIFICATION);
-
-                // Notification object
-                resolveDataSchemaNodes(basePackageName, notificationInterface, notification.childNodes);
-
-                listenerInterface.addMethod("on" + notificationInterface.name) //
-                .setAccessModifier(AccessModifier.PUBLIC).addParameter(notificationInterface, "notification").
-                    setReturnType(Types.VOID);
-
-                generatedTypes.add(notificationInterface.toInstance());
-            }
-        }
-        generatedTypes.add(listenerInterface.toInstance());
-        return generatedTypes;
-    }
-
-    /**
+       private def List<Type> allNotificationsToGenType(Module module) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+
+               checkArgument(module.name !== null, "Module name cannot be NULL.");
+
+               if (module.childNodes === null) {
+                       throw new IllegalArgumentException(
+                               "Reference to Set of Notification Definitions in module " + module.name + " cannot be NULL.");
+               }
+               val notifications = module.notifications;
+               if(notifications.isEmpty()) return Collections.emptyList();
+
+               val listenerInterface = moduleTypeBuilder(module, "Listener");
+               listenerInterface.addImplementsType(BindingTypes.NOTIFICATION_LISTENER);
+
+               val basePackageName = moduleNamespaceToPackageName(module);
+               val List<Type> generatedTypes = new ArrayList();
+
+               for (notification : notifications) {
+                       if (notification !== null) {
+                               val iter = new DataNodeIterator(notification);
+
+                               // Containers
+                               for (node : iter.allContainers()) {
+                                       if (!node.isAddedByUses()) {
+                                               generatedTypes.add(containerToGenType(basePackageName, node));
+                                       }
+                               }
+
+                               // Lists
+                               for (node : iter.allLists()) {
+                                       if (!node.isAddedByUses()) {
+                                               generatedTypes.addAll(listToGenType(basePackageName, node));
+                                       }
+                               }
+                               val notificationInterface = addDefaultInterfaceDefinition(basePackageName, notification);
+                               notificationInterface.addImplementsType(NOTIFICATION);
+
+                               // Notification object
+                               resolveDataSchemaNodes(basePackageName, notificationInterface, notification.childNodes);
+
+                               listenerInterface.addMethod("on" + notificationInterface.name) //
+                               .setAccessModifier(AccessModifier.PUBLIC).addParameter(notificationInterface, "notification").
+                                       setReturnType(Types.VOID);
+
+                               generatedTypes.add(notificationInterface.toInstance());
+                       }
+               }
+               generatedTypes.add(listenerInterface.toInstance());
+               return generatedTypes;
+       }
+
+       /**
      * Converts all <b>identities</b> of the module to the list of
      * <code>Type</code> objects.
      *
@@ -630,22 +630,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         (object of type <code>IdentitySchemaNode</code>
      *
      */
-    private def List<Type> allIdentitiesToGenTypes(Module module, SchemaContext context) {
-        val List<Type> genTypes = new ArrayList();
+       private def List<Type> allIdentitiesToGenTypes(Module module, SchemaContext context) {
+               val List<Type> genTypes = new ArrayList();
 
-        val Set<IdentitySchemaNode> schemaIdentities = module.identities;
+               val Set<IdentitySchemaNode> schemaIdentities = module.identities;
 
-        val basePackageName = moduleNamespaceToPackageName(module);
+               val basePackageName = moduleNamespaceToPackageName(module);
 
-        if (schemaIdentities !== null && !schemaIdentities.isEmpty()) {
-            for (identity : schemaIdentities) {
-                genTypes.add(identityToGenType(basePackageName, identity, context));
-            }
-        }
-        return genTypes;
-    }
+               if (schemaIdentities !== null && !schemaIdentities.isEmpty()) {
+                       for (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.
@@ -665,33 +665,33 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <code>IdentitySchemaNode</code>
      *
      */
-    private def GeneratedType identityToGenType(String basePackageName, IdentitySchemaNode identity,
-        SchemaContext context) {
-        if (identity === null) {
-            return null;
-        }
-
-        val packageName = packageNameForGeneratedType(basePackageName, identity.path);
-        val genTypeName = parseToClassName(identity.QName.localName);
-        val newType = new GeneratedTOBuilderImpl(packageName, genTypeName);
-
-        val baseIdentity = identity.baseIdentity;
-        if (baseIdentity !== null) {
-            val baseIdentityParentModule = SchemaContextUtil.findParentModule(context, baseIdentity);
-
-            val returnTypePkgName = moduleNamespaceToPackageName(baseIdentityParentModule);
-            val returnTypeName = parseToClassName(baseIdentity.QName.localName);
-
-            val gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName).toInstance();
-            newType.setExtendsType(gto);
-        } else {
-            newType.setExtendsType(Types.baseIdentityTO);
-        }
-        newType.setAbstract(true);
-        return newType.toInstance();
-    }
-
-    /**
+       private def GeneratedType identityToGenType(String basePackageName, IdentitySchemaNode identity,
+               SchemaContext context) {
+               if (identity === null) {
+                       return null;
+               }
+
+               val packageName = packageNameForGeneratedType(basePackageName, identity.path);
+               val genTypeName = parseToClassName(identity.QName.localName);
+               val newType = new GeneratedTOBuilderImpl(packageName, genTypeName);
+
+               val baseIdentity = identity.baseIdentity;
+               if (baseIdentity !== null) {
+                       val baseIdentityParentModule = SchemaContextUtil.findParentModule(context, baseIdentity);
+
+                       val returnTypePkgName = moduleNamespaceToPackageName(baseIdentityParentModule);
+                       val returnTypeName = parseToClassName(baseIdentity.QName.localName);
+
+                       val gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName).toInstance();
+                       newType.setExtendsType(gto);
+               } else {
+                       newType.setExtendsType(Types.baseIdentityTO);
+               }
+               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
@@ -705,24 +705,24 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         (object of type <code>GroupingDefinition</code>)
      *
      */
-    private def List<Type> allGroupingsToGenTypes(Module module) {
-        checkArgument(module !== null, "Module parameter can not be null");
-        val List<Type> genTypes = new ArrayList();
-        val basePackageName = moduleNamespaceToPackageName(module);
-        val Set<GroupingDefinition> groupings = module.groupings;
-        val List<GroupingDefinition> groupingsSortedByDependencies = new GroupingDefinitionDependencySort().sort(
-            groupings);
-
-        for (grouping : groupingsSortedByDependencies) {
-            val genType = groupingToGenType(basePackageName, grouping);
-            genTypes.add(genType);
-            val schemaPath = grouping.path;
-            allGroupings.put(schemaPath, genType);
-        }
-        return genTypes;
-    }
-
-    /**
+       private def List<Type> allGroupingsToGenTypes(Module module) {
+               checkArgument(module !== null, "Module parameter can not be null");
+               val List<Type> genTypes = new ArrayList();
+               val basePackageName = moduleNamespaceToPackageName(module);
+               val Set<GroupingDefinition> groupings = module.groupings;
+               val List<GroupingDefinition> groupingsSortedByDependencies = new GroupingDefinitionDependencySort().sort(
+                       groupings);
+
+               for (grouping : groupingsSortedByDependencies) {
+                       val genType = groupingToGenType(basePackageName, grouping);
+                       genTypes.add(genType);
+                       val schemaPath = grouping.path;
+                       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.
@@ -734,20 +734,20 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @return GeneratedType which is generated from grouping (object of type
      *         <code>GroupingDefinition</code>)
      */
-    private def GeneratedType groupingToGenType(String basePackageName, GroupingDefinition grouping) {
-        if (grouping === null) {
-            return null;
-        }
+       private def GeneratedType groupingToGenType(String basePackageName, GroupingDefinition grouping) {
+               if (grouping === null) {
+                       return null;
+               }
 
-        val packageName = packageNameForGeneratedType(basePackageName, grouping.path);
-        val Set<DataSchemaNode> schemaNodes = grouping.childNodes;
-        val typeBuilder = addDefaultInterfaceDefinition(packageName, grouping);
+               val packageName = packageNameForGeneratedType(basePackageName, grouping.path);
+               val Set<DataSchemaNode> schemaNodes = grouping.childNodes;
+               val typeBuilder = addDefaultInterfaceDefinition(packageName, grouping);
 
-        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
-        return typeBuilder.toInstance();
-    }
+               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.
@@ -758,18 +758,18 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @return EnumTypeDefinition if it is found inside
      *         <code>typeDefinition</code> or <code>null</code> in other case
      */
-    private def EnumTypeDefinition enumTypeDefFromExtendedType(TypeDefinition<?> typeDefinition) {
-        if (typeDefinition !== null) {
-            if (typeDefinition.baseType instanceof EnumTypeDefinition) {
-                return typeDefinition.baseType as EnumTypeDefinition;
-            } else if (typeDefinition.baseType instanceof ExtendedType) {
-                return enumTypeDefFromExtendedType(typeDefinition.baseType);
-            }
-        }
-        return null;
-    }
-
-    /**
+       private def EnumTypeDefinition enumTypeDefFromExtendedType(TypeDefinition<?> typeDefinition) {
+               if (typeDefinition !== null) {
+                       if (typeDefinition.baseType instanceof EnumTypeDefinition) {
+                               return typeDefinition.baseType as EnumTypeDefinition;
+                       } else if (typeDefinition.baseType instanceof ExtendedType) {
+                               return enumTypeDefFromExtendedType(typeDefinition.baseType);
+                       }
+               }
+               return null;
+       }
+
+       /**
      * Adds enumeration builder created from <code>enumTypeDef</code> to
      * <code>typeBuilder</code>.
      *
@@ -786,21 +786,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @return enumeration builder which contais data from
      *         <code>enumTypeDef</code>
      */
-    private def EnumBuilder resolveInnerEnumFromTypeDefinition(EnumTypeDefinition enumTypeDef, String enumName,
-        GeneratedTypeBuilder typeBuilder) {
-        if ((enumTypeDef !== null) && (typeBuilder !== null) && (enumTypeDef.QName !== null) &&
-            (enumTypeDef.QName.localName !== null)) {
+       private def EnumBuilder resolveInnerEnumFromTypeDefinition(EnumTypeDefinition enumTypeDef, String enumName,
+               GeneratedTypeBuilder typeBuilder) {
+               if ((enumTypeDef !== null) && (typeBuilder !== null) && (enumTypeDef.QName !== null) &&
+                       (enumTypeDef.QName.localName !== null)) {
 
-            val enumerationName = parseToClassName(enumName);
-            val enumBuilder = typeBuilder.addEnumeration(enumerationName);
-            enumBuilder.updateEnumPairsFromEnumTypeDef(enumTypeDef);
+                       val enumerationName = parseToClassName(enumName);
+                       val enumBuilder = typeBuilder.addEnumeration(enumerationName);
+                       enumBuilder.updateEnumPairsFromEnumTypeDef(enumTypeDef);
 
-            return enumBuilder;
-        }
-        return null;
-    }
+                       return enumBuilder;
+               }
+               return null;
+       }
 
-    /**
+       /**
      * Generates type builder for <code>module</code>.
      *
      * @param module
@@ -814,16 +814,16 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @throws IllegalArgumentException
      *             if <code>module</code> equals null
      */
-    private def GeneratedTypeBuilder moduleTypeBuilder(Module module, String postfix) {
-        checkArgument(module !== null, "Module reference cannot be NULL.");
-        val packageName = moduleNamespaceToPackageName(module);
-        val moduleName = parseToClassName(module.name) + postfix;
+       private def GeneratedTypeBuilder moduleTypeBuilder(Module module, String postfix) {
+               checkArgument(module !== null, "Module reference cannot be NULL.");
+               val packageName = moduleNamespaceToPackageName(module);
+               val moduleName = parseToClassName(module.name) + postfix;
 
-        return new GeneratedTypeBuilderImpl(packageName, moduleName);
+               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
@@ -845,47 +845,47 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if target path of <code>augSchema</code> equals null</li>
      *             </ul>
      */
-    private def List<Type> augmentationToGenTypes(String augmentPackageName, AugmentationSchema augSchema) {
-        checkArgument(augmentPackageName !== null, "Package Name cannot be NULL.");
-        checkArgument(augSchema !== null, "Augmentation Schema cannot be NULL.");
-        checkState(augSchema.targetPath !== null,
-            "Augmentation Schema does not contain Target Path (Target Path is NULL).");
-        val List<Type> genTypes = new ArrayList();
-
-        // EVERY augmented interface will extends Augmentation<T> interface
-        // and DataObject interface!!!
-        val targetPath = augSchema.targetPath;
-        val targetSchemaNode = findDataSchemaNode(schemaContext, targetPath);
-        if (targetSchemaNode !== null) {
-            var targetType = yangToJavaMapping.get(targetSchemaNode.path);
-            if (targetType == null) {
-
-                // FIXME: augmentation should be added as last, all types should already be generated
-                // and have assigned Java Types,
-                val targetModule = findParentModule(schemaContext, targetSchemaNode);
-                val targetBasePackage = moduleNamespaceToPackageName(targetModule);
-                val typePackage = packageNameForGeneratedType(targetBasePackage, targetSchemaNode.getPath());
-                val targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
-                val typeName = parseToClassName(targetSchemaNodeName);
-                targetType = new ReferencedTypeImpl(typePackage, typeName);
-            }
-            val augChildNodes = augSchema.childNodes;
-            if (!(targetSchemaNode instanceof ChoiceNode)) {
-                val augTypeBuilder = addRawAugmentGenTypeDefinition(augmentPackageName, targetType, augSchema);
-                val augType = augTypeBuilder.toInstance();
-                genTypes.add(augType);
-            } else {
-                val choiceTarget = targetSchemaNode as ChoiceNode;
-                val choiceCaseNodes = choiceTarget.cases;
-                genTypes.addAll(
-                    generateTypesFromAugmentedChoiceCases(augmentPackageName, targetType, choiceCaseNodes));
-            }
-            genTypes.addAll(augmentationBodyToGenTypes(augmentPackageName, augChildNodes));
-        }
-        return genTypes;
-    }
-
-    /**
+       private def List<Type> augmentationToGenTypes(String augmentPackageName, AugmentationSchema augSchema) {
+               checkArgument(augmentPackageName !== null, "Package Name cannot be NULL.");
+               checkArgument(augSchema !== null, "Augmentation Schema cannot be NULL.");
+               checkState(augSchema.targetPath !== null,
+                       "Augmentation Schema does not contain Target Path (Target Path is NULL).");
+               val List<Type> genTypes = new ArrayList();
+
+               // EVERY augmented interface will extends Augmentation<T> interface
+               // and DataObject interface!!!
+               val targetPath = augSchema.targetPath;
+               val targetSchemaNode = findDataSchemaNode(schemaContext, targetPath);
+               if (targetSchemaNode !== null) {
+                       var targetType = yangToJavaMapping.get(targetSchemaNode.path);
+                       if (targetType == null) {
+
+                               // FIXME: augmentation should be added as last, all types should already be generated
+                               // and have assigned Java Types,
+                               val targetModule = findParentModule(schemaContext, targetSchemaNode);
+                               val targetBasePackage = moduleNamespaceToPackageName(targetModule);
+                               val typePackage = packageNameForGeneratedType(targetBasePackage, targetSchemaNode.getPath());
+                               val targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
+                               val typeName = parseToClassName(targetSchemaNodeName);
+                               targetType = new ReferencedTypeImpl(typePackage, typeName);
+                       }
+                       val augChildNodes = augSchema.childNodes;
+                       if (!(targetSchemaNode instanceof ChoiceNode)) {
+                               val augTypeBuilder = addRawAugmentGenTypeDefinition(augmentPackageName, targetType, augSchema);
+                               val augType = augTypeBuilder.toInstance();
+                               genTypes.add(augType);
+                       } else {
+                               val choiceTarget = targetSchemaNode as ChoiceNode;
+                               val choiceCaseNodes = choiceTarget.cases;
+                               genTypes.addAll(
+                                       generateTypesFromAugmentedChoiceCases(augmentPackageName, targetType, 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
@@ -904,50 +904,50 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            and uses of augment
      * @return generated type builder for augment
      */
-    private def GeneratedTypeBuilder addRawAugmentGenTypeDefinition(String augmentPackageName, Type targetTypeRef,
-        AugmentationSchema augSchema) {
-        var Map<String, GeneratedTypeBuilder> augmentBuilders = genTypeBuilders.get(augmentPackageName);
-        if (augmentBuilders === null) {
-            augmentBuilders = new HashMap();
-            genTypeBuilders.put(augmentPackageName, augmentBuilders);
-        }
-        val augIdentifier = getAugmentIdentifier(augSchema.unknownSchemaNodes);
-
-        val augTypeName = if (augIdentifier !== null) {
-                parseToClassName(augIdentifier)
-            } else {
-                augGenTypeName(augmentBuilders, targetTypeRef.name);
-            }
-        val Set<DataSchemaNode> augChildNodes = augSchema.childNodes;
-
-        val augTypeBuilder = new GeneratedTypeBuilderImpl(augmentPackageName, augTypeName);
-
-        augTypeBuilder.addImplementsType(DATA_OBJECT);
-        augTypeBuilder.addImplementsType(Types.augmentationTypeFor(targetTypeRef));
-        addImplementedInterfaceFromUses(augSchema, augTypeBuilder);
-
-        augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);
-        augmentBuilders.put(augTypeName, augTypeBuilder);
-        return augTypeBuilder;
-    }
-
-    /**
+       private def GeneratedTypeBuilder addRawAugmentGenTypeDefinition(String augmentPackageName, Type targetTypeRef,
+               AugmentationSchema augSchema) {
+               var Map<String, GeneratedTypeBuilder> augmentBuilders = genTypeBuilders.get(augmentPackageName);
+               if (augmentBuilders === null) {
+                       augmentBuilders = new HashMap();
+                       genTypeBuilders.put(augmentPackageName, augmentBuilders);
+               }
+               val augIdentifier = getAugmentIdentifier(augSchema.unknownSchemaNodes);
+
+               val augTypeName = if (augIdentifier !== null) {
+                               parseToClassName(augIdentifier)
+                       } else {
+                               augGenTypeName(augmentBuilders, targetTypeRef.name);
+                       }
+               val Set<DataSchemaNode> augChildNodes = augSchema.childNodes;
+
+               val augTypeBuilder = new GeneratedTypeBuilderImpl(augmentPackageName, augTypeName);
+
+               augTypeBuilder.addImplementsType(DATA_OBJECT);
+               augTypeBuilder.addImplementsType(Types.augmentationTypeFor(targetTypeRef));
+               addImplementedInterfaceFromUses(augSchema, augTypeBuilder);
+
+               augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);
+               augmentBuilders.put(augTypeName, augTypeBuilder);
+               return augTypeBuilder;
+       }
+
+       /**
      *
      * @param unknownSchemaNodes
      * @return
      */
-    private def String getAugmentIdentifier(List<UnknownSchemaNode> unknownSchemaNodes) {
-        for (unknownSchemaNode : unknownSchemaNodes) {
-            val nodeType = unknownSchemaNode.nodeType;
-            if (AUGMENT_IDENTIFIER_NAME.equals(nodeType.localName) &&
-                YANG_EXT_NAMESPACE.equals(nodeType.namespace.toString())) {
-                return unknownSchemaNode.nodeParameter;
-            }
-        }
-        return null;
-    }
-
-    /**
+       private def String getAugmentIdentifier(List<UnknownSchemaNode> unknownSchemaNodes) {
+               for (unknownSchemaNode : unknownSchemaNodes) {
+                       val nodeType = unknownSchemaNode.nodeType;
+                       if (AUGMENT_IDENTIFIER_NAME.equals(nodeType.localName) &&
+                               YANG_EXT_NAMESPACE.equals(nodeType.namespace.toString())) {
+                               return unknownSchemaNode.nodeParameter;
+                       }
+               }
+               return null;
+       }
+
+       /**
      * Convert a container, list and choice subnodes (and recursivelly their
      * subnodes) of augment to generated types
      *
@@ -960,52 +960,52 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @return list of <code>Type</code> which represents container, list and
      *         choice subnodes of augment
      */
-    private def List<Type> augmentationBodyToGenTypes(String augBasePackageName, Set<DataSchemaNode> augChildNodes) {
-        val List<Type> genTypes = new ArrayList();
-        val List<DataNodeIterator> augSchemaIts = new ArrayList();
-        for (childNode : augChildNodes) {
-            if (childNode instanceof DataNodeContainer) {
-                augSchemaIts.add(new DataNodeIterator(childNode as DataNodeContainer));
-
-                if (childNode instanceof ContainerSchemaNode) {
-                    genTypes.add(containerToGenType(augBasePackageName, childNode as ContainerSchemaNode));
-                } else if (childNode instanceof ListSchemaNode) {
-                    genTypes.addAll(listToGenType(augBasePackageName, childNode as ListSchemaNode));
-                }
-            } else if (childNode instanceof ChoiceNode) {
-                val choice = childNode as ChoiceNode;
-                for (caseNode : choice.cases) {
-                    augSchemaIts.add(new DataNodeIterator(caseNode));
-                }
-                genTypes.addAll(choiceToGeneratedType(augBasePackageName, childNode as ChoiceNode));
-            }
-        }
-
-        for (it : augSchemaIts) {
-            val List<ContainerSchemaNode> augContainers = it.allContainers();
-            val List<ListSchemaNode> augLists = it.allLists();
-            val List<ChoiceNode> augChoices = it.allChoices();
-
-            if (augContainers !== null) {
-                for (container : augContainers) {
-                    genTypes.add(containerToGenType(augBasePackageName, container));
-                }
-            }
-            if (augLists !== null) {
-                for (list : augLists) {
-                    genTypes.addAll(listToGenType(augBasePackageName, list));
-                }
-            }
-            if (augChoices !== null) {
-                for (choice : augChoices) {
-                    genTypes.addAll(choiceToGeneratedType(augBasePackageName, choice));
-                }
-            }
-        }
-        return genTypes;
-    }
-
-    /**
+       private def List<Type> augmentationBodyToGenTypes(String augBasePackageName, Set<DataSchemaNode> augChildNodes) {
+               val List<Type> genTypes = new ArrayList();
+               val List<DataNodeIterator> augSchemaIts = new ArrayList();
+               for (childNode : augChildNodes) {
+                       if (childNode instanceof DataNodeContainer) {
+                               augSchemaIts.add(new DataNodeIterator(childNode as DataNodeContainer));
+
+                               if (childNode instanceof ContainerSchemaNode) {
+                                       genTypes.add(containerToGenType(augBasePackageName, childNode as ContainerSchemaNode));
+                               } else if (childNode instanceof ListSchemaNode) {
+                                       genTypes.addAll(listToGenType(augBasePackageName, childNode as ListSchemaNode));
+                               }
+                       } else if (childNode instanceof ChoiceNode) {
+                               val choice = childNode as ChoiceNode;
+                               for (caseNode : choice.cases) {
+                                       augSchemaIts.add(new DataNodeIterator(caseNode));
+                               }
+                               genTypes.addAll(choiceToGeneratedType(augBasePackageName, childNode as ChoiceNode));
+                       }
+               }
+
+               for (it : augSchemaIts) {
+                       val List<ContainerSchemaNode> augContainers = it.allContainers();
+                       val List<ListSchemaNode> augLists = it.allLists();
+                       val List<ChoiceNode> augChoices = it.allChoices();
+
+                       if (augContainers !== null) {
+                               for (container : augContainers) {
+                                       genTypes.add(containerToGenType(augBasePackageName, container));
+                               }
+                       }
+                       if (augLists !== null) {
+                               for (list : augLists) {
+                                       genTypes.addAll(listToGenType(augBasePackageName, list));
+                               }
+                       }
+                       if (augChoices !== null) {
+                               for (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.
@@ -1017,15 +1017,15 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            string with name of augmented node
      * @return string with unique name for augmentation builder
      */
-    private def String augGenTypeName(Map<String, GeneratedTypeBuilder> builders, String genTypeName) {
-        var index = 1;
-        while ((builders !== null) && builders.containsKey(genTypeName + index)) {
-            index = index + 1;
-        }
-        return genTypeName + index;
-    }
-
-    /**
+       private def String augGenTypeName(Map<String, GeneratedTypeBuilder> builders, String genTypeName) {
+               var index = 1;
+               while ((builders !== null) && builders.containsKey(genTypeName + index)) {
+                       index = index + 1;
+               }
+               return genTypeName + index;
+       }
+
+       /**
      * 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
@@ -1038,20 +1038,20 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            schema paths
      * @return generated type for <code>containerNode</code>
      */
-    private def GeneratedType containerToGenType(String basePackageName, ContainerSchemaNode containerNode) {
-        if (containerNode === null) {
-            return null;
-        }
+       private def GeneratedType containerToGenType(String basePackageName, ContainerSchemaNode containerNode) {
+               if (containerNode === null) {
+                       return null;
+               }
 
-        val packageName = packageNameForGeneratedType(basePackageName, containerNode.path);
-        val schemaNodes = containerNode.childNodes;
-        val typeBuilder = addDefaultInterfaceDefinition(packageName, containerNode);
+               val packageName = packageNameForGeneratedType(basePackageName, containerNode.path);
+               val schemaNodes = containerNode.childNodes;
+               val typeBuilder = addDefaultInterfaceDefinition(packageName, containerNode);
 
-        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
-        return typeBuilder.toInstance();
-    }
+               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.
      *
@@ -1072,20 +1072,20 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         parameter. The getter methods (representing child nodes) could be
      *         added to it.
      */
-    private def GeneratedTypeBuilder resolveDataSchemaNodes(String basePackageName, GeneratedTypeBuilder typeBuilder,
-        Set<DataSchemaNode> schemaNodes) {
-        if ((schemaNodes !== null) && (typeBuilder !== null)) {
-            for (schemaNode : schemaNodes) {
-                if (!schemaNode.isAugmenting() && !schemaNode.isAddedByUses()) {
-                    addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
-                }
-
-            }
-        }
-        return typeBuilder;
-    }
-
-    /**
+       private def GeneratedTypeBuilder resolveDataSchemaNodes(String basePackageName, GeneratedTypeBuilder typeBuilder,
+               Set<DataSchemaNode> schemaNodes) {
+               if ((schemaNodes !== null) && (typeBuilder !== null)) {
+                       for (schemaNode : schemaNodes) {
+                               if (!schemaNode.isAugmenting() && !schemaNode.isAddedByUses()) {
+                                       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.
      *
@@ -1103,19 +1103,19 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         parameter <code>typeBuilder</code>. The getter method could be
      *         added to it.
      */
-    private def GeneratedTypeBuilder augSchemaNodeToMethods(String basePackageName, GeneratedTypeBuilder typeBuilder,
-        Set<DataSchemaNode> schemaNodes) {
-        if ((schemaNodes !== null) && (typeBuilder !== null)) {
-            for (schemaNode : schemaNodes) {
-                if (schemaNode.isAugmenting()) {
-                    addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
-                }
-            }
-        }
-        return typeBuilder;
-    }
-
-    /**
+       private def GeneratedTypeBuilder augSchemaNodeToMethods(String basePackageName, GeneratedTypeBuilder typeBuilder,
+               Set<DataSchemaNode> schemaNodes) {
+               if ((schemaNodes !== null) && (typeBuilder !== null)) {
+                       for (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>.
      *
@@ -1128,25 +1128,25 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            generated type builder to which is <code>schemaNode</code>
      *            added as a method.
      */
-    private def void addSchemaNodeToBuilderAsMethod(String basePackageName, DataSchemaNode node,
-        GeneratedTypeBuilder typeBuilder) {
-        if (node !== null && typeBuilder !== null) {
-            switch (node) {
-                case node instanceof LeafSchemaNode:
-                    resolveLeafSchemaNodeAsMethod(typeBuilder, node as LeafSchemaNode)
-                case node instanceof LeafListSchemaNode:
-                    resolveLeafListSchemaNode(typeBuilder, node as LeafListSchemaNode)
-                case node instanceof ContainerSchemaNode:
-                    resolveContainerSchemaNode(basePackageName, typeBuilder, node as ContainerSchemaNode)
-                case node instanceof ListSchemaNode:
-                    resolveListSchemaNode(basePackageName, typeBuilder, node as ListSchemaNode)
-                case node instanceof ChoiceNode:
-                    resolveChoiceSchemaNode(basePackageName, typeBuilder, node as ChoiceNode)
-            }
-        }
-    }
-
-    /**
+       private def void addSchemaNodeToBuilderAsMethod(String basePackageName, DataSchemaNode node,
+               GeneratedTypeBuilder typeBuilder) {
+               if (node !== null && typeBuilder !== null) {
+                       switch (node) {
+                               case node instanceof LeafSchemaNode:
+                                       resolveLeafSchemaNodeAsMethod(typeBuilder, node as LeafSchemaNode)
+                               case node instanceof LeafListSchemaNode:
+                                       resolveLeafListSchemaNode(typeBuilder, node as LeafListSchemaNode)
+                               case node instanceof ContainerSchemaNode:
+                                       resolveContainerSchemaNode(basePackageName, typeBuilder, node as ContainerSchemaNode)
+                               case node instanceof ListSchemaNode:
+                                       resolveListSchemaNode(basePackageName, typeBuilder, node as ListSchemaNode)
+                               case node instanceof ChoiceNode:
+                                       resolveChoiceSchemaNode(basePackageName, typeBuilder, node as ChoiceNode)
+                       }
+               }
+       }
+
+       /**
      * Creates a getter method for a choice node.
      *
      * Firstly generated type builder for choice is created or found in
@@ -1171,21 +1171,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def void resolveChoiceSchemaNode(String basePackageName, GeneratedTypeBuilder typeBuilder,
-        ChoiceNode choiceNode) {
-        checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
-        checkArgument(typeBuilder !== null, "Generated Type Builder cannot be NULL.");
-        checkArgument(choiceNode !== null, "Choice Schema Node cannot be NULL.");
-
-        val choiceName = choiceNode.QName.localName;
-        if (choiceName !== null && !choiceNode.isAddedByUses()) {
-            val packageName = packageNameForGeneratedType(basePackageName, choiceNode.path);
-            val choiceType = addDefaultInterfaceDefinition(packageName, choiceNode);
-            constructGetter(typeBuilder, choiceName, choiceNode.description, choiceType);
-        }
-    }
-
-    /**
+       private def void resolveChoiceSchemaNode(String basePackageName, GeneratedTypeBuilder typeBuilder,
+               ChoiceNode choiceNode) {
+               checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
+               checkArgument(typeBuilder !== null, "Generated Type Builder cannot be NULL.");
+               checkArgument(choiceNode !== null, "Choice Schema Node cannot be NULL.");
+
+               val choiceName = choiceNode.QName.localName;
+               if (choiceName !== null && !choiceNode.isAddedByUses()) {
+                       val packageName = packageNameForGeneratedType(basePackageName, choiceNode.path);
+                       val choiceType = addDefaultInterfaceDefinition(packageName, choiceNode);
+                       constructGetter(typeBuilder, choiceName, choiceNode.description, choiceType);
+               }
+       }
+
+       /**
      * Converts <code>choiceNode</code> to the list of generated types for
      * choice and its cases.
      *
@@ -1208,26 +1208,26 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def List<GeneratedType> choiceToGeneratedType(String basePackageName, ChoiceNode choiceNode) {
-        checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
-        checkArgument(choiceNode !== null, "Choice Schema Node cannot be NULL.");
-
-        val List<GeneratedType> generatedTypes = new ArrayList();
-        val packageName = packageNameForGeneratedType(basePackageName, choiceNode.path);
-        val choiceTypeBuilder = addRawInterfaceDefinition(packageName, choiceNode);
-
-        //choiceTypeBuilder.addImplementsType(DATA_OBJECT);
-        val choiceType = choiceTypeBuilder.toInstance();
-
-        generatedTypes.add(choiceType);
-        val Set<ChoiceCaseNode> caseNodes = choiceNode.cases;
-        if ((caseNodes !== null) && !caseNodes.isEmpty()) {
-            generatedTypes.addAll(generateTypesFromChoiceCases(basePackageName, choiceType, caseNodes));
-        }
-        return generatedTypes;
-    }
-
-    /**
+       private def List<GeneratedType> choiceToGeneratedType(String basePackageName, ChoiceNode choiceNode) {
+               checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
+               checkArgument(choiceNode !== null, "Choice Schema Node cannot be NULL.");
+
+               val List<GeneratedType> generatedTypes = new ArrayList();
+               val packageName = packageNameForGeneratedType(basePackageName, choiceNode.path);
+               val choiceTypeBuilder = addRawInterfaceDefinition(packageName, choiceNode);
+
+               //choiceTypeBuilder.addImplementsType(DATA_OBJECT);
+               val choiceType = choiceTypeBuilder.toInstance();
+
+               generatedTypes.add(choiceType);
+               val Set<ChoiceCaseNode> caseNodes = choiceNode.cases;
+               if ((caseNodes !== null) && !caseNodes.isEmpty()) {
+                       generatedTypes.addAll(generateTypesFromChoiceCases(basePackageName, choiceType, caseNodes));
+               }
+               return generatedTypes;
+       }
+
+       /**
      * Converts <code>caseNodes</code> set to list of corresponding generated
      * types.
      *
@@ -1253,31 +1253,31 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *             *
      */
-    private def List<GeneratedType> generateTypesFromChoiceCases(String basePackageName, Type refChoiceType,
-        Set<ChoiceCaseNode> caseNodes) {
-        checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
-        checkArgument(refChoiceType !== null, "Referenced Choice Type cannot be NULL.");
-        checkArgument(caseNodes !== null, "Set of Choice Case Nodes cannot be NULL.");
-
-        val List<GeneratedType> generatedTypes = new ArrayList();
-        for (caseNode : caseNodes) {
-            if (caseNode !== null && !caseNode.isAddedByUses() && !caseNode.isAugmenting()) {
-                val packageName = packageNameForGeneratedType(basePackageName, caseNode.path);
-                val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
-                caseTypeBuilder.addImplementsType(refChoiceType);
-
-                val Set<DataSchemaNode> childNodes = caseNode.childNodes;
-                if (childNodes !== null) {
-                    resolveDataSchemaNodes(basePackageName, caseTypeBuilder, childNodes);
-                }
-                generatedTypes.add(caseTypeBuilder.toInstance());
-            }
-        }
-
-        return generatedTypes;
-    }
-
-    /**
+       private def List<GeneratedType> generateTypesFromChoiceCases(String basePackageName, Type refChoiceType,
+               Set<ChoiceCaseNode> caseNodes) {
+               checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
+               checkArgument(refChoiceType !== null, "Referenced Choice Type cannot be NULL.");
+               checkArgument(caseNodes !== null, "Set of Choice Case Nodes cannot be NULL.");
+
+               val List<GeneratedType> generatedTypes = new ArrayList();
+               for (caseNode : caseNodes) {
+                       if (caseNode !== null && !caseNode.isAddedByUses() && !caseNode.isAugmenting()) {
+                               val packageName = packageNameForGeneratedType(basePackageName, caseNode.path);
+                               val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
+                               caseTypeBuilder.addImplementsType(refChoiceType);
+
+                               val Set<DataSchemaNode> childNodes = caseNode.childNodes;
+                               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.
      *
@@ -1302,31 +1302,31 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if <code>caseNodes</code> equals null</li>
      *             </ul>
      */
-    private def List<GeneratedType> generateTypesFromAugmentedChoiceCases(String basePackageName, Type refChoiceType,
-        Set<ChoiceCaseNode> caseNodes) {
-        checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
-        checkArgument(refChoiceType !== null, "Referenced Choice Type cannot be NULL.");
-        checkArgument(caseNodes !== null, "Set of Choice Case Nodes cannot be NULL.");
-
-        val List<GeneratedType> generatedTypes = new ArrayList();
-        for (caseNode : caseNodes) {
-            if (caseNode !== null && caseNode.isAugmenting()) {
-                val packageName = packageNameForGeneratedType(basePackageName, caseNode.path);
-                val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
-                caseTypeBuilder.addImplementsType(refChoiceType);
-
-                val Set<DataSchemaNode> childNodes = caseNode.childNodes;
-                if (childNodes !== null) {
-                    resolveDataSchemaNodes(basePackageName, caseTypeBuilder, childNodes);
-                }
-                generatedTypes.add(caseTypeBuilder.toInstance());
-            }
-        }
-
-        return generatedTypes;
-    }
-
-    /**
+       private def List<GeneratedType> generateTypesFromAugmentedChoiceCases(String basePackageName, Type refChoiceType,
+               Set<ChoiceCaseNode> caseNodes) {
+               checkArgument(basePackageName !== null, "Base Package Name cannot be NULL.");
+               checkArgument(refChoiceType !== null, "Referenced Choice Type cannot be NULL.");
+               checkArgument(caseNodes !== null, "Set of Choice Case Nodes cannot be NULL.");
+
+               val List<GeneratedType> generatedTypes = new ArrayList();
+               for (caseNode : caseNodes) {
+                       if (caseNode !== null && caseNode.isAugmenting()) {
+                               val packageName = packageNameForGeneratedType(basePackageName, caseNode.path);
+                               val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode);
+                               caseTypeBuilder.addImplementsType(refChoiceType);
+
+                               val Set<DataSchemaNode> childNodes = caseNode.childNodes;
+                               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>.
      *
@@ -1343,51 +1343,51 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <li>true - in other cases</li>
      *         </ul>
      */
-    private def boolean resolveLeafSchemaNodeAsMethod(GeneratedTypeBuilder typeBuilder, LeafSchemaNode leaf) {
-        if ((leaf !== null) && (typeBuilder !== null)) {
-            val leafName = leaf.QName.localName;
-            var String leafDesc = leaf.description;
-            if (leafDesc === null) {
-                leafDesc = "";
-            }
-
-            val parentModule = findParentModule(schemaContext, leaf);
-            if (leafName !== null && !leaf.isAddedByUses()) {
-                val TypeDefinition<?> typeDef = leaf.type;
-
-                var Type returnType = null;
-                if (typeDef instanceof EnumTypeDefinition) {
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
-                    val enumTypeDef = enumTypeDefFromExtendedType(typeDef);
-                    val enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, leafName, typeBuilder);
-
-                    if (enumBuilder !== null) {
-                        returnType = new ReferencedTypeImpl(enumBuilder.packageName, enumBuilder.name);
-                    }
-                    (typeProvider as TypeProviderImpl).putReferencedType(leaf.path, returnType);
-                } else if (typeDef instanceof UnionType) {
-                    val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName, leaf, parentModule);
-                    if (genTOBuilder !== null) {
-                        returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
-                    }
-                } else if (typeDef instanceof BitsTypeDefinition) {
-                    val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName, leaf, parentModule);
-                    if (genTOBuilder !== null) {
-                        returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
-                    }
-                } else {
-                    returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
-                }
-                if (returnType !== null) {
-                    constructGetter(typeBuilder, leafName, leafDesc, returnType);
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
+       private def boolean resolveLeafSchemaNodeAsMethod(GeneratedTypeBuilder typeBuilder, LeafSchemaNode leaf) {
+               if ((leaf !== null) && (typeBuilder !== null)) {
+                       val leafName = leaf.QName.localName;
+                       var String leafDesc = leaf.description;
+                       if (leafDesc === null) {
+                               leafDesc = "";
+                       }
+
+                       val parentModule = findParentModule(schemaContext, leaf);
+                       if (leafName !== null && !leaf.isAddedByUses()) {
+                               val TypeDefinition<?> typeDef = leaf.type;
+
+                               var Type returnType = null;
+                               if (typeDef instanceof EnumTypeDefinition) {
+                                       returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
+                                       val enumTypeDef = enumTypeDefFromExtendedType(typeDef);
+                                       val enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, leafName, typeBuilder);
+
+                                       if (enumBuilder !== null) {
+                                               returnType = new ReferencedTypeImpl(enumBuilder.packageName, enumBuilder.name);
+                                       }
+                                       (typeProvider as TypeProviderImpl).putReferencedType(leaf.path, returnType);
+                               } else if (typeDef instanceof UnionType) {
+                                       val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName, leaf, parentModule);
+                                       if (genTOBuilder !== null) {
+                                               returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
+                                       }
+                               } else if (typeDef instanceof BitsTypeDefinition) {
+                                       val genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName, leaf, parentModule);
+                                       if (genTOBuilder !== null) {
+                                               returnType = new ReferencedTypeImpl(genTOBuilder.packageName, genTOBuilder.name);
+                                       }
+                               } else {
+                                       returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
+                               }
+                               if (returnType !== null) {
+                                       constructGetter(typeBuilder, leafName, leafDesc, returnType);
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
      * Converts <code>leaf</code> schema node to property of generated TO
      * builder.
      *
@@ -1406,40 +1406,40 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <li>true - other cases</li>
      *         </ul>
      */
-    private def boolean resolveLeafSchemaNodeAsProperty(GeneratedTOBuilder toBuilder, LeafSchemaNode leaf,
-        boolean isReadOnly) {
-        if ((leaf !== null) && (toBuilder !== null)) {
-            val leafName = leaf.QName.localName;
-            var String leafDesc = leaf.description;
-            if (leafDesc === null) {
-                leafDesc = "";
-            }
-
-            if (leafName !== null && !leaf.isAddedByUses()) {
-                val TypeDefinition<?> typeDef = leaf.type;
-
-                // TODO: properly resolve enum types
-                val returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
-
-                if (returnType !== null) {
-                    val 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;
-    }
-
-    /**
+       private def boolean resolveLeafSchemaNodeAsProperty(GeneratedTOBuilder toBuilder, LeafSchemaNode leaf,
+               boolean isReadOnly) {
+               if ((leaf !== null) && (toBuilder !== null)) {
+                       val leafName = leaf.QName.localName;
+                       var String leafDesc = leaf.description;
+                       if (leafDesc === null) {
+                               leafDesc = "";
+                       }
+
+                       if (leafName !== null && !leaf.isAddedByUses()) {
+                               val TypeDefinition<?> typeDef = leaf.type;
+
+                               // TODO: properly resolve enum types
+                               val returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
+
+                               if (returnType !== null) {
+                                       val 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>.
      *
@@ -1456,26 +1456,26 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <li>false - other cases</li>
      *         </ul>
      */
-    private def boolean resolveLeafListSchemaNode(GeneratedTypeBuilder typeBuilder, LeafListSchemaNode node) {
-        if ((node !== null) && (typeBuilder !== null)) {
-            val nodeName = node.QName.localName;
-            var String nodeDesc = node.description;
-            if (nodeDesc === null) {
-                nodeDesc = "";
-            }
-
-            if (nodeName !== null && !node.isAddedByUses()) {
-                val TypeDefinition<?> type = node.type;
-                val listType = Types.listTypeFor(typeProvider.javaTypeForSchemaDefinitionType(type, node));
-
-                constructGetter(typeBuilder, nodeName, nodeDesc, listType);
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
+       private def boolean resolveLeafListSchemaNode(GeneratedTypeBuilder typeBuilder, LeafListSchemaNode node) {
+               if ((node !== null) && (typeBuilder !== null)) {
+                       val nodeName = node.QName.localName;
+                       var String nodeDesc = node.description;
+                       if (nodeDesc === null) {
+                               nodeDesc = "";
+                       }
+
+                       if (nodeName !== null && !node.isAddedByUses()) {
+                               val TypeDefinition<?> type = node.type;
+                               val listType = Types.listTypeFor(typeProvider.javaTypeForSchemaDefinitionType(type, node));
+
+                               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
@@ -1501,24 +1501,24 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <li>true - other cases</li>
      *         </ul>
      */
-    private def boolean resolveContainerSchemaNode(String basePackageName, GeneratedTypeBuilder typeBuilder,
-        ContainerSchemaNode containerNode) {
-        if ((containerNode !== null) && (typeBuilder !== null)) {
-            val nodeName = containerNode.QName.localName;
+       private def boolean resolveContainerSchemaNode(String basePackageName, GeneratedTypeBuilder typeBuilder,
+               ContainerSchemaNode containerNode) {
+               if ((containerNode !== null) && (typeBuilder !== null)) {
+                       val nodeName = containerNode.QName.localName;
 
-            if (nodeName !== null && !containerNode.isAddedByUses()) {
-                val packageName = packageNameForGeneratedType(basePackageName, containerNode.path);
+                       if (nodeName !== null && !containerNode.isAddedByUses()) {
+                               val packageName = packageNameForGeneratedType(basePackageName, containerNode.path);
 
-                val rawGenType = addDefaultInterfaceDefinition(packageName, containerNode);
-                constructGetter(typeBuilder, nodeName, containerNode.description, rawGenType);
+                               val rawGenType = addDefaultInterfaceDefinition(packageName, containerNode);
+                               constructGetter(typeBuilder, nodeName, containerNode.description, rawGenType);
 
-                return true;
-            }
-        }
-        return false;
-    }
+                               return true;
+                       }
+               }
+               return false;
+       }
 
-    /**
+       /**
      * Creates a getter method for a list node.
      *
      * Firstly generated type builder for list is created or found in
@@ -1543,22 +1543,22 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <li>true - other cases</li>
      *         </ul>
      */
-    private def boolean resolveListSchemaNode(String basePackageName, GeneratedTypeBuilder typeBuilder,
-        ListSchemaNode listNode) {
-        if ((listNode !== null) && (typeBuilder !== null)) {
-            val listName = listNode.QName.localName;
-
-            if (listName !== null && !listNode.isAddedByUses()) {
-                val packageName = packageNameForGeneratedType(basePackageName, listNode.path);
-                val rawGenType = addDefaultInterfaceDefinition(packageName, listNode);
-                constructGetter(typeBuilder, listName, listNode.description, Types.listTypeFor(rawGenType));
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
+       private def boolean resolveListSchemaNode(String basePackageName, GeneratedTypeBuilder typeBuilder,
+               ListSchemaNode listNode) {
+               if ((listNode !== null) && (typeBuilder !== null)) {
+                       val listName = listNode.QName.localName;
+
+                       if (listName !== null && !listNode.isAddedByUses()) {
+                               val packageName = packageNameForGeneratedType(basePackageName, listNode.path);
+                               val rawGenType = addDefaultInterfaceDefinition(packageName, listNode);
+                               constructGetter(typeBuilder, listName, listNode.description, Types.listTypeFor(rawGenType));
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
      * Instantiates generated type builder with <code>packageName</code> and
      * <code>schemaNode</code>.
      *
@@ -1579,21 +1579,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            schema node for which is created generated type builder
      * @return generated type builder <code>schemaNode</code>
      */
-    private def GeneratedTypeBuilder addDefaultInterfaceDefinition(String packageName, SchemaNode schemaNode) {
-        val builder = addRawInterfaceDefinition(packageName, schemaNode, "");
-        builder.addImplementsType(DATA_OBJECT);
-        if (!(schemaNode instanceof GroupingDefinition)) {
-            builder.addImplementsType(augmentable(builder));
-        }
+       private def GeneratedTypeBuilder addDefaultInterfaceDefinition(String packageName, SchemaNode schemaNode) {
+               val builder = addRawInterfaceDefinition(packageName, schemaNode, "");
+               builder.addImplementsType(DATA_OBJECT);
+               if (!(schemaNode instanceof GroupingDefinition)) {
+                       builder.addImplementsType(augmentable(builder));
+               }
 
-        if (schemaNode instanceof DataNodeContainer) {
-            addImplementedInterfaceFromUses(schemaNode as DataNodeContainer, builder);
-        }
+               if (schemaNode instanceof DataNodeContainer) {
+                       addImplementedInterfaceFromUses(schemaNode as DataNodeContainer, builder);
+               }
 
-        return builder;
-    }
+               return builder;
+       }
 
-    /**
+       /**
      * Wraps the calling of the same overloaded method.
      *
      * @param packageName
@@ -1603,11 +1603,11 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            schema node which provide data about the schema node name
      * @return generated type builder for <code>schemaNode</code>
      */
-    private def GeneratedTypeBuilder addRawInterfaceDefinition(String packageName, SchemaNode schemaNode) {
-        return addRawInterfaceDefinition(packageName, schemaNode, "");
-    }
+       private def GeneratedTypeBuilder addRawInterfaceDefinition(String packageName, SchemaNode schemaNode) {
+               return addRawInterfaceDefinition(packageName, schemaNode, "");
+       }
 
-    /**
+       /**
      * Returns reference to generated type builder for specified
      * <code>schemaNode</code> with <code>packageName</code>.
      *
@@ -1630,38 +1630,38 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      *
      */
-    private def GeneratedTypeBuilder addRawInterfaceDefinition(String packageName, SchemaNode schemaNode,
-        String prefix) {
-        checkArgument(schemaNode !== null, "Data Schema Node cannot be NULL.");
-        checkArgument(packageName !== null, "Package Name for Generated Type cannot be NULL.");
-        checkArgument(schemaNode.QName !== null, "QName for Data Schema Node cannot be NULL.");
-        val schemaNodeName = schemaNode.QName.localName;
-        checkArgument(schemaNodeName !== null, "Local Name of QName for Data Schema Node cannot be NULL.");
-
-        var String genTypeName;
-        if (prefix === null) {
-            genTypeName = parseToClassName(schemaNodeName);
-        } else {
-            genTypeName = prefix + parseToClassName(schemaNodeName);
-        }
-
-        //FIXME: Validation of name conflict
-        val newType = new GeneratedTypeBuilderImpl(packageName, genTypeName);
-        yangToJavaMapping.put(schemaNode.path, newType);
-        if (!genTypeBuilders.containsKey(packageName)) {
-            val Map<String, GeneratedTypeBuilder> builders = new HashMap();
-            builders.put(genTypeName, newType);
-            genTypeBuilders.put(packageName, builders);
-        } else {
-            val Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);
-            if (!builders.containsKey(genTypeName)) {
-                builders.put(genTypeName, newType);
-            }
-        }
-        return newType;
-    }
-
-    /**
+       private def GeneratedTypeBuilder addRawInterfaceDefinition(String packageName, SchemaNode schemaNode,
+               String prefix) {
+               checkArgument(schemaNode !== null, "Data Schema Node cannot be NULL.");
+               checkArgument(packageName !== null, "Package Name for Generated Type cannot be NULL.");
+               checkArgument(schemaNode.QName !== null, "QName for Data Schema Node cannot be NULL.");
+               val schemaNodeName = schemaNode.QName.localName;
+               checkArgument(schemaNodeName !== null, "Local Name of QName for Data Schema Node cannot be NULL.");
+
+               var String genTypeName;
+               if (prefix === null) {
+                       genTypeName = parseToClassName(schemaNodeName);
+               } else {
+                       genTypeName = prefix + parseToClassName(schemaNodeName);
+               }
+
+               //FIXME: Validation of name conflict
+               val newType = new GeneratedTypeBuilderImpl(packageName, genTypeName);
+               yangToJavaMapping.put(schemaNode.path, newType);
+               if (!genTypeBuilders.containsKey(packageName)) {
+                       val Map<String, GeneratedTypeBuilder> builders = new HashMap();
+                       builders.put(genTypeName, newType);
+                       genTypeBuilders.put(packageName, builders);
+               } else {
+                       val 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
@@ -1669,18 +1669,18 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @return string with the name of the getter method for
      *         <code>methodName</code> in JAVA method format
      */
-    private def String getterMethodName(String methodName, Type returnType) {
-        val method = new StringBuilder();
-        if (BOOLEAN.equals(returnType)) {
-            method.append("is");
-        } else {
-            method.append("get");
-        }
-        method.append(parseToClassName(methodName));
-        return method.toString();
-    }
-
-    /**
+       private def String getterMethodName(String methodName, Type returnType) {
+               val method = new StringBuilder();
+               if (BOOLEAN.equals(returnType)) {
+                       method.append("is");
+               } else {
+                       method.append("get");
+               }
+               method.append(parseToClassName(methodName));
+               return method.toString();
+       }
+
+       /**
      * Created a method signature builder as part of
      * <code>interfaceBuilder</code>.
      *
@@ -1701,47 +1701,47 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @return method signature builder which represents the getter method of
      *         <code>interfaceBuilder</code>
      */
-    private def MethodSignatureBuilder constructGetter(GeneratedTypeBuilder interfaceBuilder, String schemaNodeName,
-        String comment, Type returnType) {
+       private def MethodSignatureBuilder constructGetter(GeneratedTypeBuilder interfaceBuilder, String schemaNodeName,
+               String comment, Type returnType) {
 
-        val getMethod = interfaceBuilder.addMethod(getterMethodName(schemaNodeName, returnType));
+               val getMethod = interfaceBuilder.addMethod(getterMethodName(schemaNodeName, returnType));
 
-        getMethod.setComment(comment);
-        getMethod.setReturnType(returnType);
+               getMethod.setComment(comment);
+               getMethod.setReturnType(returnType);
 
-        return getMethod;
-    }
+               return getMethod;
+       }
 
-    private def listToGenType(String basePackageName, ListSchemaNode list) {
-        checkArgument(basePackageName !== null, "Package Name for Generated Type cannot be NULL.");
-        checkArgument(list !== null, "List Schema Node cannot be NULL.");
+       private def listToGenType(String basePackageName, ListSchemaNode list) {
+               checkArgument(basePackageName !== null, "Package Name for Generated Type cannot be NULL.");
+               checkArgument(list !== null, "List Schema Node cannot be NULL.");
 
-        val packageName = packageNameForGeneratedType(basePackageName, list.path);
+               val packageName = packageNameForGeneratedType(basePackageName, list.path);
 
-        // val typeBuilder =
-        // resolveListTypeBuilder(packageName, list);
-        val typeBuilder = addDefaultInterfaceDefinition(packageName, list);
+               // val typeBuilder =
+               // resolveListTypeBuilder(packageName, list);
+               val typeBuilder = addDefaultInterfaceDefinition(packageName, list);
 
-        val List<String> listKeys = listKeys(list);
-        val genTOBuilder = resolveListKeyTOBuilder(packageName, list);
+               val List<String> listKeys = listKeys(list);
+               val genTOBuilder = resolveListKeyTOBuilder(packageName, list);
 
-        if (genTOBuilder !== null) {
-            val identifierMarker = IDENTIFIER.parameterizedTypeFor(typeBuilder);
-            val identifiableMarker = IDENTIFIABLE.parameterizedTypeFor(genTOBuilder);
-            genTOBuilder.addImplementsType(identifierMarker);
-            typeBuilder.addImplementsType(identifiableMarker);
-        }
-        val schemaNodes = list.childNodes;
+               if (genTOBuilder !== null) {
+                       val identifierMarker = IDENTIFIER.parameterizedTypeFor(typeBuilder);
+                       val identifiableMarker = IDENTIFIABLE.parameterizedTypeFor(genTOBuilder);
+                       genTOBuilder.addImplementsType(identifierMarker);
+                       typeBuilder.addImplementsType(identifiableMarker);
+               }
+               val schemaNodes = list.childNodes;
 
-        for (schemaNode : schemaNodes) {
-            if (!schemaNode.isAugmenting()) {
-                addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder, genTOBuilder, listKeys);
-            }
-        }
-        return typeBuildersToGenTypes(typeBuilder, genTOBuilder);
-    }
+               for (schemaNode : schemaNodes) {
+                       if (!schemaNode.isAugmenting()) {
+                               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.
      *
@@ -1763,43 +1763,43 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if <code>typeBuilder</code> equals null</li>
      *             </ul>
      */
-    private def void addSchemaNodeToListBuilders(String basePackageName, DataSchemaNode schemaNode,
-        GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder, List<String> listKeys) {
-        checkArgument(schemaNode !== null, "Data Schema Node cannot be NULL.");
-
-        checkArgument(typeBuilder !== null, "Generated Type Builder cannot be NULL.");
-
-        if (schemaNode instanceof LeafSchemaNode) {
-            val leaf = schemaNode as LeafSchemaNode;
-            val leafName = leaf.QName.localName;
-            if (!listKeys.contains(leafName)) {
-                resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);
-            } else {
-                resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true);
-            }
-        } else if (schemaNode instanceof LeafListSchemaNode) {
-            resolveLeafListSchemaNode(typeBuilder, schemaNode as LeafListSchemaNode);
-        } else if (schemaNode instanceof ContainerSchemaNode) {
-            resolveContainerSchemaNode(basePackageName, typeBuilder, schemaNode as ContainerSchemaNode);
-        } else if (schemaNode instanceof ListSchemaNode) {
-            resolveListSchemaNode(basePackageName, typeBuilder, schemaNode as ListSchemaNode);
-        }
-    }
-
-    private def typeBuildersToGenTypes(GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder) {
-        val List<Type> genTypes = new ArrayList();
-        checkArgument(typeBuilder !== null, "Generated Type Builder cannot be NULL.");
-
-        if (genTOBuilder !== null) {
-            val genTO = genTOBuilder.toInstance();
-            constructGetter(typeBuilder, "key", "Returns Primary Key of Yang List Type", genTO);
-            genTypes.add(genTO);
-        }
-        genTypes.add(typeBuilder.toInstance());
-        return genTypes;
-    }
-
-    /**
+       private def void addSchemaNodeToListBuilders(String basePackageName, DataSchemaNode schemaNode,
+               GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder, List<String> listKeys) {
+               checkArgument(schemaNode !== null, "Data Schema Node cannot be NULL.");
+
+               checkArgument(typeBuilder !== null, "Generated Type Builder cannot be NULL.");
+
+               if (schemaNode instanceof LeafSchemaNode) {
+                       val leaf = schemaNode as LeafSchemaNode;
+                       val leafName = leaf.QName.localName;
+                       if (!listKeys.contains(leafName)) {
+                               resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);
+                       } else {
+                               resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true);
+                       }
+               } else if (schemaNode instanceof LeafListSchemaNode) {
+                       resolveLeafListSchemaNode(typeBuilder, schemaNode as LeafListSchemaNode);
+               } else if (schemaNode instanceof ContainerSchemaNode) {
+                       resolveContainerSchemaNode(basePackageName, typeBuilder, schemaNode as ContainerSchemaNode);
+               } else if (schemaNode instanceof ListSchemaNode) {
+                       resolveListSchemaNode(basePackageName, typeBuilder, schemaNode as ListSchemaNode);
+               }
+       }
+
+       private def typeBuildersToGenTypes(GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder) {
+               val List<Type> genTypes = new ArrayList();
+               checkArgument(typeBuilder !== null, "Generated Type Builder cannot be NULL.");
+
+               if (genTOBuilder !== null) {
+                       val 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
      *
@@ -1809,19 +1809,19 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <code>list</code> contains no keys then the empty list is
      *         returned.
      */
-    private def listKeys(ListSchemaNode list) {
-        val List<String> listKeys = new ArrayList();
-
-        if (list.keyDefinition !== null) {
-            val keyDefinitions = list.keyDefinition;
-            for (keyDefinition : keyDefinitions) {
-                listKeys.add(keyDefinition.localName);
-            }
-        }
-        return listKeys;
-    }
-
-    /**
+       private def listKeys(ListSchemaNode list) {
+               val List<String> listKeys = new ArrayList();
+
+               if (list.keyDefinition !== null) {
+                       val keyDefinitions = list.keyDefinition;
+                       for (keyDefinition : keyDefinitions) {
+                               listKeys.add(keyDefinition.localName);
+                       }
+               }
+               return listKeys;
+       }
+
+       /**
      * Generates for the <code>list</code> which contains any list keys special
      * generated TO builder.
      *
@@ -1833,20 +1833,20 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *         <code>list</code> or null if <code>list</code> is null or list of
      *         key definitions is null or empty.
      */
-    private def GeneratedTOBuilder resolveListKeyTOBuilder(String packageName, ListSchemaNode list) {
-        var GeneratedTOBuilder genTOBuilder = null;
-        if ((list.keyDefinition !== null) && (!list.keyDefinition.isEmpty())) {
-            if (list !== null) {
-                val listName = list.QName.localName + "Key";
-                val String genTOName = parseToClassName(listName);
-                genTOBuilder = new GeneratedTOBuilderImpl(packageName, genTOName);
-            }
-        }
-        return genTOBuilder;
-
-    }
-
-    /**
+       private def GeneratedTOBuilder resolveListKeyTOBuilder(String packageName, ListSchemaNode list) {
+               var GeneratedTOBuilder genTOBuilder = null;
+               if ((list.keyDefinition !== null) && (!list.keyDefinition.isEmpty())) {
+                       if (list !== null) {
+                               val listName = list.QName.localName + "Key";
+                               val String genTOName = parseToClassName(listName);
+                               genTOBuilder = new GeneratedTOBuilderImpl(packageName, genTOName);
+                       }
+               }
+               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
@@ -1867,31 +1867,31 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            string with name for generated TO builder
      * @return generated TO builder for <code>typeDef</code>
      */
-    private def GeneratedTOBuilder addTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,
-        String leafName, LeafSchemaNode leaf, Module parentModule) {
-        val classNameFromLeaf = parseToClassName(leafName);
-        val List<GeneratedTOBuilder> genTOBuilders = new ArrayList();
-        val packageName = typeBuilder.fullyQualifiedName;
-        if (typeDef instanceof UnionTypeDefinition) {
-            genTOBuilders.addAll(
-                (typeProvider as TypeProviderImpl).
-                    provideGeneratedTOBuildersForUnionTypeDef(packageName, typeDef, classNameFromLeaf, leaf));
-        } else if (typeDef instanceof BitsTypeDefinition) {
-            genTOBuilders.add(
-                ((typeProvider as TypeProviderImpl) ).
-                    provideGeneratedTOBuilderForBitsTypeDefinition(packageName, typeDef, classNameFromLeaf));
-        }
-        if (genTOBuilders !== null && !genTOBuilders.isEmpty()) {
-            for (genTOBuilder : genTOBuilders) {
-                typeBuilder.addEnclosingTransferObject(genTOBuilder);
-            }
-            return genTOBuilders.get(0);
-        }
-        return null;
-
-    }
-
-    /**
+       private def GeneratedTOBuilder addTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,
+               String leafName, LeafSchemaNode leaf, Module parentModule) {
+               val classNameFromLeaf = parseToClassName(leafName);
+               val List<GeneratedTOBuilder> genTOBuilders = new ArrayList();
+               val packageName = typeBuilder.fullyQualifiedName;
+               if (typeDef instanceof UnionTypeDefinition) {
+                       genTOBuilders.addAll(
+                               (typeProvider as TypeProviderImpl).
+                                       provideGeneratedTOBuildersForUnionTypeDef(packageName, typeDef, classNameFromLeaf, leaf));
+               } else if (typeDef instanceof BitsTypeDefinition) {
+                       genTOBuilders.add(
+                               ((typeProvider as TypeProviderImpl) ).
+                                       provideGeneratedTOBuilderForBitsTypeDefinition(packageName, typeDef, classNameFromLeaf));
+               }
+               if (genTOBuilders !== null && !genTOBuilders.isEmpty()) {
+                       for (genTOBuilder : genTOBuilders) {
+                               typeBuilder.addEnclosingTransferObject(genTOBuilder);
+                       }
+                       return genTOBuilders.get(0);
+               }
+               return null;
+
+       }
+
+       /**
      * Adds the implemented types to type builder.
      *
      * The method passes through the list of <i>uses</i> in
@@ -1907,17 +1907,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            <code>dataNodeContainer</code>
      * @return generated type builder with all implemented types
      */
-    private def addImplementedInterfaceFromUses(DataNodeContainer dataNodeContainer, GeneratedTypeBuilder builder) {
-        for (usesNode : dataNodeContainer.uses) {
-            if (usesNode.groupingPath !== null) {
-                val genType = allGroupings.get(usesNode.groupingPath);
-                if (genType === null) {
-                    throw new IllegalStateException(
-                        "Grouping " + usesNode.groupingPath + "is not resolved for " + builder.name);
-                }
-                builder.addImplementsType(genType);
-            }
-        }
-        return builder;
-    }
+       private def addImplementedInterfaceFromUses(DataNodeContainer dataNodeContainer, GeneratedTypeBuilder builder) {
+               for (usesNode : dataNodeContainer.uses) {
+                       if (usesNode.groupingPath !== null) {
+                               val genType = allGroupings.get(usesNode.groupingPath);
+                               if (genType === null) {
+                                       throw new IllegalStateException(
+                                               "Grouping " + usesNode.groupingPath + "is not resolved for " + builder.name);
+                               }
+                               builder.addImplementsType(genType);
+                       }
+               }
+               return builder;
+       }
 }
index fde03cbdb183061cd7969cbd894ae73494cdaa53..9bb36e07af7b9db928bc6a87e1636a34c525fe6c 100644 (file)
@@ -254,7 +254,8 @@ public final class TypeProviderImpl implements TypeProvider {
      */
     private Type provideTypeForIdentityref(IdentityrefTypeDefinition idref) {
         QName baseIdQName = idref.getIdentity();
-        Module module = schemaContext.findModuleByNamespaceAndRevision(baseIdQName.getNamespace(),baseIdQName.getRevision());
+        Module module = schemaContext.findModuleByNamespaceAndRevision(baseIdQName.getNamespace(),
+                baseIdQName.getRevision());
         IdentitySchemaNode identity = null;
         for (IdentitySchemaNode id : module.getIdentities()) {
             if (id.getQName().equals(baseIdQName)) {
index d84696d13d1b9623fad4f61c43d1215b3506a75f..71644923afbb6bfff86e2e86de1e733b852da4e4 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.yang.data.impl;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;\r
-import org.opendaylight.yangtools.yang.data.api.Node;\r
-import org.opendaylight.yangtools.yang.data.api.NodeModification;\r
-\r
-/**\r
- * @author michal.rehak\r
- * @param <T>\r
- *            type of node value\r
- *\r
- */\r
-public abstract class AbstractNodeTO<T> implements Node<T>, NodeModification {\r
-\r
-    private QName qName;\r
-    private CompositeNode parent;\r
-    private T value;\r
-    private ModifyAction modifyAction;\r
-\r
-    /**\r
-     * @param qname\r
-     * @param parent\r
-     * @param value\r
-     */\r
-    public AbstractNodeTO(QName qname, CompositeNode parent, T value) {\r
-        this.qName = qname;\r
-        this.parent = parent;\r
-        this.value = value;\r
-    }\r
-\r
-    /**\r
-     * @param qname\r
-     * @param parent\r
-     * @param value\r
-     * @param modifyAction\r
-     */\r
-    public AbstractNodeTO(QName qname, CompositeNode parent, T value, ModifyAction modifyAction) {\r
-        this.qName = qname;\r
-        this.parent = parent;\r
-        this.value = value;\r
-        this.modifyAction = modifyAction;\r
-    }\r
-\r
-    @Override\r
-    public QName getNodeType() {\r
-        return qName;\r
-    }\r
-\r
-    /**\r
-     * @return the qName\r
-     */\r
-    public QName getQName() {\r
-        return qName;\r
-    }\r
-\r
-    @Override\r
-    public CompositeNode getParent() {\r
-        return parent;\r
-    }\r
-\r
-    /**\r
-     * @param parent the parent to set\r
-     */\r
-    public void setParent(CompositeNode parent) {\r
-        this.parent = parent;\r
-    }\r
-\r
-    /**\r
-     * @param value the value to set\r
-     */\r
-    protected void setValue(T value) {\r
-        this.value = value;\r
-    }\r
-\r
-    @Override\r
-    public T getValue() {\r
-        return value;\r
-    }\r
-\r
-    /**\r
-     * @return modification action\r
-     * @see org.opendaylight.yangtools.yang.data.impl.NodeModificationSupport#getModificationAction()\r
-     */\r
-    @Override\r
-    public ModifyAction getModificationAction() {\r
-        return modifyAction;\r
-    }\r
-\r
-    /**\r
-     * @param modifyAction\r
-     *            the modifyAction to set\r
-     */\r
-    protected void setModificationAction(ModifyAction modifyAction) {\r
-        this.modifyAction = modifyAction;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        StringBuffer out = new StringBuffer();\r
-        out.append(String.format("Node[%s], qName[%s], modify[%s]",\r
-                getClass().getSimpleName(), getQName().getLocalName(),\r
-                getModificationAction() == null ? "n/a" : getModificationAction()));\r
-        return out.toString();\r
-    }\r
-\r
-    /* */\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result\r
-                + ((modifyAction == null) ? 0 : modifyAction.hashCode());\r
-//        result = prime * result + ((parent == null) ? 0 : parent.hashCode());\r
-        result = prime * result + ((qName == null) ? 0 : qName.hashCode());\r
-        result = prime * result + ((value == null) ? 0 : value.hashCode());\r
-        return result % 2;\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
-        @SuppressWarnings("unchecked")\r
-        AbstractNodeTO<T> other = (AbstractNodeTO<T>) obj;\r
-        if (modifyAction != other.modifyAction)\r
-            return false;\r
-        if (parent == null) {\r
-            if (other.parent != null)\r
-                return false;\r
-        } else if (other.parent == null) {\r
-            return false;\r
-        }\r
-        if (qName == null) {\r
-            if (other.qName != null)\r
-                return false;\r
-        } else if (!qName.equals(other.qName))\r
-            return false;\r
-        if (value == null) {\r
-            if (other.value != null)\r
-                return false;\r
-        } else if (!value.equals(other.value))\r
-            return false;\r
-        return true;\r
-    }\r
-    /* */\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.impl;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.ModifyAction;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.NodeModification;
+
+/**
+ * @author michal.rehak
+ * @param <T>
+ *            type of node value
+ * 
+ */
+public abstract class AbstractNodeTO<T> implements Node<T>, NodeModification {
+
+    private QName qName;
+    private CompositeNode parent;
+    private T value;
+    private ModifyAction modifyAction;
+
+    /**
+     * @param qname
+     * @param parent
+     * @param value
+     */
+    public AbstractNodeTO(QName qname, CompositeNode parent, T value) {
+        this.qName = qname;
+        this.parent = parent;
+        this.value = value;
+    }
+
+    /**
+     * @param qname
+     * @param parent
+     * @param value
+     * @param modifyAction
+     */
+    public AbstractNodeTO(QName qname, CompositeNode parent, T value, ModifyAction modifyAction) {
+        this.qName = qname;
+        this.parent = parent;
+        this.value = value;
+        this.modifyAction = modifyAction;
+    }
+
+    @Override
+    public QName getNodeType() {
+        return qName;
+    }
+
+    /**
+     * @return the qName
+     */
+    public QName getQName() {
+        return qName;
+    }
+
+    @Override
+    public CompositeNode getParent() {
+        return parent;
+    }
+
+    /**
+     * @param parent
+     *            the parent to set
+     */
+    public void setParent(CompositeNode parent) {
+        this.parent = parent;
+    }
+
+    /**
+     * @param value
+     *            the value to set
+     */
+    protected void setValue(T value) {
+        this.value = value;
+    }
+
+    @Override
+    public T getValue() {
+        return value;
+    }
+
+    /**
+     * @return modification action
+     * @see org.opendaylight.yangtools.yang.data.impl.NodeModificationSupport#getModificationAction()
+     */
+    @Override
+    public ModifyAction getModificationAction() {
+        return modifyAction;
+    }
+
+    /**
+     * @param modifyAction
+     *            the modifyAction to set
+     */
+    protected void setModificationAction(ModifyAction modifyAction) {
+        this.modifyAction = modifyAction;
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer out = new StringBuffer();
+        out.append(String.format("Node[%s], qName[%s], modify[%s]", getClass().getSimpleName(), getQName()
+                .getLocalName(), getModificationAction() == null ? "n/a" : getModificationAction()));
+        return out.toString();
+    }
+
+    /* */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((modifyAction == null) ? 0 : modifyAction.hashCode());
+        result = prime * result + ((qName == null) ? 0 : qName.hashCode());
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result % 2;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        @SuppressWarnings("unchecked")
+        AbstractNodeTO<T> other = (AbstractNodeTO<T>) obj;
+        if (modifyAction != other.modifyAction) {
+            return false;
+        }
+        if (parent == null) {
+            if (other.parent != null) {
+                return false;
+            }
+        } else if (other.parent == null) {
+            return false;
+        }
+        if (qName == null) {
+            if (other.qName != null) {
+                return false;
+            }
+        } else if (!qName.equals(other.qName)) {
+            return false;
+        }
+        if (value == null) {
+            if (other.value != null) {
+                return false;
+            }
+        } else if (!value.equals(other.value)) {
+            return false;
+        }
+        return true;
+    }
+    /* */
+
+}
index 5ba7ed8b3c2853c3fc2f4786a8faa2ea7e58c25f..3945fdda5ecfb0ee54aa5dcc1536aaf760ddd5aa 100644 (file)
@@ -91,8 +91,9 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
         List<SimpleNode<?>> list = new ArrayList<SimpleNode<?>>();
 
         for (Node<?> node : toFilter) {
-            if (node instanceof SimpleNode<?>)
+            if (node instanceof SimpleNode<?>) {
                 list.add((SimpleNode<?>) node);
+            }
         }
         return list;
     }
index 62f45beea1a689e297ae61af40c4a5430233e5f3..e55cc0137e4b4b88f5b9c7480287d3409be61017 100644 (file)
@@ -1,63 +1,63 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.data.impl;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;\r
-import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;\r
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;\r
-\r
-/**\r
- * @author michal.rehak\r
- * @param <T> type of simple node value\r
- *\r
- */\r
-public class MutableSimpleNodeTOImpl<T> extends SimpleNodeTOImpl<T>\r
-        implements MutableSimpleNode<T> {\r
-\r
-    private SimpleNode<T> original;\r
-\r
-    /**\r
-     * @param qname\r
-     * @param parent\r
-     * @param value\r
-     * @param modifyAction\r
-     */\r
-    public MutableSimpleNodeTOImpl(QName qname, CompositeNode parent, T value,\r
-            ModifyAction modifyAction) {\r
-        super(qname, parent, value, modifyAction);\r
-    }\r
-\r
-    @Override\r
-    public void setValue(T value) {\r
-        super.setValue(value);\r
-    }\r
-\r
-    @Override\r
-    public void setModifyAction(ModifyAction action) {\r
-        super.setModificationAction(action);\r
-    }\r
-\r
-    @Override\r
-    public MutableSimpleNode<T> asMutable() {\r
-        return this;\r
-    }\r
-\r
-    @Override\r
-    public SimpleNode<T> getOriginal() {\r
-        return original;\r
-    }\r
-\r
-    /**\r
-     * @param original the original to set\r
-     */\r
-    public void setOriginal(SimpleNode<T> original) {\r
-        this.original = original;\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.yang.data.impl;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.ModifyAction;
+import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+
+/**
+ * @author michal.rehak
+ * @param <T>
+ *            type of simple node value
+ * 
+ */
+public class MutableSimpleNodeTOImpl<T> extends SimpleNodeTOImpl<T> implements MutableSimpleNode<T> {
+
+    private SimpleNode<T> original;
+
+    /**
+     * @param qname
+     * @param parent
+     * @param value
+     * @param modifyAction
+     */
+    public MutableSimpleNodeTOImpl(QName qname, CompositeNode parent, T value, ModifyAction modifyAction) {
+        super(qname, parent, value, modifyAction);
+    }
+
+    @Override
+    public void setValue(T value) {
+        super.setValue(value);
+    }
+
+    @Override
+    public void setModifyAction(ModifyAction action) {
+        super.setModificationAction(action);
+    }
+
+    @Override
+    public MutableSimpleNode<T> asMutable() {
+        return this;
+    }
+
+    @Override
+    public SimpleNode<T> getOriginal() {
+        return original;
+    }
+
+    /**
+     * @param original
+     *            the original to set
+     */
+    public void setOriginal(SimpleNode<T> original) {
+        this.original = original;
+    }
+}
index 503b07fc63c77a4fdf9df0e2490b78b63fb4ff1c..f1c2a44a03373ee0126595802740b54cff6beb18 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.yang.data.impl;\r
-\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;\r
-import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.MutableNode;\r
-import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;\r
-import org.opendaylight.yangtools.yang.data.api.Node;\r
-import org.opendaylight.yangtools.yang.data.api.NodeModificationBuilder;\r
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-\r
-/**\r
- * @author michal.rehak\r
- *\r
- */\r
-public class NodeModificationBuilderImpl implements NodeModificationBuilder {\r
-\r
-    private SchemaContext context;\r
-\r
-    private Set<MutableNode<?>> changeLog;\r
-    private LazyNodeToNodeMap originalToMutable;\r
-\r
-    /**\r
-     * @param originalTreeRootNode\r
-     * @param context\r
-     */\r
-    public NodeModificationBuilderImpl(CompositeNode originalTreeRootNode, SchemaContext context) {\r
-        this.context = context;\r
-        originalToMutable = new LazyNodeToNodeMap();\r
-        changeLog = new HashSet<>();\r
-    }\r
-\r
-    /**\r
-     * @param modNode\r
-     * @param action\r
-     */\r
-    private void addModificationToLog(MutableNode<?> modNode, ModifyAction action) {\r
-        modNode.setModifyAction(action);\r
-        changeLog.add(modNode);\r
-    }\r
-\r
-    @Override\r
-    public void addNode(MutableSimpleNode<?> newNode) {\r
-        NodeUtils.fixParentRelation(newNode);\r
-        addModificationToLog(newNode, ModifyAction.CREATE);\r
-    }\r
-\r
-    @Override\r
-    public void addNode(MutableCompositeNode newNode) {\r
-        NodeUtils.fixParentRelation(newNode);\r
-        addModificationToLog(newNode, ModifyAction.CREATE);\r
-    }\r
-\r
-    @Override\r
-    public void replaceNode(MutableSimpleNode<?> replacementNode) {\r
-        addModificationToLog(replacementNode, ModifyAction.REPLACE);\r
-    }\r
-\r
-    @Override\r
-    public void replaceNode(MutableCompositeNode replacementNode) {\r
-        addModificationToLog(replacementNode, ModifyAction.REPLACE);\r
-    }\r
-\r
-    @Override\r
-    public void deleteNode(MutableCompositeNode deadNode) {\r
-        addModificationToLog(deadNode, ModifyAction.DELETE);\r
-    }\r
-\r
-    @Override\r
-    public void deleteNode(MutableSimpleNode<?> deadNode) {\r
-        addModificationToLog(deadNode, ModifyAction.DELETE);\r
-    }\r
-\r
-    @Override\r
-    public void removeNode(MutableSimpleNode<?> deadNode) {\r
-        addModificationToLog(deadNode, ModifyAction.REMOVE);\r
-    }\r
-\r
-    @Override\r
-    public void removeNode(MutableCompositeNode deadNode) {\r
-        addModificationToLog(deadNode, ModifyAction.REMOVE);\r
-    }\r
-\r
-    @Override\r
-    public void mergeNode(MutableCompositeNode alteredNode) {\r
-        addModificationToLog(alteredNode, ModifyAction.MERGE);\r
-    }\r
-\r
-    /**\r
-     * @return minimalistic tree containing diffs only\r
-     */\r
-    @Override\r
-    public CompositeNode buildDiffTree() {\r
-        Set<Node<?>> wanted = new HashSet<>();\r
-\r
-        // walk changeLog, collect all required nodes\r
-        for (MutableNode<?> mutant : changeLog) {\r
-            wanted.addAll(collectSelfAndAllParents(mutant));\r
-        }\r
-\r
-        // walk wanted and add relevant keys\r
-        Map<String, ListSchemaNode>  mapOfLists = NodeUtils.buildMapOfListNodes(context);\r
-        for (Node<?> outlaw : wanted) {\r
-            if (outlaw instanceof CompositeNode) {\r
-                String path = NodeUtils.buildPath(outlaw);\r
-                if (mapOfLists.containsKey(path)) {\r
-                    ListSchemaNode listSchema = mapOfLists.get(path);\r
-                    if (listSchema.getQName().equals(outlaw.getNodeType())) {\r
-                        // try to add key subnode to wanted list\r
-                        List<QName> supportedKeys = listSchema.getKeyDefinition();\r
-                        CompositeNode outlawOriginal = ((MutableCompositeNode) outlaw).getOriginal();\r
-                        for (Node<?> outlawOriginalChild : outlawOriginal.getChildren()) {\r
-                            if (supportedKeys.contains(outlawOriginalChild.getNodeType())) {\r
-                                originalToMutable.getMutableEquivalent(outlawOriginalChild);\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        return originalToMutable.getMutableRoot();\r
-    }\r
-\r
-    /**\r
-     * @param focusedDescendant\r
-     * @return set of parents and focusedAncestor itself\r
-     */\r
-    private static Set<Node<?>> collectSelfAndAllParents(Node<?> focusedDescendant) {\r
-        Set<Node<?>> family = new HashSet<>();\r
-        Node<?> tmpNode = focusedDescendant;\r
-        while (tmpNode != null) {\r
-            family.add(tmpNode);\r
-            tmpNode = tmpNode.getParent();\r
-        }\r
-        return family;\r
-    }\r
-\r
-    /**\r
-     * @param originalNode\r
-     * @return mutable version of given node\r
-     */\r
-    @Override\r
-    public Node<?> getMutableEquivalent(Node<?> originalNode) {\r
-        return originalToMutable.getMutableEquivalent(originalNode);\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.yang.data.impl;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.ModifyAction;
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableNode;
+import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.NodeModificationBuilder;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+/**
+ * @author michal.rehak
+ * 
+ */
+public class NodeModificationBuilderImpl implements NodeModificationBuilder {
+
+    private SchemaContext context;
+
+    private Set<MutableNode<?>> changeLog;
+    private LazyNodeToNodeMap originalToMutable;
+
+    /**
+     * @param context
+     */
+    public NodeModificationBuilderImpl(SchemaContext context) {
+        this.context = context;
+        originalToMutable = new LazyNodeToNodeMap();
+        changeLog = new HashSet<>();
+    }
+
+    /**
+     * @param modNode
+     * @param action
+     */
+    private void addModificationToLog(MutableNode<?> modNode, ModifyAction action) {
+        modNode.setModifyAction(action);
+        changeLog.add(modNode);
+    }
+
+    @Override
+    public void addNode(MutableSimpleNode<?> newNode) {
+        NodeUtils.fixParentRelation(newNode);
+        addModificationToLog(newNode, ModifyAction.CREATE);
+    }
+
+    @Override
+    public void addNode(MutableCompositeNode newNode) {
+        NodeUtils.fixParentRelation(newNode);
+        addModificationToLog(newNode, ModifyAction.CREATE);
+    }
+
+    @Override
+    public void replaceNode(MutableSimpleNode<?> replacementNode) {
+        addModificationToLog(replacementNode, ModifyAction.REPLACE);
+    }
+
+    @Override
+    public void replaceNode(MutableCompositeNode replacementNode) {
+        addModificationToLog(replacementNode, ModifyAction.REPLACE);
+    }
+
+    @Override
+    public void deleteNode(MutableCompositeNode deadNode) {
+        addModificationToLog(deadNode, ModifyAction.DELETE);
+    }
+
+    @Override
+    public void deleteNode(MutableSimpleNode<?> deadNode) {
+        addModificationToLog(deadNode, ModifyAction.DELETE);
+    }
+
+    @Override
+    public void removeNode(MutableSimpleNode<?> deadNode) {
+        addModificationToLog(deadNode, ModifyAction.REMOVE);
+    }
+
+    @Override
+    public void removeNode(MutableCompositeNode deadNode) {
+        addModificationToLog(deadNode, ModifyAction.REMOVE);
+    }
+
+    @Override
+    public void mergeNode(MutableCompositeNode alteredNode) {
+        addModificationToLog(alteredNode, ModifyAction.MERGE);
+    }
+
+    /**
+     * @return minimalistic tree containing diffs only
+     */
+    @Override
+    public CompositeNode buildDiffTree() {
+        Set<Node<?>> wanted = new HashSet<>();
+
+        // walk changeLog, collect all required nodes
+        for (MutableNode<?> mutant : changeLog) {
+            wanted.addAll(collectSelfAndAllParents(mutant));
+        }
+
+        // walk wanted and add relevant keys
+        Map<String, ListSchemaNode> mapOfLists = NodeUtils.buildMapOfListNodes(context);
+        for (Node<?> outlaw : wanted) {
+            if (outlaw instanceof CompositeNode) {
+                String path = NodeUtils.buildPath(outlaw);
+                if (mapOfLists.containsKey(path)) {
+                    ListSchemaNode listSchema = mapOfLists.get(path);
+                    if (listSchema.getQName().equals(outlaw.getNodeType())) {
+                        // try to add key subnode to wanted list
+                        List<QName> supportedKeys = listSchema.getKeyDefinition();
+                        CompositeNode outlawOriginal = ((MutableCompositeNode) outlaw).getOriginal();
+                        for (Node<?> outlawOriginalChild : outlawOriginal.getChildren()) {
+                            if (supportedKeys.contains(outlawOriginalChild.getNodeType())) {
+                                originalToMutable.getMutableEquivalent(outlawOriginalChild);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return originalToMutable.getMutableRoot();
+    }
+
+    /**
+     * @param focusedDescendant
+     * @return set of parents and focusedAncestor itself
+     */
+    private static Set<Node<?>> collectSelfAndAllParents(Node<?> focusedDescendant) {
+        Set<Node<?>> family = new HashSet<>();
+        Node<?> tmpNode = focusedDescendant;
+        while (tmpNode != null) {
+            family.add(tmpNode);
+            tmpNode = tmpNode.getParent();
+        }
+        return family;
+    }
+
+    /**
+     * @param originalNode
+     * @return mutable version of given node
+     */
+    @Override
+    public Node<?> getMutableEquivalent(Node<?> originalNode) {
+        return originalToMutable.getMutableEquivalent(originalNode);
+    }
+
+}
index df7960ddb86ebf91f69f95930daa7042a4bde3f3..6473c8100a15f7f615eb314e9df2bd31812c8789 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.yang.data.impl;\r
-\r
-import java.util.AbstractMap.SimpleEntry;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Stack;\r
-import java.util.Vector;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-import javax.xml.xpath.XPath;\r
-import javax.xml.xpath.XPathConstants;\r
-import javax.xml.xpath.XPathExpression;\r
-import javax.xml.xpath.XPathExpressionException;\r
-import javax.xml.xpath.XPathFactory;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;\r
-import org.opendaylight.yangtools.yang.data.api.Node;\r
-import org.opendaylight.yangtools.yang.data.api.NodeModification;\r
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;\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.ListSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.w3c.dom.Element;\r
-\r
-import com.google.common.base.Joiner;\r
-import com.google.common.collect.Lists;\r
-\r
-\r
-/**\r
- * @author michal.rehak\r
- *\r
- */\r
-public abstract class NodeUtils {\r
-\r
-    private static final Logger LOG = LoggerFactory.getLogger(NodeUtils.class);\r
-\r
-    /**\r
-     *\r
-     */\r
-    private static final String USER_KEY_NODE = "node";\r
-\r
-    /**\r
-     * @param node\r
-     * @return node path up till root node\r
-     */\r
-    public static String buildPath(Node<?> node) {\r
-        Vector<String> breadCrumbs = new Vector<>();\r
-        Node<?> tmpNode = node;\r
-        while (tmpNode != null) {\r
-            breadCrumbs.insertElementAt(tmpNode.getNodeType().getLocalName(), 0);\r
-            tmpNode = tmpNode.getParent();\r
-        }\r
-\r
-        return Joiner.on(".").join(breadCrumbs);\r
-    }\r
-\r
-\r
-    /**\r
-     * @param treeRootNode\r
-     * @return dom tree, containing same node structure, yang nodes are associated\r
-     * to dom nodes as user data\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.yang.data.impl;
+
+import java.util.AbstractMap.SimpleEntry;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.ModifyAction;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.NodeModification;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
+/**
+ * @author michal.rehak
+ * 
+ */
+public abstract class NodeUtils {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NodeUtils.class);
+
+    /**
+     *
+     */
+    private static final String USER_KEY_NODE = "node";
+
+    /**
+     * @param node
+     * @return node path up till root node
+     */
+    public static String buildPath(Node<?> node) {
+        List<String> breadCrumbs = new ArrayList<>();
+        Node<?> tmpNode = node;
+        while (tmpNode != null) {
+            breadCrumbs.add(0, tmpNode.getNodeType().getLocalName());
+            tmpNode = tmpNode.getParent();
+        }
+
+        return Joiner.on(".").join(breadCrumbs);
+    }
+
+    /**
+     * @param treeRootNode
+     * @return dom tree, containing same node structure, yang nodes are
+     *         associated to dom nodes as user data
+     */
     public static org.w3c.dom.Document buildShadowDomTree(CompositeNode treeRootNode) {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-        org.w3c.dom.Document doc = null;\r
-        try {\r
-            DocumentBuilder bob = dbf.newDocumentBuilder();\r
-            doc = bob.newDocument();\r
-        } catch (ParserConfigurationException e) {\r
-            LOG.error("documentBuilder problem", e);\r
-            return null;\r
-        }\r
-\r
-\r
-        Stack<SimpleEntry<org.w3c.dom.Node, Node<?>>> jobQueue = new Stack<>();\r
-        jobQueue.push(new SimpleEntry<org.w3c.dom.Node, Node<?>>(doc, treeRootNode));\r
-\r
-        while (!jobQueue.isEmpty()) {\r
-            SimpleEntry<org.w3c.dom.Node, Node<?>> job = jobQueue.pop();\r
-            org.w3c.dom.Node jointPlace = job.getKey();\r
-            Node<?> item = job.getValue();\r
-            QName nodeType = item.getNodeType();\r
-            Element itemEl = doc.createElementNS(nodeType.getNamespace().toString(),\r
-                    item.getNodeType().getLocalName());\r
-            itemEl.setUserData(USER_KEY_NODE, item, null);\r
-            if (item instanceof SimpleNode<?>) {\r
-                Object value = ((SimpleNode<?>) item).getValue();\r
-                itemEl.setTextContent(String.valueOf(value));\r
-                //itemEl.setAttribute("type", value.getClass().getSimpleName());\r
-            }\r
-            if (item instanceof NodeModification) {\r
-                ModifyAction modificationAction = ((NodeModification) item).getModificationAction();\r
-                if (modificationAction != null) {\r
-                    itemEl.setAttribute("modifyAction", modificationAction.toString());\r
-                }\r
-            }\r
-\r
-            jointPlace.appendChild(itemEl);\r
-\r
-            if (item instanceof CompositeNode) {\r
-                for (Node<?> child : ((CompositeNode) item).getChildren()) {\r
-                    jobQueue.push(new SimpleEntry<org.w3c.dom.Node, Node<?>>(itemEl, child));\r
-                }\r
-            }\r
-        }\r
-\r
-        return doc;\r
-    }\r
-\r
-    /**\r
-     * @param doc\r
-     * @param xpathEx\r
-     * @return user data value on found node\r
-     * @throws XPathExpressionException\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    public static <T> T findNodeByXpath(org.w3c.dom.Document doc, String xpathEx)\r
-            throws XPathExpressionException {\r
-        T userNode = null;\r
-        XPathFactory xPathfactory = XPathFactory.newInstance();\r
-        XPath xpath = xPathfactory.newXPath();\r
-        XPathExpression expr = xpath.compile(xpathEx);\r
-\r
-        org.w3c.dom.Node result = (org.w3c.dom.Node) expr.evaluate(doc, XPathConstants.NODE);\r
-        if (result != null) {\r
-            userNode = (T) result.getUserData(USER_KEY_NODE);\r
-        }\r
-\r
-        return userNode;\r
-    }\r
-\r
-\r
-    /**\r
-     * build NodeMap, where key = qName; value = node\r
-     *\r
-     * @param value\r
-     * @return map of children, where key = qName and value is list of children groupped by qName\r
-     */\r
-    public static Map<QName, List<Node<?>>> buildNodeMap(List<Node<?>> value) {\r
-        Map<QName, List<Node<?>>> nodeMapTmp = new HashMap<>();\r
-        if (value == null || value.isEmpty()) {\r
-            throw new IllegalStateException(\r
-                    "nodeList should not be null or empty");\r
-        }\r
-        for (Node<?> node : value) {\r
-            List<Node<?>> qList = nodeMapTmp.get(node.getNodeType());\r
-            if (qList == null) {\r
-                qList = new ArrayList<>();\r
-                nodeMapTmp.put(node.getNodeType(), qList);\r
-            }\r
-            qList.add(node);\r
-        }\r
-        return nodeMapTmp;\r
-    }\r
-\r
-\r
-    /**\r
-     * @param context\r
-     * @return map of lists, where key = path; value = {@link DataSchemaNode}\r
-     */\r
-    public static Map<String, ListSchemaNode> buildMapOfListNodes(\r
-            SchemaContext context) {\r
-        Map<String, ListSchemaNode> mapOfLists = new HashMap<>();\r
-\r
-        Stack<DataSchemaNode> jobQueue = new Stack<>();\r
-        jobQueue.addAll(context.getDataDefinitions());\r
-\r
-        while (!jobQueue.isEmpty()) {\r
-            DataSchemaNode dataSchema = jobQueue.pop();\r
-            if (dataSchema instanceof ListSchemaNode) {\r
-                mapOfLists.put(schemaPathToPath(dataSchema.getPath().getPath()), (ListSchemaNode) dataSchema);\r
-            }\r
-\r
-            if (dataSchema instanceof DataNodeContainer) {\r
-                jobQueue.addAll(((DataNodeContainer) dataSchema).getChildNodes());\r
-            }\r
-        }\r
-\r
-        return mapOfLists;\r
-    }\r
-\r
-    /**\r
-     * @param path\r
-     * @return\r
-     */\r
-    private static String schemaPathToPath(List<QName> qNamesPath) {\r
-        List<String> pathSeed = new ArrayList<>();\r
-        for (QName qNameItem : qNamesPath) {\r
-            pathSeed.add(qNameItem.getLocalName());\r
-        }\r
-        return Joiner.on(".").join(pathSeed);\r
-    }\r
-\r
-    /**\r
-     * add given node to it's parent's list of children\r
-     * @param newNode\r
-     */\r
-    public static void fixParentRelation(Node<?> newNode) {\r
-        if (newNode.getParent() != null) {\r
-            List<Node<?>> siblings = newNode.getParent().getChildren();\r
-            if (!siblings.contains(newNode)) {\r
-                siblings.add(newNode);\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * crawl all children of given node and assign it as their parent\r
-     * @param parentNode\r
-     */\r
-    public static void fixChildrenRelation(CompositeNode parentNode) {\r
-        if (parentNode.getChildren() != null) {\r
-            for (Node<?> child : parentNode.getChildren()) {\r
-                if (child instanceof AbstractNodeTO<?>) {\r
-                    ((AbstractNodeTO<?>) child).setParent(parentNode);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-    /**\r
-     * @param keys\r
-     * @param dataMap\r
-     * @return list of values of map, found by given keys\r
-     */\r
-    public static <T, K> List<K> collectMapValues(List<T> keys,\r
-            Map<T, K> dataMap) {\r
-        List<K> valueSubList = new ArrayList<>();\r
-        for (T key : keys) {\r
-            valueSubList.add(dataMap.get(key));\r
-        }\r
-\r
-        return valueSubList;\r
-    }\r
-\r
-    /**\r
-     * @param nodes\r
-     * @return list of children in list of appropriate type\r
-     */\r
-    public static List<Node<?>> buildChildrenList(Node<?>...nodes) {\r
-        return Lists.newArrayList(nodes);\r
-    }\r
-\r
-}\r
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        org.w3c.dom.Document doc = null;
+        try {
+            DocumentBuilder bob = dbf.newDocumentBuilder();
+            doc = bob.newDocument();
+        } catch (ParserConfigurationException e) {
+            LOG.error("documentBuilder problem", e);
+            return null;
+        }
+
+        Stack<SimpleEntry<org.w3c.dom.Node, Node<?>>> jobQueue = new Stack<>();
+        jobQueue.push(new SimpleEntry<org.w3c.dom.Node, Node<?>>(doc, treeRootNode));
+
+        while (!jobQueue.isEmpty()) {
+            SimpleEntry<org.w3c.dom.Node, Node<?>> job = jobQueue.pop();
+            org.w3c.dom.Node jointPlace = job.getKey();
+            Node<?> item = job.getValue();
+            QName nodeType = item.getNodeType();
+            Element itemEl = doc.createElementNS(nodeType.getNamespace().toString(), item.getNodeType().getLocalName());
+            itemEl.setUserData(USER_KEY_NODE, item, null);
+            if (item instanceof SimpleNode<?>) {
+                Object value = ((SimpleNode<?>) item).getValue();
+                itemEl.setTextContent(String.valueOf(value));
+            }
+            if (item instanceof NodeModification) {
+                ModifyAction modificationAction = ((NodeModification) item).getModificationAction();
+                if (modificationAction != null) {
+                    itemEl.setAttribute("modifyAction", modificationAction.toString());
+                }
+            }
+
+            jointPlace.appendChild(itemEl);
+
+            if (item instanceof CompositeNode) {
+                for (Node<?> child : ((CompositeNode) item).getChildren()) {
+                    jobQueue.push(new SimpleEntry<org.w3c.dom.Node, Node<?>>(itemEl, child));
+                }
+            }
+        }
+
+        return doc;
+    }
+
+    /**
+     * @param doc
+     * @param xpathEx
+     * @return user data value on found node
+     * @throws XPathExpressionException
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T findNodeByXpath(org.w3c.dom.Document doc, String xpathEx) throws XPathExpressionException {
+        T userNode = null;
+        XPathFactory xPathfactory = XPathFactory.newInstance();
+        XPath xpath = xPathfactory.newXPath();
+        XPathExpression expr = xpath.compile(xpathEx);
+
+        org.w3c.dom.Node result = (org.w3c.dom.Node) expr.evaluate(doc, XPathConstants.NODE);
+        if (result != null) {
+            userNode = (T) result.getUserData(USER_KEY_NODE);
+        }
+
+        return userNode;
+    }
+
+    /**
+     * build NodeMap, where key = qName; value = node
+     * 
+     * @param value
+     * @return map of children, where key = qName and value is list of children
+     *         groupped by qName
+     */
+    public static Map<QName, List<Node<?>>> buildNodeMap(List<Node<?>> value) {
+        Map<QName, List<Node<?>>> nodeMapTmp = new HashMap<>();
+        if (value == null || value.isEmpty()) {
+            throw new IllegalStateException("nodeList should not be null or empty");
+        }
+        for (Node<?> node : value) {
+            List<Node<?>> qList = nodeMapTmp.get(node.getNodeType());
+            if (qList == null) {
+                qList = new ArrayList<>();
+                nodeMapTmp.put(node.getNodeType(), qList);
+            }
+            qList.add(node);
+        }
+        return nodeMapTmp;
+    }
+
+    /**
+     * @param context
+     * @return map of lists, where key = path; value = {@link DataSchemaNode}
+     */
+    public static Map<String, ListSchemaNode> buildMapOfListNodes(SchemaContext context) {
+        Map<String, ListSchemaNode> mapOfLists = new HashMap<>();
+
+        Stack<DataSchemaNode> jobQueue = new Stack<>();
+        jobQueue.addAll(context.getDataDefinitions());
+
+        while (!jobQueue.isEmpty()) {
+            DataSchemaNode dataSchema = jobQueue.pop();
+            if (dataSchema instanceof ListSchemaNode) {
+                mapOfLists.put(schemaPathToPath(dataSchema.getPath().getPath()), (ListSchemaNode) dataSchema);
+            }
+
+            if (dataSchema instanceof DataNodeContainer) {
+                jobQueue.addAll(((DataNodeContainer) dataSchema).getChildNodes());
+            }
+        }
+
+        return mapOfLists;
+    }
+
+    /**
+     * @param path
+     * @return
+     */
+    private static String schemaPathToPath(List<QName> qNamesPath) {
+        List<String> pathSeed = new ArrayList<>();
+        for (QName qNameItem : qNamesPath) {
+            pathSeed.add(qNameItem.getLocalName());
+        }
+        return Joiner.on(".").join(pathSeed);
+    }
+
+    /**
+     * add given node to it's parent's list of children
+     * 
+     * @param newNode
+     */
+    public static void fixParentRelation(Node<?> newNode) {
+        if (newNode.getParent() != null) {
+            List<Node<?>> siblings = newNode.getParent().getChildren();
+            if (!siblings.contains(newNode)) {
+                siblings.add(newNode);
+            }
+        }
+    }
+
+    /**
+     * crawl all children of given node and assign it as their parent
+     * 
+     * @param parentNode
+     */
+    public static void fixChildrenRelation(CompositeNode parentNode) {
+        if (parentNode.getChildren() != null) {
+            for (Node<?> child : parentNode.getChildren()) {
+                if (child instanceof AbstractNodeTO<?>) {
+                    ((AbstractNodeTO<?>) child).setParent(parentNode);
+                }
+            }
+        }
+    }
+
+    /**
+     * @param keys
+     * @param dataMap
+     * @return list of values of map, found by given keys
+     */
+    public static <T, K> List<K> collectMapValues(List<T> keys, Map<T, K> dataMap) {
+        List<K> valueSubList = new ArrayList<>();
+        for (T key : keys) {
+            valueSubList.add(dataMap.get(key));
+        }
+
+        return valueSubList;
+    }
+
+    /**
+     * @param nodes
+     * @return list of children in list of appropriate type
+     */
+    public static List<Node<?>> buildChildrenList(Node<?>... nodes) {
+        return Lists.newArrayList(nodes);
+    }
+
+}
index c6558f62273a85cc16c65211e85535f1f9a6b0df..f7fc7c22b8537663c70d10569c1fd3c6d679ec1b 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.yang.data.impl;\r
-\r
-import java.net.URI;\r
-import java.util.Date;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;\r
-import org.opendaylight.yangtools.yang.data.api.Node;\r
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.w3c.dom.Document;\r
-\r
-/**\r
- * @author michal.rehak\r
- *\r
- */\r
-public class NodeModificationBuilderImplTest {\r
-\r
-    private static final Logger LOG = LoggerFactory\r
-            .getLogger(NodeModificationBuilderImplTest.class);\r
-\r
-    private SchemaContext schemaCtx;\r
-    private QName qName;\r
-    private CompositeNode network;\r
-    private NodeModificationBuilderImpl nodeModificationBuilder;\r
-\r
-    private String ns;\r
-\r
-    /**\r
-     * @throws Exception\r
-     */\r
-    private void dumpResult() throws Exception {\r
-        CompositeNode diffTree = nodeModificationBuilder.buildDiffTree();\r
-        CompositeNode diffTreeImmutable = NodeFactory.copyDeepAsImmutable(diffTree, null);\r
-\r
-        Document diffShadow = NodeUtils.buildShadowDomTree(diffTreeImmutable);\r
-        NodeHelper.dumpDoc(diffShadow, System.out);\r
-    }\r
-\r
-    /**\r
-     * prepare schemaContext\r
-     * @throws Exception\r
-     */\r
-    @Before\r
-    public void setUp() throws Exception {\r
-        schemaCtx = NodeHelper.loadSchemaContext();\r
-\r
-        ns = "urn:opendaylight:controller:network";\r
-        qName = new QName(\r
-                new URI(ns),\r
-                new Date(1369000800000L), "topos");\r
-        network = NodeHelper.buildTestConfigTree(qName);\r
-\r
-        nodeModificationBuilder = new NodeModificationBuilderImpl(network, schemaCtx);\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#getMutableEquivalent(org.opendaylight.yangtools.yang.data.api.Node)}\r
-     * .\r
-     */\r
-    @Test\r
-    public void testGetMutableEquivalent() {\r
-        MutableCompositeNode rootMutable = (MutableCompositeNode)\r
-                nodeModificationBuilder.getMutableEquivalent(network);\r
-\r
-        CompositeNode topologies = network.getCompositesByName("topologies").iterator().next();\r
-        Node<?> mutableEquivalent = nodeModificationBuilder.getMutableEquivalent(topologies);\r
-        CompositeNode topologiesMutable = rootMutable.getCompositesByName("topologies").iterator().next();\r
-\r
-        Assert.assertSame(topologiesMutable, mutableEquivalent);\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeAddSimple() throws Exception {\r
-        LOG.debug("testBuildDiffTreeAddSimple");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));\r
-\r
-        MutableCompositeNode mutableParent = (MutableCompositeNode)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(\r
-                new QName(needle.getNodeType(), "anySubNode"), mutableParent, "42", null, null);\r
-\r
-        nodeModificationBuilder.addNode(newMutable);\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeAddComposite() throws Exception {\r
-        LOG.debug("testBuildDiffTreeAddComposite");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));\r
-\r
-        MutableCompositeNode mutableParent = (MutableCompositeNode)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(\r
-                new QName(needle.getNodeType(), "anySubNode"), null, "42", null, null);\r
-\r
-        MutableCompositeNode newMutableCom = NodeFactory.createMutableCompositeNode(\r
-                new QName(needle.getNodeType(), "anySubNode"), mutableParent,\r
-                NodeUtils.buildChildrenList(newMutable), null, null);\r
-        NodeUtils.fixChildrenRelation(newMutableCom);\r
-        newMutableCom.init();\r
-\r
-        nodeModificationBuilder.addNode(newMutableCom);\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeDeleteComposite() throws Exception {\r
-        LOG.debug("testBuildDiffTreeDeleteComposite");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        nodeModificationBuilder.deleteNode(mutableNeedle.getParent().asMutable());\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeDeleteSimple() throws Exception {\r
-        LOG.debug("testBuildDiffTreeDeleteSimple");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        nodeModificationBuilder.deleteNode(mutableNeedle);\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeMerge() throws Exception {\r
-        LOG.debug("testBuildDiffTreeMerge");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        mutableNeedle.setValue("tpId_18x");\r
-        nodeModificationBuilder.mergeNode(mutableNeedle.getParent().asMutable());\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeRemoveComposite() throws Exception {\r
-        LOG.debug("testBuildDiffTreeRemoveComposite");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        nodeModificationBuilder.removeNode(mutableNeedle.getParent().asMutable());\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeRemoveSimple() throws Exception {\r
-        LOG.debug("testBuildDiffTreeRemoveSimple");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        nodeModificationBuilder.removeNode(mutableNeedle);\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeReplaceComposite() throws Exception {\r
-        LOG.debug("testBuildDiffTreeReplaceComposite");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        mutableNeedle.setValue("tpId_18x");\r
-        nodeModificationBuilder.replaceNode(mutableNeedle.getParent().asMutable());\r
-        dumpResult();\r
-    }\r
-\r
-    /**\r
-     * Test method for\r
-     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
-     * .\r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testBuildDiffTreeReplaceSimple() throws Exception {\r
-        LOG.debug("testBuildDiffTreeReplaceSimple");\r
-        Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
-        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
-                NodeHelper.AddNamespaceToPattern(\r
-                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
-        @SuppressWarnings("unchecked")\r
-        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
-                nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
-        mutableNeedle.setValue("tpId_18x");\r
-        nodeModificationBuilder.replaceNode(mutableNeedle);\r
-        dumpResult();\r
-    }\r
-\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.impl;
+
+import java.net.URI;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+/**
+ * @author michal.rehak
+ * 
+ */
+public class NodeModificationBuilderImplTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NodeModificationBuilderImplTest.class);
+
+    private SchemaContext schemaCtx;
+    private QName qName;
+    private CompositeNode network;
+    private NodeModificationBuilderImpl nodeModificationBuilder;
+
+    private String ns;
+
+    /**
+     * @throws Exception
+     */
+    private void dumpResult() throws Exception {
+        CompositeNode diffTree = nodeModificationBuilder.buildDiffTree();
+        CompositeNode diffTreeImmutable = NodeFactory.copyDeepAsImmutable(diffTree, null);
+
+        Document diffShadow = NodeUtils.buildShadowDomTree(diffTreeImmutable);
+        NodeHelper.dumpDoc(diffShadow, System.out);
+    }
+
+    /**
+     * prepare schemaContext
+     * 
+     * @throws Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        schemaCtx = NodeHelper.loadSchemaContext();
+
+        ns = "urn:opendaylight:controller:network";
+        qName = new QName(new URI(ns), new Date(1369000800000L), "topos");
+        network = NodeHelper.buildTestConfigTree(qName);
+
+        nodeModificationBuilder = new NodeModificationBuilderImpl(schemaCtx);
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#getMutableEquivalent(org.opendaylight.yangtools.yang.data.api.Node)}
+     * .
+     */
+    @Test
+    public void testGetMutableEquivalent() {
+        MutableCompositeNode rootMutable = (MutableCompositeNode) nodeModificationBuilder.getMutableEquivalent(network);
+
+        CompositeNode topologies = network.getCompositesByName("topologies").iterator().next();
+        Node<?> mutableEquivalent = nodeModificationBuilder.getMutableEquivalent(topologies);
+        CompositeNode topologiesMutable = rootMutable.getCompositesByName("topologies").iterator().next();
+
+        Assert.assertSame(topologiesMutable, mutableEquivalent);
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeAddSimple() throws Exception {
+        LOG.debug("testBuildDiffTreeAddSimple");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,
+                NodeHelper.AddNamespaceToPattern("//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));
+
+        MutableCompositeNode mutableParent = (MutableCompositeNode) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(new QName(needle.getNodeType(),
+                "anySubNode"), mutableParent, "42", null, null);
+
+        nodeModificationBuilder.addNode(newMutable);
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeAddComposite() throws Exception {
+        LOG.debug("testBuildDiffTreeAddComposite");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,
+                NodeHelper.AddNamespaceToPattern("//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));
+
+        MutableCompositeNode mutableParent = (MutableCompositeNode) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(new QName(needle.getNodeType(),
+                "anySubNode"), null, "42", null, null);
+
+        MutableCompositeNode newMutableCom = NodeFactory.createMutableCompositeNode(new QName(needle.getNodeType(),
+                "anySubNode"), mutableParent, NodeUtils.buildChildrenList(newMutable), null, null);
+        NodeUtils.fixChildrenRelation(newMutableCom);
+        newMutableCom.init();
+
+        nodeModificationBuilder.addNode(newMutableCom);
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeDeleteComposite() throws Exception {
+        LOG.debug("testBuildDiffTreeDeleteComposite");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        nodeModificationBuilder.deleteNode(mutableNeedle.getParent().asMutable());
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeDeleteSimple() throws Exception {
+        LOG.debug("testBuildDiffTreeDeleteSimple");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        nodeModificationBuilder.deleteNode(mutableNeedle);
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeMerge() throws Exception {
+        LOG.debug("testBuildDiffTreeMerge");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        mutableNeedle.setValue("tpId_18x");
+        nodeModificationBuilder.mergeNode(mutableNeedle.getParent().asMutable());
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeRemoveComposite() throws Exception {
+        LOG.debug("testBuildDiffTreeRemoveComposite");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        nodeModificationBuilder.removeNode(mutableNeedle.getParent().asMutable());
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeRemoveSimple() throws Exception {
+        LOG.debug("testBuildDiffTreeRemoveSimple");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        nodeModificationBuilder.removeNode(mutableNeedle);
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeReplaceComposite() throws Exception {
+        LOG.debug("testBuildDiffTreeReplaceComposite");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        mutableNeedle.setValue("tpId_18x");
+        nodeModificationBuilder.replaceNode(mutableNeedle.getParent().asMutable());
+        dumpResult();
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+     * .
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testBuildDiffTreeReplaceSimple() throws Exception {
+        LOG.debug("testBuildDiffTreeReplaceSimple");
+        Document networkShadow = NodeUtils.buildShadowDomTree(network);
+        SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+                "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+        @SuppressWarnings("unchecked")
+        MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+                .getMutableEquivalent(needle);
+
+        mutableNeedle.setValue("tpId_18x");
+        nodeModificationBuilder.replaceNode(mutableNeedle);
+        dumpResult();
+    }
+
+}
index 0621cb4ab6518b2e886b665b910fb30e12b797fb..d5c53338a4b64e3c85d69d7a03abe1324cd3cf0a 100644 (file)
@@ -36,22 +36,31 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
 final class Util {
+
+    /**
+     * It isn't desirable to create instances of this class
+     */
+    private Util() {
+    }
+
     static final String YANG_SUFFIX = "yang";
 
+    private static final int CACHE_SIZE = 10;
     // Cache for listed directories and found yang files. Typically yang files
     // are utilized twice. First: code is generated during generate-sources
     // phase Second: yang files are copied as resources during
     // generate-resources phase. This cache ensures that yang files are listed
     // only once.
-    private static Map<File, Collection<File>> cache = Maps.newHashMapWithExpectedSize(10);
+    private static Map<File, Collection<File>> cache = Maps.newHashMapWithExpectedSize(CACHE_SIZE);
 
     /**
      * List files recursively and return as array of String paths. Use cache of
      * size 1.
      */
     static Collection<File> listFiles(File root) throws FileNotFoundException {
-        if (cache.get(root) != null)
+        if (cache.get(root) != null) {
             return cache.get(root);
+        }
 
         if (!root.exists()) {
             throw new FileNotFoundException(root.toString());
@@ -78,7 +87,7 @@ final class Util {
                 }
             }
             if (excluded) {
-                if(log != null) {
+                if (log != null) {
                     log.info(Util.message("%s file excluded %s", YangToSourcesProcessor.LOG_PREFIX,
                             Util.YANG_SUFFIX.toUpperCase(), f));
                 }
@@ -131,15 +140,17 @@ final class Util {
     private static Class<?> resolveClass(String codeGeneratorClass, Class<?> baseType) throws ClassNotFoundException {
         Class<?> clazz = Class.forName(codeGeneratorClass);
 
-        if (!isImplemented(baseType, clazz))
+        if (!isImplemented(baseType, clazz)) {
             throw new IllegalArgumentException("Code generator " + clazz + " has to implement " + baseType);
+        }
         return clazz;
     }
 
     private static boolean isImplemented(Class<?> expectedIface, Class<?> byClazz) {
         for (Class<?> iface : byClazz.getInterfaces()) {
-            if (iface.equals(expectedIface))
+            if (iface.equals(expectedIface)) {
                 return true;
+            }
         }
         return false;
     }
@@ -170,8 +181,8 @@ final class Util {
         return Preconditions.checkNotNull(obj, "Parameter " + paramName + " is null");
     }
 
-    final static class YangsInZipsResult implements Closeable {
-        final List<InputStream> yangStreams;
+    static final class YangsInZipsResult implements Closeable {
+        private final List<InputStream> yangStreams;
         private final List<Closeable> zipInputStreams;
 
         private YangsInZipsResult(List<InputStream> yangStreams, List<Closeable> zipInputStreams) {
@@ -188,6 +199,10 @@ final class Util {
                 is.close();
             }
         }
+
+        public List<InputStream> getYangStreams() {
+            return this.yangStreams;
+        }
     }
 
     static YangsInZipsResult findYangFilesInDependenciesAsStream(Log log, MavenProject project)
@@ -225,14 +240,13 @@ final class Util {
                         ZipEntry entry = entries.nextElement();
                         String entryName = entry.getName();
 
-                        if (entryName.startsWith(YangToSourcesProcessor.META_INF_YANG_STRING_JAR)) {
-                            if (entry.isDirectory() == false && entryName.endsWith(".yang")) {
-                                foundFilesForReporting.add(entryName);
-                                // This will be closed after all strams are
-                                // parsed.
-                                InputStream entryStream = zip.getInputStream(entry);
-                                yangsFromDependencies.add(entryStream);
-                            }
+                        if (entryName.startsWith(YangToSourcesProcessor.META_INF_YANG_STRING_JAR)
+                                && !entry.isDirectory() && entryName.endsWith(".yang")) {
+                            foundFilesForReporting.add(entryName);
+                            // This will be closed after all strams are
+                            // parsed.
+                            InputStream entryStream = zip.getInputStream(entry);
+                            yangsFromDependencies.add(entryStream);
                         }
                     }
                 }
@@ -248,7 +262,7 @@ final class Util {
         return new YangsInZipsResult(yangsFromDependencies, zips);
     }
 
-    final static class ContextHolder {
+    static final class ContextHolder {
         private final SchemaContext context;
         private final Set<Module> yangModules;
 
index cebef8c69c97f224e5578ad2724732e7f8a0db9f..429b57ce70f2e79f7d4a609a90c23d4bce3f05ad 100644 (file)
@@ -20,7 +20,6 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
 import org.slf4j.impl.StaticLoggerBinder;
 
@@ -56,13 +55,14 @@ public final class YangToSourcesMojo extends AbstractMojo {
      * with .yang suffix).
      */
     @Parameter(required = false)
-    private String yangFilesRootDir; // defaults to ${basedir}/src/main/yang
+    // defaults to ${basedir}/src/main/yang
+    private String yangFilesRootDir;
 
     @Parameter(required = false)
     private String[] excludeFiles;
 
     @Parameter(property = "project", required = true, readonly = true)
-    protected MavenProject project;
+    private MavenProject project;
 
     @Parameter(property = "inspectDependencies", required = true, readonly = true)
     private boolean inspectDependencies;
@@ -73,6 +73,10 @@ public final class YangToSourcesMojo extends AbstractMojo {
 
     }
 
+    public void setProject(MavenProject project) {
+        this.project = project;
+    }
+
     @VisibleForTesting
     YangToSourcesMojo(YangToSourcesProcessor processor) {
         this.yangToSourcesProcessor = processor;
index eb7269d818fc181c82e4abb3840302716025e436..c32dcc27fe9863debe4f1fc862b5293258d422ed 100644 (file)
@@ -54,7 +54,11 @@ class YangToSourcesProcessor {
             MavenProject project, boolean inspectDependencies, YangProvider yangProvider) {
         this.log = Util.checkNotNull(log, "log");
         this.yangFilesRootDir = Util.checkNotNull(yangFilesRootDir, "yangFilesRootDir");
-        this.excludedFiles = excludedFiles;
+        this.excludedFiles = new File[excludedFiles.length];
+        int i = 0;
+        for (File file : excludedFiles) {
+            this.excludedFiles[i++] = new File(file.getPath());
+        }
         this.codeGenerators = Collections.unmodifiableList(Util.checkNotNull(codeGenerators, "codeGenerators"));
         this.project = Util.checkNotNull(project, "project");
         this.inspectDependencies = inspectDependencies;
@@ -69,7 +73,7 @@ class YangToSourcesProcessor {
     public void execute() throws MojoExecutionException, MojoFailureException {
         ContextHolder context = processYang();
         generateSources(context);
-        yangProvider.addYangsToMETA_INF(log, project, yangFilesRootDir, excludedFiles);
+        yangProvider.addYangsToMetaInf(log, project, yangFilesRootDir, excludedFiles);
     }
 
     private ContextHolder processYang() throws MojoExecutionException {
@@ -87,7 +91,7 @@ class YangToSourcesProcessor {
                     YangsInZipsResult dependentYangResult = Util.findYangFilesInDependenciesAsStream(log, project);
                     Closeable dependentYangResult1 = dependentYangResult;
                     closeables.add(dependentYangResult1);
-                    all.addAll(dependentYangResult.yangStreams);
+                    all.addAll(dependentYangResult.getYangStreams());
                 }
 
                 allYangModules = parser.parseYangModelsFromStreamsMapped(all);
@@ -119,11 +123,11 @@ class YangToSourcesProcessor {
 
     static class YangProvider {
 
-        private static final String yangResourceDir = "target" + File.separator + "yang";
+        private static final String YANG_RESOURCE_DIR = "target" + File.separator + "yang";
 
-        void addYangsToMETA_INF(Log log, MavenProject project, File yangFilesRootDir, File[] excludedFiles)
+        void addYangsToMetaInf(Log log, MavenProject project, File yangFilesRootDir, File[] excludedFiles)
                 throws MojoFailureException {
-            File targetYangDir = new File(project.getBasedir(), yangResourceDir);
+            File targetYangDir = new File(project.getBasedir(), YANG_RESOURCE_DIR);
 
             try {
                 Collection<File> files = Util.listFiles(yangFilesRootDir, excludedFiles, null);
@@ -145,8 +149,9 @@ class YangToSourcesProcessor {
         private static void setResource(File targetYangDir, String targetPath, MavenProject project) {
             Resource res = new Resource();
             res.setDirectory(targetYangDir.getPath());
-            if (targetPath != null)
+            if (targetPath != null) {
                 res.setTargetPath(targetPath);
+            }
             project.addResource(res);
         }
     }
index 2f7a050cb02e2f5dc1ca03412220efd514432b1c..a48124028ae3f84a2dc58ca509e5506a952a9f79 100644 (file)
@@ -49,7 +49,7 @@ public class GenerateSourcesTest {
         yang = new File(getClass().getResource("/yang/mock.yang").getFile()).getParent();
         outDir = new File("/outputDir");
         YangProvider mock = mock(YangProvider.class);
-        doNothing().when(mock).addYangsToMETA_INF(any(Log.class), any(MavenProject.class), any(File.class),
+        doNothing().when(mock).addYangsToMetaInf(any(Log.class), any(MavenProject.class), any(File.class),
                 any(File[].class));
 
         YangToSourcesProcessor processor = new YangToSourcesProcessor(mock(Log.class), new File(yang), new File[] {},
@@ -57,7 +57,7 @@ public class GenerateSourcesTest {
                 mock);
         mojo = new YangToSourcesMojo(processor);
         doReturn(new File("")).when(project).getBasedir();
-        mojo.project = project;
+        mojo.setProject(project);
     }
 
     @Test
index 22b952ce3667583fa9001918ce32822b1b9c58d8..967a61d76a642519fa4db6355ca351890781e726 100644 (file)
@@ -1,55 +1,55 @@
-/*\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.yang.model.api;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * AugmentationSchema represents augment definition. The "augment" statement\r
- * allows a module or submodule to add to the schema tree defined in an external\r
- * module, or the current module and its submodules, and to add to the nodes\r
- * from a grouping in a "uses" statement.\r
- */\r
-public interface AugmentationSchema extends DataNodeContainer {\r
-\r
-    /**\r
-     * @return when statement\r
-     */\r
-    RevisionAwareXPath getWhenCondition();\r
-\r
-    /**\r
-     * @return textual description of this augment.\r
-     */\r
-    String getDescription();\r
-\r
-    /**\r
-     * @return textual cross-reference to an external document that provides\r
-     *         additional information relevant to this node.\r
-     */\r
-    String getReference();\r
-\r
-    /**\r
-     * @return actual status of this node.\r
-     */\r
-    Status getStatus();\r
-\r
-    /**\r
-     * @return SchemaPath that identifies a node in the schema tree. This node\r
-     *         is called the augment's target node. The target node MUST be\r
-     *         either a container, list, choice, case, input, output, or\r
-     *         notification node. It is augmented with the nodes defined as\r
-     *         child nodes of this AugmentationSchema.\r
-     */\r
-    SchemaPath getTargetPath();\r
-\r
-    /**\r
-     * @return collection of all unknown nodes defined in this augmentation\r
-     */\r
-    public List<UnknownSchemaNode> getUnknownSchemaNodes();\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.yang.model.api;
+
+import java.util.List;
+
+/**
+ * AugmentationSchema represents augment definition. The "augment" statement
+ * allows a module or submodule to add to the schema tree defined in an external
+ * module, or the current module and its submodules, and to add to the nodes
+ * from a grouping in a "uses" statement.
+ */
+public interface AugmentationSchema extends DataNodeContainer {
+
+    /**
+     * @return when statement
+     */
+    RevisionAwareXPath getWhenCondition();
+
+    /**
+     * @return textual description of this augment.
+     */
+    String getDescription();
+
+    /**
+     * @return textual cross-reference to an external document that provides
+     *         additional information relevant to this node.
+     */
+    String getReference();
+
+    /**
+     * @return actual status of this node.
+     */
+    Status getStatus();
+
+    /**
+     * @return SchemaPath that identifies a node in the schema tree. This node
+     *         is called the augment's target node. The target node MUST be
+     *         either a container, list, choice, case, input, output, or
+     *         notification node. It is augmented with the nodes defined as
+     *         child nodes of this AugmentationSchema.
+     */
+    SchemaPath getTargetPath();
+
+    /**
+     * @return collection of all unknown nodes defined in this augmentation
+     */
+    List<UnknownSchemaNode> getUnknownSchemaNodes();
+
+}
index 8c3391bd2156a470dd2c3dcc48fcf426bf4c0e1c..3a7cce85b546545f1c5f49b915a178e88cbb0991 100644 (file)
@@ -1,53 +1,53 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.model.api;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * Interface describing YANG 'deviation' statement.\r
- * <p>\r
- * The 'deviation' statement defines a hierarchy of a module that the device\r
- * does not implement faithfully. Deviations define the way a device deviate\r
- * from a standard.\r
- * </p>\r
- */\r
-public interface Deviation {\r
-\r
-    /**\r
-     * Enum describing YANG deviation 'deviate' statement. It defines how the\r
-     * device's implementation of the target node deviates from its original\r
-     * definition.\r
-     */\r
-    enum Deviate {\r
-        NOT_SUPPORTED, ADD, REPLACE, DELETE\r
-    }\r
-\r
-    /**\r
-     * @return SchemaPath that identifies the node in the schema tree where a\r
-     *         deviation from the module occurs.\r
-     */\r
-    SchemaPath getTargetPath();\r
-\r
-    /**\r
-     * @return deviate statement of this deviation\r
-     */\r
-    Deviate getDeviate();\r
-\r
-    /**\r
-     * @return textual cross-reference to an external document that provides\r
-     *         additional information relevant to this node.\r
-     */\r
-    String getReference();\r
-\r
-    /**\r
-     * @return collection of all unknown nodes defined under this schema node.\r
-     */\r
-    public List<UnknownSchemaNode> getUnknownSchemaNodes();\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.yang.model.api;
+
+import java.util.List;
+
+/**
+ * Interface describing YANG 'deviation' statement.
+ * <p>
+ * The 'deviation' statement defines a hierarchy of a module that the device
+ * does not implement faithfully. Deviations define the way a device deviate
+ * from a standard.
+ * </p>
+ */
+public interface Deviation {
+
+    /**
+     * Enum describing YANG deviation 'deviate' statement. It defines how the
+     * device's implementation of the target node deviates from its original
+     * definition.
+     */
+    enum Deviate {
+        NOT_SUPPORTED, ADD, REPLACE, DELETE
+    }
+
+    /**
+     * @return SchemaPath that identifies the node in the schema tree where a
+     *         deviation from the module occurs.
+     */
+    SchemaPath getTargetPath();
+
+    /**
+     * @return deviate statement of this deviation
+     */
+    Deviate getDeviate();
+
+    /**
+     * @return textual cross-reference to an external document that provides
+     *         additional information relevant to this node.
+     */
+    String getReference();
+
+    /**
+     * @return collection of all unknown nodes defined under this schema node.
+     */
+    List<UnknownSchemaNode> getUnknownSchemaNodes();
+
+}
index c65200c7e86d7bc40192ff92de74fbc31310ea1d..5154df6d86b646f1d547109215a3175ca5e5bb79 100644 (file)
@@ -27,7 +27,7 @@ public interface ExtensionDefinition extends SchemaNode {
      *         Keyword. If no argument statement is present the method will
      *         return <code>null</code>
      */
-    public String getArgument();
+    String getArgument();
 
     /**
      * This statement indicates if the argument is mapped to an XML element in
@@ -46,5 +46,5 @@ public interface ExtensionDefinition extends SchemaNode {
      *         YIN or returns <code>false</code> if the argument is mapped to an
      *         XML attribute.
      */
-    public boolean isYinElement();
+    boolean isYinElement();
 }
index c36528adbbce85dca399a258d3cac92d566ad45a..ad8d999816d3e2e9751a330ceb8f8421f890dc17 100644 (file)
@@ -1,39 +1,38 @@
-/*\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.yang.model.api;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-\r
-/**\r
- * Interface describing YANG 'list' statement.\r
- * <p>\r
- * The 'list' statement is used to define an interior data node in the schema\r
- * tree. A list entry is uniquely identified by the values of the list's keys,\r
- * if defined.\r
- * </p>\r
- */\r
-public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget,\r
-        DataSchemaNode {\r
-\r
-    /**\r
-     * @return List of QNames of leaf identifiers of this list\r
-     */\r
-    public List<QName> getKeyDefinition();\r
-\r
-    /**\r
-     * YANG 'ordered-by' statement. It defines whether the order of entries\r
-     * within a list are determined by the user or the system. If not present,\r
-     * default is false.\r
-     *\r
-     * @return true if ordered-by argument is "user", false otherwise\r
-     */\r
-    boolean isUserOrdered();\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.yang.model.api;
+
+import java.util.List;
+
+import org.opendaylight.yangtools.yang.common.QName;
+
+/**
+ * Interface describing YANG 'list' statement.
+ * <p>
+ * The 'list' statement is used to define an interior data node in the schema
+ * tree. A list entry is uniquely identified by the values of the list's keys,
+ * if defined.
+ * </p>
+ */
+public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget, DataSchemaNode {
+
+    /**
+     * @return List of QNames of leaf identifiers of this list
+     */
+    List<QName> getKeyDefinition();
+
+    /**
+     * YANG 'ordered-by' statement. It defines whether the order of entries
+     * within a list are determined by the user or the system. If not present,
+     * default is false.
+     * 
+     * @return true if ordered-by argument is "user", false otherwise
+     */
+    boolean isUserOrdered();
+
+}
index 95d46ac8b20b577c0a1c17bc8522fdcbb7b52d79..f2d911a7dadfa42931e6bb78317eabbe57509f9c 100644 (file)
@@ -23,7 +23,7 @@ public interface RevisionAwareXPath {
      * @return <code>true</code> if the XPapth starts in root of Yang model,
      *         otherwise returns <code>false</cdoe>
      */
-    public boolean isAbsolute();
+    boolean isAbsolute();
 
     /**
      * Returns the XPath formatted string as is defined in model. <br>
@@ -32,5 +32,5 @@ public interface RevisionAwareXPath {
      * 
      * @return the XPath formatted string as is defined in model.
      */
-    public String toString();
+    String toString();
 }
index 84dc24a0b4298e4972c1d32d53cc26c091b029ca..146da3ae65ef5e9c53300d97cd1348473c4aa26e 100644 (file)
@@ -21,7 +21,7 @@ public interface SchemaNode {
      * 
      * @return QName with the name of the schema node
      */
-    public QName getQName();
+    QName getQName();
 
     /**
      * Returns the schema path of the instance of the type
@@ -29,7 +29,7 @@ public interface SchemaNode {
      * 
      * @return schema path of the schema node
      */
-    public SchemaPath getPath();
+    SchemaPath getPath();
 
     /**
      * Returns description of the instance of the type <code>SchemaNode</code>
@@ -37,7 +37,7 @@ public interface SchemaNode {
      * @return string with textual description the node which represents the
      *         argument of the YANG <code>description</code> substatement
      */
-    public String getDescription();
+    String getDescription();
 
     /**
      * Returns reference of the instance of the type <code>SchemaNode</code>
@@ -49,7 +49,7 @@ public interface SchemaNode {
      *         represents the argument of the YANG <code>reference</code>
      *         substatement
      */
-    public String getReference();
+    String getReference();
 
     /**
      * Returns status of the instance of the type <code>SchemaNode</code>
@@ -57,7 +57,7 @@ public interface SchemaNode {
      * @return status of this node which represents the argument of the YANG
      *         <code>status</code> substatement
      */
-    public Status getStatus();
+    Status getStatus();
 
     /**
      * 
@@ -66,6 +66,6 @@ public interface SchemaNode {
      * 
      * @return list of unknown schema nodes defined under this schema node.
      */
-    public List<UnknownSchemaNode> getUnknownSchemaNodes();
+    List<UnknownSchemaNode> getUnknownSchemaNodes();
 
 }
index 325b0c2c0a6d9df2397d5d40a5638323ee4f634f..f05c2b26dafb859556e768951f9560abcd90d517 100644 (file)
@@ -19,17 +19,19 @@ import org.opendaylight.yangtools.yang.common.QName;
  * 
  */
 public class SchemaPath {
+    private final int hashBooleanTrue = 1231;
+    private final int hashBooleanFalse = 1237;
 
     /**
      * List of QName instances which represents complete path to the node.
      */
-    final List<QName> path;
+    private final List<QName> path;
 
     /**
      * Boolean value which represents type of schema path (relative or
      * absolute).
      */
-    final boolean absolute;
+    private final boolean absolute;
 
     /**
      * Constructs new instance of this class with the concrete path.
@@ -70,7 +72,7 @@ public class SchemaPath {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + (absolute ? 1231 : 1237);
+        result = prime * result + (absolute ? hashBooleanTrue : hashBooleanFalse);
         result = prime * result + ((path == null) ? 0 : path.hashCode());
         return result;
     }
index 64a3fd2ac5321fb200d80196343dc1424146f255..320fdca5a81565c44699d7c0b073a94db995eafc 100644 (file)
@@ -41,7 +41,7 @@ public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
          * 
          * @return name of each assigned name of an enumeration type.
          */
-        public String getName();
+        String getName();
 
         /**
          * The "value" statement, which is optional, is used to associate an
@@ -51,6 +51,6 @@ public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
          * 
          * @return integer value assigned to enumeration
          */
-        public Integer getValue();
+        Integer getValue();
     }
 }
index c5647b783519a1c1ea02118470fa9effc3080593..86f6379f1f2c43056a61b4dff051c7622880c5bf 100644 (file)
@@ -21,5 +21,5 @@ public interface IdentityTypeDefinition extends TypeDefinition<IdentityTypeDefin
      * 
      * @return QName of the YANG identity
      */
-    public QName getIdentityName();
+    QName getIdentityName();
 }
index 3b5f5e0d3fc4e206f147c8c6c7122812a736a635..3d7279655c172bf891b2dd08c2ec6eeeb780b0aa 100644 (file)
@@ -23,7 +23,7 @@ public interface InstanceIdentifierTypeDefinition extends TypeDefinition<Instanc
      * 
      * @return instance of type <code>RevisionAwareXPath</code>
      */
-    public RevisionAwareXPath getPathStatement();
+    RevisionAwareXPath getPathStatement();
 
     /**
      * Returns true|false which represents argument of
@@ -33,5 +33,5 @@ public interface InstanceIdentifierTypeDefinition extends TypeDefinition<Instanc
      * @return boolean value which is true if the <code>require-instance</code>
      *         statement is true and vice versa
      */
-    public boolean requireInstance();
+    boolean requireInstance();
 }
diff --git a/yang/yang-model-util/.gitignore b/yang/yang-model-util/.gitignore
new file mode 100644 (file)
index 0000000..0aba2eb
--- /dev/null
@@ -0,0 +1 @@
+/src/main/xtend-gen
\ No newline at end of file
index 7b0298073221f806821c3f141eee374a2bfad251..799ac6bac8b1d7cd538eeebd7a206d79642bde38 100644 (file)
@@ -1,61 +1,65 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-\r
-    <parent>\r
-        <groupId>org.opendaylight.yangtools</groupId>\r
-        <artifactId>yang</artifactId>\r
-        <version>0.5.7-SNAPSHOT</version>\r
-    </parent>\r
-\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <artifactId>yang-model-util</artifactId>\r
-    <name>${project.artifactId}</name>\r
-    <description>${project.artifactId}</description>\r
-\r
-\r
-    <build>\r
-        <plugins>\r
-            <plugin>\r
-                <groupId>org.eclipse.xtend</groupId>\r
-                <artifactId>xtend-maven-plugin</artifactId>\r
-                <version>2.4.2</version>\r
-                <executions>\r
-                    <execution>\r
-                        <goals>\r
-                            <goal>compile</goal>\r
-                        </goals>\r
-                        <configuration>\r
-                            <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>\r
-                        </configuration>\r
-                    </execution>\r
-                </executions>\r
-            </plugin>\r
-            <plugin>\r
-                <artifactId>maven-clean-plugin</artifactId>\r
-                <version>2.4.1</version>\r
-                <configuration>\r
-                    <filesets>\r
-                        <fileset>\r
-                            <directory>${basedir}/src/main/xtend-gen</directory>\r
-                            <includes>\r
-                                <include>**</include>\r
-                            </includes>\r
-                        </fileset>\r
-                    </filesets>\r
-                </configuration>\r
-            </plugin>\r
-        </plugins>\r
-    </build>\r
-\r
-    <dependencies>\r
-        <dependency>\r
-            <groupId>${project.groupId}</groupId>\r
-            <artifactId>yang-model-api</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.eclipse.xtend</groupId>\r
-            <artifactId>org.eclipse.xtend.lib</artifactId>\r
-            <version>2.4.2</version>\r
-        </dependency>\r
-    </dependencies>\r
-</project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yang</artifactId>
+        <version>0.5.7-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>yang-model-util</artifactId>
+    <name>${project.artifactId}</name>
+    <description>${project.artifactId}</description>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.eclipse.xtend</groupId>
+                <artifactId>xtend-maven-plugin</artifactId>
+                <version>2.4.2</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>2.4.1</version>
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>${basedir}/src/main/xtend-gen</directory>
+                            <includes>
+                                <include>**</include>
+                            </includes>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>yang-model-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.xtend</groupId>
+            <artifactId>org.eclipse.xtend.lib</artifactId>
+            <version>2.4.2</version>
+        </dependency>
+        <dependency>
+               <groupId>junit</groupId>
+               <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
index 23528e52e4e2c8be7adbc2e94cb26ecdccb5ea58..8dd79e6a2d82f68802f60998751a30fe4c858842 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
  * interface which represents SIGNED Integer values defined in Yang language. <br>
  * The integer built-in types in Yang are int8, int16, int32, int64. They
  * represent signed integers of different sizes:
- *
+ * 
  * <ul>
  * <li>int8 - represents integer values between -128 and 127, inclusively.</li>
  * <li>int16 - represents integer values between -32768 and 32767, inclusively.</li>
@@ -32,13 +32,13 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
  * <li>int64 - represents integer values between -9223372036854775808 and
  * 9223372036854775807, inclusively.</li>
  * </ul>
- *
+ * 
  */
 public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
     private final QName name;
     private final SchemaPath path;
     private final String description;
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.2";
     private final String units;
     private final List<RangeConstraint> rangeStatements;
 
@@ -83,7 +83,7 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
 
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     @Override
@@ -109,7 +109,6 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
         result = prime * result + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
-        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
         result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
@@ -154,13 +153,6 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
         } else if (!rangeStatements.equals(other.rangeStatements)) {
             return false;
         }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
         if (units == null) {
             if (other.units != null) {
                 return false;
@@ -181,7 +173,7 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
         builder.append(", description=");
         builder.append(description);
         builder.append(", reference=");
-        builder.append(reference);
+        builder.append(REFERENCE);
         builder.append(", units=");
         builder.append(units);
         builder.append(", rangeStatements=");
index 7d5a8f68d3b066c28b11466e0a150c4337df4975..646fecb9b6d79ca913b28d568f42e37db4ed9bb4 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * interface which represents UNSIGNED Integer values defined in Yang language. <br>
  * The integer built-in types in Yang are uint8, uint16, uint32, and uint64.
  * They represent unsigned integers of different sizes:
- *
+ * 
  * <ul>
  * <li>uint8 - represents integer values between 0 and 255, inclusively.</li>
  * <li>uint16 - represents integer values between 0 and 65535, inclusively.</li>
@@ -28,19 +28,19 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * <li>uint64 - represents integer values between 0 and 18446744073709551615,
  * inclusively.</li>
  * </ul>
- *
+ * 
  */
 public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefinition {
     private static final long MIN_VALUE = 0;
     private final QName name;
     private final SchemaPath path;
     private final String description;
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.2";
     private final String units;
     private final List<RangeConstraint> rangeStatements;
 
     /**
-     *
+     * 
      * @param name
      * @param description
      * @param maxRange
@@ -79,7 +79,7 @@ public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefi
 
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     @Override
@@ -105,7 +105,6 @@ public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefi
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
         result = prime * result + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
-        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
         result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
@@ -150,13 +149,6 @@ public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefi
         } else if (!rangeStatements.equals(other.rangeStatements)) {
             return false;
         }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
         if (units == null) {
             if (other.units != null) {
                 return false;
@@ -177,7 +169,7 @@ public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefi
         builder.append(", description=");
         builder.append(description);
         builder.append(", reference=");
-        builder.append(reference);
+        builder.append(REFERENCE);
         builder.append(", units=");
         builder.append(units);
         builder.append(", rangeStatements=");
index 5a3622a89ec6702bae513bc8beb778f9b3f56c38..c6ba5d619c0605e0d8dbab39ccb4d81b9f3d4687 100644 (file)
@@ -16,18 +16,18 @@ public final class BaseConstraints {
     private BaseConstraints() {
     }
 
-    public static LengthConstraint lengthConstraint(final Number min,
-            final Number max, final String description, final String reference) {
+    public static LengthConstraint lengthConstraint(final Number min, final Number max, final String description,
+            final String reference) {
         return new LengthConstraintImpl(min, max, description, reference);
     }
 
-    public static RangeConstraint rangeConstraint(final Number min,
-            final Number max, final String description, final String reference) {
+    public static RangeConstraint rangeConstraint(final Number min, final Number max, final String description,
+            final String reference) {
         return new RangeConstraintImpl(min, max, description, reference);
     }
 
-    public static PatternConstraint patternConstraint(final String pattern,
-            final String description, final String reference) {
+    public static PatternConstraint patternConstraint(final String pattern, final String description,
+            final String reference) {
         return new PatternConstraintImpl(pattern, description, reference);
     }
 
@@ -42,8 +42,7 @@ public final class BaseConstraints {
         private final String errorAppTag;
         private final String errorMessage;
 
-        public LengthConstraintImpl(Number min, Number max,
-                final String description, final String reference) {
+        public LengthConstraintImpl(Number min, Number max, final String description, final String reference) {
             super();
             this.min = min;
             this.max = max;
@@ -51,8 +50,7 @@ public final class BaseConstraints {
             this.reference = reference;
 
             this.errorAppTag = "length-out-of-specified-bounds";
-            this.errorMessage = "The argument is out of bounds <" + min + ", "
-                    + max + ">";
+            this.errorMessage = "The argument is out of bounds <" + min + ", " + max + ">";
         }
 
         @Override
@@ -89,16 +87,12 @@ public final class BaseConstraints {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result
-                    + ((description == null) ? 0 : description.hashCode());
-            result = prime * result
-                    + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
-            result = prime * result
-                    + ((errorMessage == null) ? 0 : errorMessage.hashCode());
+            result = prime * result + ((description == null) ? 0 : description.hashCode());
+            result = prime * result + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
+            result = prime * result + ((errorMessage == null) ? 0 : errorMessage.hashCode());
             result = prime * result + ((max == null) ? 0 : max.hashCode());
             result = prime * result + ((min == null) ? 0 : min.hashCode());
-            result = prime * result
-                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result + ((reference == null) ? 0 : reference.hashCode());
             return result;
         }
 
@@ -171,7 +165,7 @@ public final class BaseConstraints {
         }
     }
 
-    private final static class RangeConstraintImpl implements RangeConstraint {
+    private static final class RangeConstraintImpl implements RangeConstraint {
         private final Number min;
         private final Number max;
 
@@ -181,8 +175,7 @@ public final class BaseConstraints {
         private final String errorAppTag;
         private final String errorMessage;
 
-        public RangeConstraintImpl(Number min, Number max, String description,
-                String reference) {
+        public RangeConstraintImpl(Number min, Number max, String description, String reference) {
             super();
             this.min = min;
             this.max = max;
@@ -190,8 +183,7 @@ public final class BaseConstraints {
             this.reference = reference;
 
             this.errorAppTag = "range-out-of-specified-bounds";
-            this.errorMessage = "The argument is out of bounds <" + min + ", "
-                    + max + ">";
+            this.errorMessage = "The argument is out of bounds <" + min + ", " + max + ">";
         }
 
         @Override
@@ -228,16 +220,12 @@ public final class BaseConstraints {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result
-                    + ((description == null) ? 0 : description.hashCode());
-            result = prime * result
-                    + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
-            result = prime * result
-                    + ((errorMessage == null) ? 0 : errorMessage.hashCode());
+            result = prime * result + ((description == null) ? 0 : description.hashCode());
+            result = prime * result + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
+            result = prime * result + ((errorMessage == null) ? 0 : errorMessage.hashCode());
             result = prime * result + ((max == null) ? 0 : max.hashCode());
             result = prime * result + ((min == null) ? 0 : min.hashCode());
-            result = prime * result
-                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result + ((reference == null) ? 0 : reference.hashCode());
             return result;
         }
 
@@ -318,8 +306,7 @@ public final class BaseConstraints {
         }
     }
 
-    private final static class PatternConstraintImpl implements
-            PatternConstraint {
+    private static final class PatternConstraintImpl implements PatternConstraint {
 
         private final String regex;
         private final String description;
@@ -328,8 +315,7 @@ public final class BaseConstraints {
         private final String errorAppTag;
         private final String errorMessage;
 
-        public PatternConstraintImpl(final String regex,
-                final String description, final String reference) {
+        public PatternConstraintImpl(final String regex, final String description, final String reference) {
             super();
             this.regex = regex;
             this.description = description;
@@ -369,14 +355,10 @@ public final class BaseConstraints {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result
-                    + ((description == null) ? 0 : description.hashCode());
-            result = prime * result
-                    + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
-            result = prime * result
-                    + ((errorMessage == null) ? 0 : errorMessage.hashCode());
-            result = prime * result
-                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result + ((description == null) ? 0 : description.hashCode());
+            result = prime * result + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
+            result = prime * result + ((errorMessage == null) ? 0 : errorMessage.hashCode());
+            result = prime * result + ((reference == null) ? 0 : reference.hashCode());
             result = prime * result + ((regex == null) ? 0 : regex.hashCode());
             return result;
         }
index 76157fbcb115769eec7071cf7f928c298072f7d6..4688f58aa6587c1a8a590bb9eb6a9fbda9373757 100644 (file)
@@ -1,70 +1,75 @@
-/*\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.yang.model.util;\r
-\r
-import java.net.URI;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
-\r
-public final class BaseTypes {\r
-\r
-    private BaseTypes() {}\r
-\r
-    public static final URI BaseTypesNamespace = URI\r
-            .create("urn:ietf:params:xml:ns:yang:1");\r
-\r
-    /**\r
-     * Construct QName for Built-in base Yang type. The namespace for\r
-     * built-in base yang types is defined as: urn:ietf:params:xml:ns:yang:1\r
-     *\r
-     * @param typeName yang type name\r
-     * @return built-in base yang type QName.\r
-     */\r
-    public static final QName constructQName(final String typeName) {\r
-        return new QName(BaseTypesNamespace, typeName);\r
-    }\r
-\r
-    /**\r
-     * Creates Schema Path from Qname.\r
-     *\r
-     * @param typeName yang type QName\r
-     * @return Schema Path from Qname.\r
-     */\r
-    public static final SchemaPath schemaPath(final QName typeName) {\r
-        List<QName> pathList = Collections.singletonList(typeName);\r
-        return new SchemaPath(pathList, true);\r
-    }\r
-\r
-    /**\r
-     * Creates Schema Path from List of partial paths defined as Strings, module Namespace and\r
-     * module latest Revision Date.\r
-     *\r
-     * @param actualPath List of partial paths\r
-     * @param namespace Module Namespace\r
-     * @param revision Revision Date\r
-     * @return Schema Path\r
-     */\r
-    public static final SchemaPath schemaPath(final List<String> actualPath, final URI namespace, final Date revision) {\r
-        if (actualPath == null) {\r
-            throw new IllegalArgumentException("The actual path List MUST be specified.");\r
-        }\r
-        final List<QName> pathList = new ArrayList<QName>();\r
-        for (final String path : actualPath) {\r
-            final QName qname = new QName(namespace, revision, path);\r
-            if (qname != null) {\r
-                pathList.add(qname);\r
-            }\r
-        }\r
-        return new SchemaPath(pathList, true);\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.yang.model.util;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public final class BaseTypes {
+
+    private BaseTypes() {
+    }
+
+    public static final URI BASE_TYPES_NAMESPACE = URI.create("urn:ietf:params:xml:ns:yang:1");
+
+    /**
+     * Construct QName for Built-in base Yang type. The namespace for built-in
+     * base yang types is defined as: urn:ietf:params:xml:ns:yang:1
+     * 
+     * @param typeName
+     *            yang type name
+     * @return built-in base yang type QName.
+     */
+    public static QName constructQName(final String typeName) {
+        return new QName(BASE_TYPES_NAMESPACE, typeName);
+    }
+
+    /**
+     * Creates Schema Path from Qname.
+     * 
+     * @param typeName
+     *            yang type QName
+     * @return Schema Path from Qname.
+     */
+    public static SchemaPath schemaPath(final QName typeName) {
+        List<QName> pathList = Collections.singletonList(typeName);
+        return new SchemaPath(pathList, true);
+    }
+
+    /**
+     * Creates Schema Path from List of partial paths defined as Strings, module
+     * Namespace and module latest Revision Date.
+     * 
+     * @param actualPath
+     *            List of partial paths
+     * @param namespace
+     *            Module Namespace
+     * @param revision
+     *            Revision Date
+     * @return Schema Path
+     */
+    public static SchemaPath schemaPath(final List<String> actualPath, final URI namespace, final Date revision) {
+        if (actualPath == null) {
+            throw new IllegalArgumentException("The actual path List MUST be specified.");
+        }
+        final List<QName> pathList = new ArrayList<QName>();
+        for (final String path : actualPath) {
+            final QName qname = new QName(namespace, revision, path);
+            if (qname != null) {
+                pathList.add(qname);
+            }
+        }
+        return new SchemaPath(pathList, true);
+    }
+}
index 89a78d261470e8ea107702e27f40e9db52cec818..d7495ada748068042d4fe9b1d365190168c85abb 100644 (file)
@@ -20,18 +20,18 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 
 /**
  * The <code>default</code> implementation of Binary Type Definition interface.
- *
+ * 
  * @see BinaryTypeDefinition
  */
 public final class BinaryType implements BinaryTypeDefinition {
     private static final BinaryType INSTANCE = new BinaryType();
     private final QName name = BaseTypes.constructQName("binary");
     private final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
-    private final String description = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.8";
+    private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8";
     private final List<Byte> bytes;
     private final List<LengthConstraint> lengthConstraints;
-    private final String units = "";
+    private static final String UNITS = "";
 
     private BinaryType() {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
@@ -46,7 +46,7 @@ public final class BinaryType implements BinaryTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
@@ -57,17 +57,17 @@ public final class BinaryType implements BinaryTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
      * ()
@@ -79,7 +79,7 @@ public final class BinaryType implements BinaryTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -89,7 +89,7 @@ public final class BinaryType implements BinaryTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -99,28 +99,28 @@ public final class BinaryType implements BinaryTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -130,7 +130,7 @@ public final class BinaryType implements BinaryTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.base.type.api.BinaryTypeDefinition
      * #getLengthConstraint ()
@@ -150,12 +150,9 @@ public final class BinaryType implements BinaryTypeDefinition {
         final int prime = 31;
         int result = 1;
         result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());
-        result = prime * result + ((description == null) ? 0 : description.hashCode());
         result = prime * result + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
 
@@ -178,13 +175,6 @@ public final class BinaryType implements BinaryTypeDefinition {
         } else if (!bytes.equals(other.bytes)) {
             return false;
         }
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
         if (lengthConstraints == null) {
             if (other.lengthConstraints != null) {
                 return false;
@@ -206,20 +196,6 @@ public final class BinaryType implements BinaryTypeDefinition {
         } else if (!path.equals(other.path)) {
             return false;
         }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
         return true;
     }
 
@@ -231,15 +207,15 @@ public final class BinaryType implements BinaryTypeDefinition {
         builder.append(", path=");
         builder.append(path);
         builder.append(", description=");
-        builder.append(description);
+        builder.append(DESCRIPTION);
         builder.append(", reference=");
-        builder.append(reference);
+        builder.append(REFERENCE);
         builder.append(", bytes=");
         builder.append(bytes);
         builder.append(", lengthConstraints=");
         builder.append(lengthConstraints);
         builder.append(", units=");
-        builder.append(units);
+        builder.append(UNITS);
         builder.append("]");
         return builder.toString();
     }
index 6fa221df6e254e05218ea15381de4f6c1a6c5528..cacfeb305ded07c22c5582878263877fdf9af428 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 
 /**
  * The <code>default</code> implementation of Bits Type Definition interface.
- *
+ * 
  * @see BitsTypeDefinition
  */
 public final class BitsType implements BitsTypeDefinition {
@@ -28,15 +28,15 @@ public final class BitsType implements BitsTypeDefinition {
             + "That is, a bits value is a set of flags identified by small integer position "
             + "numbers starting at 0.  Each bit number has an assigned name.";
 
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.7";
     private final BitsTypeDefinition baseType;
     private final List<Bit> bits;
-    private final String units = "";
+    private static final String UNITS = "";
 
     /**
      * Default constructor. <br>
      * Instantiates Bits type as empty bits list.
-     *
+     * 
      * @param path
      */
     public BitsType(final SchemaPath path) {
@@ -48,7 +48,7 @@ public final class BitsType implements BitsTypeDefinition {
 
     /**
      * Constructor with explicit definition of bits assigned to BitsType.
-     *
+     * 
      * @param path
      * @param bits
      */
@@ -61,7 +61,7 @@ public final class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
@@ -72,17 +72,17 @@ public final class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
      * ()
@@ -94,7 +94,7 @@ public final class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -104,7 +104,7 @@ public final class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -114,7 +114,7 @@ public final class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
@@ -125,17 +125,17 @@ public final class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -161,8 +161,6 @@ public final class BitsType implements BitsTypeDefinition {
         result = prime * result + ((description == null) ? 0 : description.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
 
@@ -206,20 +204,6 @@ public final class BitsType implements BitsTypeDefinition {
         } else if (!path.equals(other.path)) {
             return false;
         }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
         return true;
     }
 
@@ -233,11 +217,11 @@ public final class BitsType implements BitsTypeDefinition {
         builder.append(", description=");
         builder.append(description);
         builder.append(", reference=");
-        builder.append(reference);
+        builder.append(REFERENCE);
         builder.append(", bits=");
         builder.append(bits);
         builder.append(", units=");
-        builder.append(units);
+        builder.append(UNITS);
         builder.append("]");
         return builder.toString();
     }
index 7ecba89748daf84d4fbf6208d62319e1eb27f22d..9d7aff3366d5dcf62ffb4d79b4bcb4bca4d6c8a5 100644 (file)
@@ -18,16 +18,16 @@ import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
 
 /**
  * The <code>default</code> implementation of Boolean Type Definition interface.
- *
+ * 
  * @see BooleanTypeDefinition
  */
 public final class BooleanType implements BooleanTypeDefinition {
     private static final BooleanType INSTANCE = new BooleanType();
-    private static final QName name = BaseTypes.constructQName("boolean");
-    private static final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
-    private static final String description = "The boolean built-in type represents a boolean value.";
-    private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
-    private final String units = "";
+    private static final QName NAME = BaseTypes.constructQName("boolean");
+    private static final SchemaPath PATH = new SchemaPath(Collections.singletonList(NAME), true);
+    private static final String DESCRIPTION = "The boolean built-in type represents a boolean value.";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.5";
+    private static final String UNITS = "";
 
     /**
      * Default constructor with default value set to "false".
@@ -41,7 +41,7 @@ public final class BooleanType implements BooleanTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
@@ -52,17 +52,17 @@ public final class BooleanType implements BooleanTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
      * ()
@@ -74,48 +74,48 @@ public final class BooleanType implements BooleanTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
     public QName getQName() {
-        return name;
+        return NAME;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
     public SchemaPath getPath() {
-        return path;
+        return PATH;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -132,9 +132,9 @@ public final class BooleanType implements BooleanTypeDefinition {
     public String toString() {
         StringBuilder builder = new StringBuilder();
         builder.append("BooleanType [name=");
-        builder.append(name);
+        builder.append(NAME);
         builder.append(", path=");
-        builder.append(path);
+        builder.append(PATH);
         builder.append("]");
         return builder.toString();
     }
index 24e7f221e0d9eebd963e6afcaf58b073aad79da5..6fb90d96cb3b1e60160447102706171105922b1f 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.yang.model.util;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.yangtools.yang.model.api.*;\r
-\r
-public class DataNodeIterator implements Iterator<DataSchemaNode> {\r
-\r
-    private final DataNodeContainer container;\r
-    private final List<ListSchemaNode> allLists;\r
-    private final List<ContainerSchemaNode> allContainers;\r
-    private final List<ChoiceNode> allChoices;\r
-    private final List<DataSchemaNode> allChilds;\r
-    \r
-    public DataNodeIterator(final DataNodeContainer container) {\r
-        if (container == null) {\r
-            throw new IllegalArgumentException("Data Node Container MUST be specified and cannot be NULL!");\r
-        }\r
-\r
-        this.allContainers = new ArrayList<>();\r
-        this.allLists = new ArrayList<>();\r
-        this.allChilds = new ArrayList<>();\r
-        this.allChoices = new ArrayList<>();\r
-\r
-        this.container = container;\r
-        traverse(this.container);\r
-    }\r
-\r
-    public List<ContainerSchemaNode> allContainers() {\r
-        return allContainers;\r
-    }\r
-\r
-    public List<ListSchemaNode> allLists() {\r
-        return allLists;\r
-    }\r
-\r
-    public List<ChoiceNode> allChoices() {\r
-        return allChoices;\r
-    }\r
-\r
-    private void traverse(final DataNodeContainer dataNode) {\r
-        if (dataNode == null) {\r
-            return;\r
-        }\r
-\r
-        final Set<DataSchemaNode> childNodes = dataNode.getChildNodes();\r
-        if (childNodes != null) {\r
-            for (DataSchemaNode childNode : childNodes) {\r
-                if (childNode.isAugmenting()) {\r
-                    continue;\r
-                }\r
-                allChilds.add(childNode);\r
-                if (childNode instanceof ContainerSchemaNode) {\r
-                    final ContainerSchemaNode container = (ContainerSchemaNode) childNode;\r
-                    allContainers.add(container);\r
-                    traverse(container);\r
-                } else if (childNode instanceof ListSchemaNode) {\r
-                    final ListSchemaNode list = (ListSchemaNode) childNode;\r
-                    allLists.add(list);\r
-                    traverse(list);\r
-                } else if (childNode instanceof ChoiceNode) {\r
-                    final ChoiceNode choiceNode = (ChoiceNode) childNode;\r
-                    allChoices.add(choiceNode);\r
-                    final Set<ChoiceCaseNode> cases = choiceNode.getCases();\r
-                    if (cases != null) {\r
-                        for (final ChoiceCaseNode caseNode : cases) {\r
-                            traverse(caseNode);\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        if(dataNode instanceof Module) {\r
-            traverseModule((Module)dataNode);\r
-        }\r
-        \r
-        final Set<GroupingDefinition> groupings = dataNode.getGroupings();\r
-        if (groupings != null) {\r
-            for (GroupingDefinition grouping : groupings) {\r
-                traverse(grouping);\r
-            }\r
-        }\r
-    }\r
-    \r
-\r
-    private void traverseModule(Module module) {\r
-        final Set<NotificationDefinition> notifications = module.getNotifications();\r
-        for (NotificationDefinition notificationDefinition : notifications) {\r
-            traverse(notificationDefinition);\r
-        }\r
-        final Set<RpcDefinition> rpcs = module.getRpcs();\r
-        for (RpcDefinition rpcDefinition : rpcs) {\r
-            ContainerSchemaNode input = rpcDefinition.getInput();\r
-            if(input != null) {\r
-                traverse(input);\r
-            }\r
-            ContainerSchemaNode output = rpcDefinition.getInput();\r
-            if(input != null) {\r
-                traverse(output);\r
-            }\r
-        }\r
-    }\r
-    \r
-    @Override\r
-    public boolean hasNext() {\r
-        if (container.getChildNodes() != null) {\r
-            final Set<DataSchemaNode> childNodes = container.getChildNodes();\r
-\r
-            if ((childNodes != null) && !childNodes.isEmpty()) {\r
-                return childNodes.iterator().hasNext();\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public DataSchemaNode next() {\r
-        return allChilds.iterator().next();\r
-    }\r
-\r
-    @Override\r
-    public void remove() {\r
-        throw new UnsupportedOperationException();\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.yang.model.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.model.api.*;
+
+public class DataNodeIterator implements Iterator<DataSchemaNode> {
+
+    private final DataNodeContainer container;
+    private final List<ListSchemaNode> allLists;
+    private final List<ContainerSchemaNode> allContainers;
+    private final List<ChoiceNode> allChoices;
+    private final List<DataSchemaNode> allChilds;
+
+    public DataNodeIterator(final DataNodeContainer container) {
+        if (container == null) {
+            throw new IllegalArgumentException("Data Node Container MUST be specified and cannot be NULL!");
+        }
+
+        this.allContainers = new ArrayList<>();
+        this.allLists = new ArrayList<>();
+        this.allChilds = new ArrayList<>();
+        this.allChoices = new ArrayList<>();
+
+        this.container = container;
+        traverse(this.container);
+    }
+
+    public List<ContainerSchemaNode> allContainers() {
+        return allContainers;
+    }
+
+    public List<ListSchemaNode> allLists() {
+        return allLists;
+    }
+
+    public List<ChoiceNode> allChoices() {
+        return allChoices;
+    }
+
+    private void traverse(final DataNodeContainer dataNode) {
+        if (dataNode == null) {
+            return;
+        }
+
+        final Set<DataSchemaNode> childNodes = dataNode.getChildNodes();
+        if (childNodes != null) {
+            for (DataSchemaNode childNode : childNodes) {
+                if (childNode.isAugmenting()) {
+                    continue;
+                }
+                allChilds.add(childNode);
+                if (childNode instanceof ContainerSchemaNode) {
+                    final ContainerSchemaNode containerNode = (ContainerSchemaNode) childNode;
+                    allContainers.add(containerNode);
+                    traverse(containerNode);
+                } else if (childNode instanceof ListSchemaNode) {
+                    final ListSchemaNode list = (ListSchemaNode) childNode;
+                    allLists.add(list);
+                    traverse(list);
+                } else if (childNode instanceof ChoiceNode) {
+                    final ChoiceNode choiceNode = (ChoiceNode) childNode;
+                    allChoices.add(choiceNode);
+                    final Set<ChoiceCaseNode> cases = choiceNode.getCases();
+                    if (cases != null) {
+                        for (final ChoiceCaseNode caseNode : cases) {
+                            traverse(caseNode);
+                        }
+                    }
+                }
+            }
+        }
+
+        traverseModule(dataNode);
+        traverseGroupings(dataNode);
+
+    }
+
+    private void traverseModule(DataNodeContainer dataNode) {
+        final Module module;
+        if (dataNode instanceof Module) {
+            module = (Module) dataNode;
+        } else {
+            return;
+        }
+        final Set<NotificationDefinition> notifications = module.getNotifications();
+        for (NotificationDefinition notificationDefinition : notifications) {
+            traverse(notificationDefinition);
+        }
+        final Set<RpcDefinition> rpcs = module.getRpcs();
+        for (RpcDefinition rpcDefinition : rpcs) {
+            ContainerSchemaNode input = rpcDefinition.getInput();
+            if (input != null) {
+                traverse(input);
+            }
+            ContainerSchemaNode output = rpcDefinition.getInput();
+            if (input != null) {
+                traverse(output);
+            }
+        }
+    }
+
+    private void traverseGroupings(DataNodeContainer dataNode) {
+        final Set<GroupingDefinition> groupings = dataNode.getGroupings();
+        if (groupings != null) {
+            for (GroupingDefinition grouping : groupings) {
+                traverse(grouping);
+            }
+        }
+    }
+
+    @Override
+    public boolean hasNext() {
+        if (container.getChildNodes() != null) {
+            final Set<DataSchemaNode> childNodes = container.getChildNodes();
+
+            if ((childNodes != null) && !childNodes.isEmpty()) {
+                return childNodes.iterator().hasNext();
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public DataSchemaNode next() {
+        return allChilds.iterator().next();
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+}
index cfc39994799edd9e9088bc083ff359cd3b623467..64f1dc6e8ec49912b8eed68987200cc77897c615 100644 (file)
@@ -21,26 +21,27 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 
 /**
  * The <code>default</code> implementation of Decimal Type Definition interface.
- *
- *
+ * 
+ * 
  * @see DecimalTypeDefinition
  */
 public final class Decimal64 implements DecimalTypeDefinition {
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
-    private final String units = "";
-    private final BigDecimal defaultValue = null;
+    private static final String UNITS = "";
+    private static final BigDecimal DEFAULT_VALUE = null;
 
     private final String description = "The decimal64 type represents a subset of the real numbers, which can "
             + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "
             + "be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as "
             + "'i x 10^-n' where i is an integer64 and n is an integer between 1 and 18, inclusively.";
 
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.3";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.3";
 
     private final List<RangeConstraint> rangeStatements;
     private final Integer fractionDigits;
     private final DecimalTypeDefinition baseType;
+    private static final int MAX_NUMBER_OF_FRACTION_DIGITS = 18;
 
     /**
      * Default Decimal64 Type Constructor. <br>
@@ -48,20 +49,21 @@ public final class Decimal64 implements DecimalTypeDefinition {
      * The initial range statements are set to Decimal64
      * <code>min=-922337203685477580.8</code> and
      * <code>max=922337203685477580.7</code> <br>
-     * The fractions digits MUST be defined as integer between 1 and 18
-     * inclusively as defined interface {@link DecimalTypeDefinition} <br>
+     * The fractions digits MUST be defined as integer between 1 and
+     * {@link #MAX_NUMBER_OF_FRACTION_DIGITS} inclusively as defined interface
+     * {@link DecimalTypeDefinition} <br>
      * If the fraction digits are not defined inner the definition boundaries
      * the constructor will throw {@link IllegalArgumentException}
-     *
+     * 
      * @param path
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
-     *
+     * 
      * @see DecimalTypeDefinition
      * @exception IllegalArgumentException
      */
     public Decimal64(final SchemaPath path, final Integer fractionDigits) {
-        if (!((fractionDigits.intValue() >= 1) && (fractionDigits.intValue() <= 18))) {
+        if (!((fractionDigits.intValue() >= 1) && (fractionDigits.intValue() <= MAX_NUMBER_OF_FRACTION_DIGITS))) {
             throw new IllegalArgumentException(
                     "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
         }
@@ -73,19 +75,17 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     /**
      * Returns unmodifiable List with default definition of Range Statements.
-     *
+     * 
      * @return unmodifiable List with default definition of Range Statements.
      */
     private List<RangeConstraint> defaultRangeStatements() {
-        final List<RangeConstraint> rangeStatements = new ArrayList<RangeConstraint>();
+        final List<RangeConstraint> rangeStmts = new ArrayList<RangeConstraint>();
         final BigDecimal min = new BigDecimal("-922337203685477580.8");
         final BigDecimal max = new BigDecimal("922337203685477580.7");
-        final String rangeDescription = "Integer values between " + min
-                + " and " + max + ", inclusively.";
-        rangeStatements.add(BaseConstraints.rangeConstraint(min, max,
-                rangeDescription,
+        final String rangeDescription = "Integer values between " + min + " and " + max + ", inclusively.";
+        rangeStmts.add(BaseConstraints.rangeConstraint(min, max, rangeDescription,
                 "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
-        return Collections.unmodifiableList(rangeStatements);
+        return Collections.unmodifiableList(rangeStmts);
     }
 
     @Override
@@ -95,12 +95,12 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     @Override
     public Object getDefaultValue() {
-        return defaultValue;
+        return DEFAULT_VALUE;
     }
 
     @Override
@@ -120,7 +120,7 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     @Override
@@ -183,7 +183,6 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public String toString() {
-        return Decimal64.class.getSimpleName() + "[qname=" + name
-                + ", fractionDigits=" + fractionDigits + "]";
+        return Decimal64.class.getSimpleName() + "[qname=" + name + ", fractionDigits=" + fractionDigits + "]";
     }
 }
index 4a1200e129c1cbd28c2cee4f97ed7c3ee54d62e1..ee56f760d49b7dff67bd4ba00ad81e7209be4d84 100644 (file)
@@ -17,20 +17,20 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 
 public final class EmptyType implements EmptyTypeDefinition {
-    private static EmptyType INSTANCE;
+    private static EmptyType instance;
     private static final QName NAME = BaseTypes.constructQName("empty");
-    private static final SchemaPath path = new SchemaPath(Collections.singletonList(NAME), true);
-    private static final String description = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence.";
-    private static final String reference = "https://tools.ietf.org/html/rfc6020#page-131";
+    private static final SchemaPath PATH = new SchemaPath(Collections.singletonList(NAME), true);
+    private static final String DESCRIPTION = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence.";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#page-131";
 
     private EmptyType() {
     }
 
     public static EmptyType getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new EmptyType();
+        if (instance == null) {
+            instance = new EmptyType();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
@@ -55,17 +55,17 @@ public final class EmptyType implements EmptyTypeDefinition {
 
     @Override
     public SchemaPath getPath() {
-        return path;
+        return PATH;
     }
 
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     @Override
index 472bc69517040cb42bbd6407c85f257c30a981e6..3ae8eb346de99e78e63fceb7469ab3912917e07a 100644 (file)
@@ -1,10 +1,10 @@
 /*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.yangtools.yang.model.util;
 
 import java.util.Collections;
@@ -17,19 +17,20 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 
 /**
- * The <code>default</code> implementation of Enumertaion Type Definition interface.
- *
+ * The <code>default</code> implementation of Enumertaion Type Definition
+ * interface.
+ * 
  * @see EnumTypeDefinition
  */
 public final class EnumerationType implements EnumTypeDefinition {
     private final QName name = BaseTypes.constructQName("enumeration");
     private final SchemaPath path;
-    private final String description = "The enumeration built-in type represents values from a set of assigned names.";
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.6";
+    private static final String DESCRIPTION = "The enumeration built-in type represents values from a set of assigned names.";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.6";
 
     private final EnumPair defaultEnum;
     private final List<EnumPair> enums;
-    private final String units = "";
+    private static final String UNITS = "";
     private final EnumTypeDefinition baseType;
 
     public EnumerationType(final SchemaPath path, final List<EnumPair> enums) {
@@ -40,8 +41,7 @@ public final class EnumerationType implements EnumTypeDefinition {
         this.baseType = this;
     }
 
-    public EnumerationType(final SchemaPath path, final EnumPair defaultEnum,
-            final List<EnumPair> enums) {
+    public EnumerationType(final SchemaPath path, final EnumPair defaultEnum, final List<EnumPair> enums) {
         super();
         this.path = path;
         this.baseType = this;
@@ -51,8 +51,9 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public EnumTypeDefinition getBaseType() {
@@ -61,18 +62,20 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -81,7 +84,7 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -91,7 +94,7 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -101,27 +104,28 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -131,8 +135,10 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.base.type.api.EnumTypeDefinition#getValues()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.base.type.api.EnumTypeDefinition
+     * #getValues()
      */
     @Override
     public List<EnumPair> getValues() {
@@ -148,16 +154,10 @@ public final class EnumerationType implements EnumTypeDefinition {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result
-                + ((defaultEnum == null) ? 0 : defaultEnum.hashCode());
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
+        result = prime * result + ((defaultEnum == null) ? 0 : defaultEnum.hashCode());
         result = prime * result + ((enums == null) ? 0 : enums.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
 
@@ -180,13 +180,6 @@ public final class EnumerationType implements EnumTypeDefinition {
         } else if (!defaultEnum.equals(other.defaultEnum)) {
             return false;
         }
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
         if (enums == null) {
             if (other.enums != null) {
                 return false;
@@ -208,20 +201,6 @@ public final class EnumerationType implements EnumTypeDefinition {
         } else if (!path.equals(other.path)) {
             return false;
         }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
         return true;
     }
 
@@ -233,15 +212,15 @@ public final class EnumerationType implements EnumTypeDefinition {
         builder.append(", path=");
         builder.append(path);
         builder.append(", description=");
-        builder.append(description);
+        builder.append(DESCRIPTION);
         builder.append(", reference=");
-        builder.append(reference);
+        builder.append(REFERENCE);
         builder.append(", defaultEnum=");
         builder.append(defaultEnum);
         builder.append(", enums=");
         builder.append(enums);
         builder.append(", units=");
-        builder.append(units);
+        builder.append(UNITS);
         builder.append("]");
         return builder.toString();
     }
index f498608c0f91f007d629e94bd01aefa925804216..1156762cca83c9a1a583dcaf1e2acd6b5352c0a4 100644 (file)
@@ -1,95 +1,95 @@
-/*\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.yang.model.util;\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
-import org.opendaylight.yangtools.yang.model.api.Status;\r
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;\r
-import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;\r
-\r
-/**\r
- * The <code>default</code> implementation of Identityref Type Definition\r
- * interface.\r
- *\r
- * @see IdentityrefTypeDefinition\r
- */\r
-public final class IdentityrefType implements IdentityrefTypeDefinition {\r
-    private final QName name = BaseTypes.constructQName("identityref");\r
-    private final SchemaPath path;\r
-    private final String description = "The identityref type is used to reference an existing identity.";\r
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.10";\r
-    private final IdentityrefTypeDefinition baseType;\r
-    private final QName identity;\r
-    private final String units = "";\r
-\r
-    public IdentityrefType(QName identity, SchemaPath schemaPath) {\r
-        this.identity = identity;\r
-        this.path = schemaPath;\r
-        this.baseType = this;\r
-    }\r
-\r
-    @Override\r
-    public String getUnits() {\r
-        return units;\r
-    }\r
-\r
-    @Override\r
-    public Object getDefaultValue() {\r
-        return identity;\r
-    }\r
-\r
-    @Override\r
-    public QName getQName() {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public SchemaPath getPath() {\r
-        return path;\r
-    }\r
-\r
-    @Override\r
-    public String getDescription() {\r
-        return description;\r
-    }\r
-\r
-    @Override\r
-    public String getReference() {\r
-        return reference;\r
-    }\r
-\r
-    @Override\r
-    public Status getStatus() {\r
-        return Status.CURRENT;\r
-    }\r
-\r
-    @Override\r
-    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
-        return Collections.emptyList();\r
-    }\r
-\r
-    @Override\r
-    public QName getIdentity() {\r
-        return identity;\r
-    }\r
-\r
-    @Override\r
-    public IdentityrefTypeDefinition getBaseType() {\r
-        return baseType;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "identityref " + identity.getLocalName();\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.yang.model.util;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
+
+/**
+ * The <code>default</code> implementation of Identityref Type Definition
+ * interface.
+ * 
+ * @see IdentityrefTypeDefinition
+ */
+public final class IdentityrefType implements IdentityrefTypeDefinition {
+    private final QName name = BaseTypes.constructQName("identityref");
+    private final SchemaPath path;
+    private static final String DESCRIPTION = "The identityref type is used to reference an existing identity.";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.10";
+    private final IdentityrefTypeDefinition baseType;
+    private final QName identity;
+    private static final String UNITS = "";
+
+    public IdentityrefType(QName identity, SchemaPath schemaPath) {
+        this.identity = identity;
+        this.path = schemaPath;
+        this.baseType = this;
+    }
+
+    @Override
+    public String getUnits() {
+        return UNITS;
+    }
+
+    @Override
+    public Object getDefaultValue() {
+        return identity;
+    }
+
+    @Override
+    public QName getQName() {
+        return name;
+    }
+
+    @Override
+    public SchemaPath getPath() {
+        return path;
+    }
+
+    @Override
+    public String getDescription() {
+        return DESCRIPTION;
+    }
+
+    @Override
+    public String getReference() {
+        return REFERENCE;
+    }
+
+    @Override
+    public Status getStatus() {
+        return Status.CURRENT;
+    }
+
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public QName getIdentity() {
+        return identity;
+    }
+
+    @Override
+    public IdentityrefTypeDefinition getBaseType() {
+        return baseType;
+    }
+
+    @Override
+    public String toString() {
+        return "identityref " + identity.getLocalName();
+    }
+
+}
index 1af0fb8ff04cea9d35f28ce77f8397bd1dac403d..4949d4ebeec24721bf6693b52e14e61b2699ea00 100644 (file)
@@ -20,20 +20,23 @@ import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefi
 /**
  * The <code>default</code> implementation of Instance Identifier Type
  * Definition interface.
- *
+ * 
  * @see InstanceIdentifierTypeDefinition
  */
 public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
-    private static final QName name = BaseTypes.constructQName("instance-identifier");
-    private static final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
-    private static final String description = "The instance-identifier built-in type is used to "
+    private static final QName NAME = BaseTypes.constructQName("instance-identifier");
+    private static final SchemaPath PATH = new SchemaPath(Collections.singletonList(NAME), true);
+    private static final String DESCRIPTION = "The instance-identifier built-in type is used to "
             + "uniquely identify a particular instance node in the data tree.";
-    private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.13";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.13";
 
     private final RevisionAwareXPath xpath;
-    private static final String units = "";
+    private static final String UNITS = "";
     private boolean requireInstance = true;
 
+    private static final int HASH_BOOLEAN_TRUE = 1231;
+    private static final int HASH_BOOLEAN_FALSE = 1237;
+
     public InstanceIdentifier(final RevisionAwareXPath xpath) {
         this.xpath = xpath;
     }
@@ -45,7 +48,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
@@ -56,17 +59,17 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
      * ()
@@ -78,48 +81,48 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
     public QName getQName() {
-        return name;
+        return NAME;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
     public SchemaPath getPath() {
-        return path;
+        return PATH;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -129,7 +132,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getExtensionSchemaNodes
      * ()
@@ -141,7 +144,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.type.
      * InstanceIdentifierTypeDefinition# getPathStatement()
      */
@@ -152,7 +155,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.type.
      * InstanceIdentifierTypeDefinition# requireInstance()
      */
@@ -165,27 +168,33 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + (requireInstance ? 1231 : 1237);
+        result = prime * result + (requireInstance ? HASH_BOOLEAN_TRUE : HASH_BOOLEAN_FALSE);
         result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
         return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         InstanceIdentifier other = (InstanceIdentifier) obj;
-        if (requireInstance != other.requireInstance)
+        if (requireInstance != other.requireInstance) {
             return false;
+        }
         if (xpath == null) {
-            if (other.xpath != null)
+            if (other.xpath != null) {
                 return false;
-        } else if (!xpath.equals(other.xpath))
+            }
+        } else if (!xpath.equals(other.xpath)) {
             return false;
+        }
         return true;
     }
 
index 629e9ff7d3969af347fdbaae4ba25dd5cf440a01..d73bf754ff459f84fdbb1ce7f89c46f321aa14ae 100644 (file)
@@ -14,11 +14,11 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * Implementation of Yang int16 built-in type. <br>
  * int16 represents integer values between -32768 and 32767, inclusively. The
  * Java counterpart of Yang int16 built-in type is {@link Short}.
- *
+ * 
  * @see AbstractSignedInteger
  */
 public final class Int16 extends AbstractSignedInteger {
-    private static Int16 INSTANCE;
+    private static Int16 instance;
     private static final QName NAME = BaseTypes.constructQName("int16");
     private static final String DESCRIPTION = "int16  represents integer values between -32768 and 32767, inclusively.";
 
@@ -27,10 +27,10 @@ public final class Int16 extends AbstractSignedInteger {
     }
 
     public static Int16 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Int16();
+        if (instance == null) {
+            instance = new Int16();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index 82f278c40f8bc36a86787e838f524567cf640827..799ca00d0c39f3439f3ab1309696fa8f9bbe2d75 100644 (file)
@@ -15,12 +15,12 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * int32 represents integer values between -2147483648 and 2147483647,
  * inclusively. The Java counterpart of Yang int32 built-in type is
  * {@link Integer}.
- *
+ * 
  * @see AbstractSignedInteger
- *
+ * 
  */
 public final class Int32 extends AbstractSignedInteger {
-    private static Int32 INSTANCE;
+    private static Int32 instance;
     private static final QName NAME = BaseTypes.constructQName("int32");
     private static final String DESCRIPTION = "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
 
@@ -29,10 +29,10 @@ public final class Int32 extends AbstractSignedInteger {
     }
 
     public static Int32 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Int32();
+        if (instance == null) {
+            instance = new Int32();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index 0800f3c8c59199ed484e7ec75251a6aac67d85ba..a22d2d5a6c478a75cfc33996381c80e7fa9b03cd 100644 (file)
@@ -15,10 +15,10 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * int64 represents integer values between -9223372036854775808 and
  * 9223372036854775807, inclusively. The Java counterpart of Yang int64 built-in
  * type is {@link Long}.
- *
+ * 
  */
 public final class Int64 extends AbstractSignedInteger {
-    private static Int64 INSTANCE;
+    private static Int64 instance;
     private static final QName NAME = BaseTypes.constructQName("int64");
     private static final String DESCRIPTION = "int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";
 
@@ -27,10 +27,10 @@ public final class Int64 extends AbstractSignedInteger {
     }
 
     public static Int64 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Int64();
+        if (instance == null) {
+            instance = new Int64();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index 537eef44de1f66fc02e0cc67c39dd0ef4bda1ff4..16f7ee68f52cdea2246092f88f32572dc50fd977 100644 (file)
@@ -14,11 +14,11 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * Implementation of Yang int8 built-in type. <br>
  * int8 represents integer values between -128 and 127, inclusively. The Java
  * counterpart of Yang int8 built-in type is {@link Byte}.
- *
+ * 
  * @see AbstractSignedInteger
  */
 public final class Int8 extends AbstractSignedInteger {
-    private static Int8 INSTANCE;
+    private static Int8 instance;
     private static final QName NAME = BaseTypes.constructQName("int8");
     private static final String DESCRIPTION = "represents integer values between -128 and 127, inclusively.";
 
@@ -27,10 +27,10 @@ public final class Int8 extends AbstractSignedInteger {
     }
 
     public static Int8 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Int8();
+        if (instance == null) {
+            instance = new Int8();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index a3577ba0aec07db8b3bfecf2f406d2600ca225ac..c5852696e4ec14b9c516d00aae66b1de5397a72b 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.yangtools.yang.model.util;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 
 /**
- * The <code>default</code> implementation of Instance Rewision Aware XPath interface.
+ * The <code>default</code> implementation of Instance Rewision Aware XPath
+ * interface.
  * 
  * @see RevisionAwareXPath
  */
@@ -19,6 +20,9 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath {
     private final String xpath;
     private final boolean absolute;
 
+    private static final int HASH_BOOLEAN_TRUE = 1231;
+    private static final int HASH_BOOLEAN_FALSE = 1237;
+
     public RevisionAwareXPathImpl(String xpath, boolean absolute) {
         this.xpath = xpath;
         this.absolute = absolute;
@@ -34,7 +38,7 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath {
         final int prime = 31;
         int result = 1;
         result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
-        result = prime * result + (absolute ? 1231 : 1237);
+        result = prime * result + (absolute ? HASH_BOOLEAN_TRUE : HASH_BOOLEAN_FALSE);
         return result;
     }
 
@@ -62,7 +66,7 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath {
         }
         return false;
     }
-    
+
     @Override
     public String toString() {
         return xpath;
index bad6067a417c65543810ae76ef1610ceea5ae30b..93f0c7c13c5bf58944fac59033a4f388cd5cd150 100644 (file)
@@ -1,10 +1,10 @@
 /*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.yangtools.yang.model.util;
 
 import java.util.ArrayList;
@@ -21,19 +21,19 @@ import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
 /**
  * The <code>default</code> implementation of String Type Definition interface.
- *
+ * 
  * @see StringTypeDefinition
  */
 public final class StringType implements StringTypeDefinition {
     private static final StringType INSTANCE = new StringType();
     private final QName name = BaseTypes.constructQName("string");
     private final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
-    private final String defaultValue = "";
-    private final String description = "";
-    private final String reference = "";
+    private static final String DEFAULT_VALUE = "";
+    private static final String DESCRIPTION = "";
+    private static final String REFERENCE = "";
     private final List<LengthConstraint> lengthStatements;
     private final List<PatternConstraint> patterns;
-    private final String units = "";
+    private static final String UNITS = "";
 
     /**
      * Default Constructor.
@@ -51,8 +51,9 @@ public final class StringType implements StringTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public StringTypeDefinition getBaseType() {
@@ -61,27 +62,29 @@ public final class StringType implements StringTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
-        return defaultValue;
+        return DEFAULT_VALUE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -91,7 +94,7 @@ public final class StringType implements StringTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -101,27 +104,28 @@ public final class StringType implements StringTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
+     * 
+     * @see
+     * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -131,7 +135,7 @@ public final class StringType implements StringTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * com.csico.yang.model.base.type.api.StringTypeDefinition#getLengthStatements
      * ()
@@ -143,7 +147,7 @@ public final class StringType implements StringTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * com.csico.yang.model.base.type.api.StringTypeDefinition#getPatterns()
      */
@@ -161,20 +165,10 @@ public final class StringType implements StringTypeDefinition {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
-        result = prime
-                * result
-                + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());
+        result = prime * result + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((patterns == null) ? 0 : patterns.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
+        result = prime * result + ((patterns == null) ? 0 : patterns.hashCode());
         return result;
     }
 
@@ -190,20 +184,6 @@ public final class StringType implements StringTypeDefinition {
             return false;
         }
         StringType other = (StringType) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
         if (lengthStatements == null) {
             if (other.lengthStatements != null) {
                 return false;
@@ -222,10 +202,8 @@ public final class StringType implements StringTypeDefinition {
             if (other.path != null) {
                 return false;
             }
-        } else if ((path != null) && (other.path != null)) {
-            if (!path.getPath().equals(other.path.getPath())) {
-                return false;
-            }
+        } else if (!path.getPath().equals(other.path.getPath())) {
+            return false;
         }
         if (patterns == null) {
             if (other.patterns != null) {
@@ -234,20 +212,6 @@ public final class StringType implements StringTypeDefinition {
         } else if (!patterns.equals(other.patterns)) {
             return false;
         }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
         return true;
     }
 
@@ -259,17 +223,17 @@ public final class StringType implements StringTypeDefinition {
         builder.append(", path=");
         builder.append(path);
         builder.append(", defaultValue=");
-        builder.append(defaultValue);
+        builder.append(DEFAULT_VALUE);
         builder.append(", description=");
-        builder.append(description);
+        builder.append(DESCRIPTION);
         builder.append(", reference=");
-        builder.append(reference);
+        builder.append(REFERENCE);
         builder.append(", lengthStatements=");
         builder.append(lengthStatements);
         builder.append(", patterns=");
         builder.append(patterns);
         builder.append(", units=");
-        builder.append(units);
+        builder.append(UNITS);
         builder.append("]");
         return builder.toString();
     }
index 05cead85ff07f8f51e9f0de5e66545bd2cfe4f3b..120f4926cf875b6c0c90f398711d594dea810142 100644 (file)
@@ -14,11 +14,11 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * Implementation of Yang uint16 built-in type. <br>
  * uint16 represents integer values between 0 and 65535, inclusively. The Java
  * counterpart of Yang uint16 built-in type is {@link Integer}.
- *
+ * 
  */
 public final class Uint16 extends AbstractUnsignedInteger {
     public static final int MAX_VALUE = 65535;
-    private static Uint16 INSTANCE;
+    private static Uint16 instance;
     private static final QName NAME = BaseTypes.constructQName("uint16");
     private static final String DESCRIPTION = "uint16 represents integer values between 0 and 65535, inclusively.";
 
@@ -27,10 +27,10 @@ public final class Uint16 extends AbstractUnsignedInteger {
     }
 
     public static Uint16 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Uint16();
+        if (instance == null) {
+            instance = new Uint16();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index d5d3e9efe6b885d1c37ab0e318e7a512a85c0fed..375a26bf918aa6c909480d1fb85f048ac21b93bc 100644 (file)
@@ -13,11 +13,11 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
 /**
  * Implementation of Yang uint32 built-in type. <br>
  * uint32 represents integer values between 0 and 4294967295, inclusively.
- *
+ * 
  */
 public final class Uint32 extends AbstractUnsignedInteger {
     public static final long MAX_VALUE = 4294967295L;
-    private static Uint32 INSTANCE;
+    private static Uint32 instance;
     private static final QName NAME = BaseTypes.constructQName("uint32");
     private static final String DESCRIPTION = "uint32 represents integer values between 0 and 4294967295, inclusively.";
 
@@ -26,10 +26,10 @@ public final class Uint32 extends AbstractUnsignedInteger {
     }
 
     public static Uint32 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Uint32();
+        if (instance == null) {
+            instance = new Uint32();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index 078b569e15293ac2f7377872de8f7c4cfbb59530..e003873eb6641bd2e212b14b76907e42ea78cafc 100644 (file)
@@ -17,11 +17,11 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * uint64 represents integer values between 0 and 18446744073709551615,
  * inclusively. The Java counterpart of Yang uint64 built-in type is
  * {@link BigInteger}.
- *
+ * 
  */
 public final class Uint64 extends AbstractUnsignedInteger {
     public static final BigInteger MAX_VALUE = new BigInteger("18446744073709551615");
-    private static Uint64 INSTANCE;
+    private static Uint64 instance;
     private static final QName NAME = BaseTypes.constructQName("uint64");
     private static final String DESCRIPTION = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
 
@@ -30,10 +30,10 @@ public final class Uint64 extends AbstractUnsignedInteger {
     }
 
     public static Uint64 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Uint64();
+        if (instance == null) {
+            instance = new Uint64();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index 4befa856ec0e68a15dbdcb11608f19a5a57fd108..4c36ae1d906c7cfbe33065103bb56562c6b52a5d 100644 (file)
@@ -13,12 +13,12 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
 /**
  * Implementation of Yang uint8 built-in type. <br>
  * uint8 represents integer values between 0 and 255, inclusively.
- *
+ * 
  * @see AbstractUnsignedInteger
  */
 public final class Uint8 extends AbstractUnsignedInteger {
     public static final int MAX_VALUE = 255;
-    private static Uint8 INSTANCE;
+    private static Uint8 instance;
     private static final QName NAME = BaseTypes.constructQName("uint8");
     private static final String DESCRIPTION = "uint8  represents integer values between 0 and 255, inclusively.";
 
@@ -27,10 +27,10 @@ public final class Uint8 extends AbstractUnsignedInteger {
     }
 
     public static Uint8 getInstance() {
-        if (INSTANCE == null) {
-            INSTANCE = new Uint8();
+        if (instance == null) {
+            instance = new Uint8();
         }
-        return INSTANCE;
+        return instance;
     }
 
     @Override
index 81bda38776c8dca0e6758336644aa19c7caf5800..a12c1c1119ab0520843279d8e61617dbe0196cef 100644 (file)
@@ -20,14 +20,13 @@ import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 public final class UnionType implements UnionTypeDefinition {
     private final QName name = BaseTypes.constructQName("union");
     private final SchemaPath path = BaseTypes.schemaPath(name);
-    private final String description = "The union built-in type represents a value that corresponds to one of its member types.";
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.12";
+    private static final String DESCRIPTION = "The union built-in type represents a value that corresponds to one of its member types.";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.12";
     private final List<TypeDefinition<?>> types;
 
     public UnionType(List<TypeDefinition<?>> types) {
         if (types == null) {
-            throw new NullPointerException(
-                    "When the type is 'union', the 'type' statement MUST be present.");
+            throw new IllegalArgumentException("When the type is 'union', the 'type' statement MUST be present.");
         }
         this.types = types;
     }
@@ -59,12 +58,12 @@ public final class UnionType implements UnionTypeDefinition {
 
     @Override
     public String getDescription() {
-        return description;
+        return DESCRIPTION;
     }
 
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     @Override
index 7459e6f6e6987a82f6f2c07018520bc7021a4e7c..748507f38a4953ad58c525688eb7c33c57abe5a9 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
 
-public class UnknownType implements UnknownTypeDefinition {
+public final class UnknownType implements UnknownTypeDefinition {
 
     private final QName name;
     private final SchemaPath path;
@@ -44,8 +44,7 @@ public class UnknownType implements UnknownTypeDefinition {
         private String description;
         private String reference;
 
-        private List<LengthConstraint> lengthStatements = Collections
-                .emptyList();
+        private List<LengthConstraint> lengthStatements = Collections.emptyList();
         private List<PatternConstraint> patterns = Collections.emptyList();
         private List<RangeConstraint> rangeStatements = Collections.emptyList();
         private List<UnknownSchemaNode> extensions = Collections.emptyList();
@@ -57,8 +56,7 @@ public class UnknownType implements UnknownTypeDefinition {
         private Object defaultValue = null;
         private boolean referenceOnly = false;
 
-        public Builder(final QName name, final String description,
-                final String reference) {
+        public Builder(final QName name, final String description, final String reference) {
             this.name = name;
             this.path = BaseTypes.schemaPath(name);
             this.description = description;
@@ -80,8 +78,7 @@ public class UnknownType implements UnknownTypeDefinition {
             return this;
         }
 
-        public Builder lengthStatements(
-                final List<LengthConstraint> lengthStatements) {
+        public Builder lengthStatements(final List<LengthConstraint> lengthStatements) {
             this.lengthStatements = lengthStatements;
             return this;
         }
@@ -91,8 +88,7 @@ public class UnknownType implements UnknownTypeDefinition {
             return this;
         }
 
-        public Builder rangeStatements(
-                final List<RangeConstraint> rangeStatements) {
+        public Builder rangeStatements(final List<RangeConstraint> rangeStatements) {
             this.rangeStatements = rangeStatements;
             return this;
         }
@@ -132,8 +128,8 @@ public class UnknownType implements UnknownTypeDefinition {
         }
 
         public void setReferenceOnly(boolean b) {
-            this.referenceOnly  = b;
-            
+            this.referenceOnly = b;
+
         }
     }
 
@@ -156,7 +152,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
      */
@@ -167,7 +163,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
@@ -177,7 +173,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
      * ()
@@ -189,7 +185,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -199,7 +195,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -209,7 +205,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
      */
@@ -220,7 +216,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
      */
     @Override
@@ -230,7 +226,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -240,7 +236,7 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see
      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getExtensionSchemaNodes
      * ()
@@ -252,9 +248,8 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
+     * 
+     * @see org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
      * #getRangeStatements()
      */
     @Override
@@ -264,9 +259,8 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
+     * 
+     * @see org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
      * #getLengthStatements()
      */
     @Override
@@ -276,9 +270,8 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
+     * 
+     * @see org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
      * #getPatterns()
      */
     @Override
@@ -288,9 +281,8 @@ public class UnknownType implements UnknownTypeDefinition {
 
     /*
      * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
+     * 
+     * @see org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition
      * #getLengthConstraint()
      */
     @Override
@@ -307,31 +299,21 @@ public class UnknownType implements UnknownTypeDefinition {
     public boolean isReferenceOnly() {
         return referenceOnly;
     }
-    
+
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
-        result = prime * result
-                + ((extensions == null) ? 0 : extensions.hashCode());
-        result = prime
-                * result
-                + ((lengthConstraint == null) ? 0 : lengthConstraint.hashCode());
-        result = prime
-                * result
-                + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());
+        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+        result = prime * result + ((description == null) ? 0 : description.hashCode());
+        result = prime * result + ((extensions == null) ? 0 : extensions.hashCode());
+        result = prime * result + ((lengthConstraint == null) ? 0 : lengthConstraint.hashCode());
+        result = prime * result + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((patterns == null) ? 0 : patterns.hashCode());
-        result = prime * result
-                + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
+        result = prime * result + ((patterns == null) ? 0 : patterns.hashCode());
+        result = prime * result + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
+        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
         result = prime * result + ((status == null) ? 0 : status.hashCode());
         result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
index 7b75a30247bd72af8773b71bfe7018cd74d11dc1..0cf3b859bc3943e01ddc09ae4d07efc91379d279 100644 (file)
@@ -1,83 +1,89 @@
-/*\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.yang.model.util;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
-\r
-public final class YangTypesConverter {\r
-    private static final Set<String> baseYangTypes = new HashSet<String>();\r
-\r
-    static {\r
-        baseYangTypes.add("binary");\r
-        baseYangTypes.add("bits");\r
-        baseYangTypes.add("boolean");\r
-        baseYangTypes.add("decimal64");\r
-        baseYangTypes.add("empty");\r
-        baseYangTypes.add("enumeration");\r
-        baseYangTypes.add("identityref");\r
-        baseYangTypes.add("instance-identifier");\r
-        baseYangTypes.add("int8");\r
-        baseYangTypes.add("int16");\r
-        baseYangTypes.add("int32");\r
-        baseYangTypes.add("int64");\r
-        baseYangTypes.add("leafref");\r
-        baseYangTypes.add("string");\r
-        baseYangTypes.add("uint8");\r
-        baseYangTypes.add("uint16");\r
-        baseYangTypes.add("uint32");\r
-        baseYangTypes.add("uint64");\r
-        baseYangTypes.add("union");\r
-    }\r
-\r
-    public static boolean isBaseYangType(String type) {\r
-        return baseYangTypes.contains(type);\r
-    }\r
-\r
-    public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {\r
-        TypeDefinition<?> type = null;\r
-\r
-        if (typeName.startsWith("int")) {\r
-            if ("int8".equals(typeName)) {\r
-                type = Int8.getInstance();\r
-            } else if ("int16".equals(typeName)) {\r
-                type = Int16.getInstance();\r
-            } else if ("int32".equals(typeName)) {\r
-                type = Int32.getInstance();\r
-            } else if ("int64".equals(typeName)) {\r
-                type = Int64.getInstance();\r
-            }\r
-        } else if (typeName.startsWith("uint")) {\r
-            if ("uint8".equals(typeName)) {\r
-                type = Uint8.getInstance();\r
-            } else if ("uint16".equals(typeName)) {\r
-                type = Uint16.getInstance();\r
-            } else if ("uint32".equals(typeName)) {\r
-                type = Uint32.getInstance();\r
-            } else if ("uint64".equals(typeName)) {\r
-                type = Uint64.getInstance();\r
-            }\r
-        } else if ("string".equals(typeName)) {\r
-            type = StringType.getIntance();\r
-        } else if("binary".equals(typeName)) {\r
-            type = BinaryType.getInstance();\r
-        } else if("boolean".equals(typeName)) {\r
-            type = BooleanType.getInstance();\r
-        } else if("empty".equals(typeName)) {\r
-            type = EmptyType.getInstance();\r
-        } else if("instance-identifier".equals(typeName)) {\r
-            // FIXME\r
-            type = new InstanceIdentifier(null, true);\r
-        }\r
-\r
-        return type;\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.yang.model.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+
+public final class YangTypesConverter {
+    private static final Set<String> BASE_YANG_TYPES = new HashSet<String>();
+
+    /**
+     * It isn't desirable to create the instances of this class
+     */
+    private YangTypesConverter() {
+    }
+
+    static {
+        BASE_YANG_TYPES.add("binary");
+        BASE_YANG_TYPES.add("bits");
+        BASE_YANG_TYPES.add("boolean");
+        BASE_YANG_TYPES.add("decimal64");
+        BASE_YANG_TYPES.add("empty");
+        BASE_YANG_TYPES.add("enumeration");
+        BASE_YANG_TYPES.add("identityref");
+        BASE_YANG_TYPES.add("instance-identifier");
+        BASE_YANG_TYPES.add("int8");
+        BASE_YANG_TYPES.add("int16");
+        BASE_YANG_TYPES.add("int32");
+        BASE_YANG_TYPES.add("int64");
+        BASE_YANG_TYPES.add("leafref");
+        BASE_YANG_TYPES.add("string");
+        BASE_YANG_TYPES.add("uint8");
+        BASE_YANG_TYPES.add("uint16");
+        BASE_YANG_TYPES.add("uint32");
+        BASE_YANG_TYPES.add("uint64");
+        BASE_YANG_TYPES.add("union");
+    }
+
+    public static boolean isBaseYangType(String type) {
+        return BASE_YANG_TYPES.contains(type);
+    }
+
+    public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {
+        TypeDefinition<?> type = null;
+
+        if (typeName.startsWith("int")) {
+            if ("int8".equals(typeName)) {
+                type = Int8.getInstance();
+            } else if ("int16".equals(typeName)) {
+                type = Int16.getInstance();
+            } else if ("int32".equals(typeName)) {
+                type = Int32.getInstance();
+            } else if ("int64".equals(typeName)) {
+                type = Int64.getInstance();
+            }
+        } else if (typeName.startsWith("uint")) {
+            if ("uint8".equals(typeName)) {
+                type = Uint8.getInstance();
+            } else if ("uint16".equals(typeName)) {
+                type = Uint16.getInstance();
+            } else if ("uint32".equals(typeName)) {
+                type = Uint32.getInstance();
+            } else if ("uint64".equals(typeName)) {
+                type = Uint64.getInstance();
+            }
+        } else if ("string".equals(typeName)) {
+            type = StringType.getIntance();
+        } else if ("binary".equals(typeName)) {
+            type = BinaryType.getInstance();
+        } else if ("boolean".equals(typeName)) {
+            type = BooleanType.getInstance();
+        } else if ("empty".equals(typeName)) {
+            type = EmptyType.getInstance();
+        } else if ("instance-identifier".equals(typeName)) {
+            // FIXME
+            type = new InstanceIdentifier(null, true);
+        }
+
+        return type;
+    }
+
+}
diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/Int8Test.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/Int8Test.java
new file mode 100644 (file)
index 0000000..aab41b8
--- /dev/null
@@ -0,0 +1,20 @@
+package org.opendaylight.yangtools.yang.model.util;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class Int8Test {
+
+    @Test
+    public void testInt8() {
+        Int8 int8 = Int8.getInstance();
+        Int8 int8Second = Int8.getInstance();
+        assertTrue("The method 'getInstance()' has to return the same instance", int8 == int8Second);
+        assertTrue("The method 'getBaseType()' is returning incorrect value", int8.getBaseType() == int8);
+        assertTrue("The method 'getDefaultType()' is returning incorrect value", int8.getDefaultValue() == null);
+        assertEquals("The method 'toString()' is returning incorrect value",
+                "type (urn:ietf:params:xml:ns:yang:1)int8", int8.toString());
+
+    }
+
+}
index 820c976c130f32c45fc48ba7eb4ffc156f069b08..553ab2bd8f8d9816f6a63a125d9086bfa997a0e2 100644 (file)
@@ -15,12 +15,11 @@ import java.util.Set;
 
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
 
 /**
  * Yang Model Parser interface is designed for parsing yang models and convert
  * the information to Data Schema Tree.
- *
+ * 
  */
 public interface YangModelParser {
 
@@ -29,7 +28,7 @@ public interface YangModelParser {
      * modules defined in *.yang files; <br>
      * This method SHOULD be used if user need to parse multiple yang models
      * that are referenced either through import or include statements.
-     *
+     * 
      * @param yangFiles
      *            yang files to parse
      * @return Set of Yang Modules
@@ -42,7 +41,7 @@ public interface YangModelParser {
      * This method SHOULD be used if user has already parsed context and need to
      * parse additinal yang models which can have dependencies on models in this
      * context.
-     *
+     * 
      * @param yangFiles
      *            yang files to parse
      * @param context
@@ -54,7 +53,7 @@ public interface YangModelParser {
     /**
      * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
      * mapped to Files from which they were parsed.
-     *
+     * 
      * @param yangFiles
      *            yang files to parse
      * @return Map of Yang Modules
@@ -66,7 +65,7 @@ public interface YangModelParser {
      * modules defined in *.yang files; <br>
      * This method SHOULD be used if user need to parse multiple yang models
      * that are referenced either through import or include statements.
-     *
+     * 
      * @param yangModelStreams
      *            yang streams to parse
      * @return Set of Yang Modules
@@ -79,7 +78,7 @@ public interface YangModelParser {
      * This method SHOULD be used if user has already parsed context and need to
      * parse additinal yang models which can have dependencies on models in this
      * context.
-     *
+     * 
      * @param yangModelStreams
      *            yang streams to parse
      * @param context
@@ -91,7 +90,7 @@ public interface YangModelParser {
     /**
      * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
      * mapped to IputStreams from which they were parsed.
-     *
+     * 
      * @param yangModelStreams
      *            yang streams to parse
      * @return Map of Yang Modules
@@ -105,7 +104,7 @@ public interface YangModelParser {
      * should not contain ANY Schema Nodes that contains
      * {@link UnknownTypeDefinition} and all dependencies although via import or
      * include definitions are resolved.
-     *
+     * 
      * @param modules
      *            Set of Yang Modules
      * @return Schema Context instance constructed from whole Set of Modules.
index 7183d0c82cf5637a6e5176bad5bc72abdf8e7f9d..e390c4ad32c9f12f0e62c6267839a491f99421d0 100644 (file)
@@ -12,7 +12,7 @@ import java.util.Comparator;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
-public class Comparators {
+public final class Comparators {
 
     public static final QNameComparator QNAME_COMP = new QNameComparator();
     public static final SchemaNodeComparator SCHEMA_NODE_COMP = new SchemaNodeComparator();
index 743b9afb9130a4aa78c716b044bdb55705b0db9a..53e5205d9efbc1ea79e306487a54a65b1dead6a7 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuil
  * Utility class with helper methods to perform operations tied to refine
  * process.
  */
-public class RefineUtils {
+public final class RefineUtils {
 
     private RefineUtils() {
     }
@@ -155,7 +155,7 @@ public class RefineUtils {
 
     /**
      * Check if refine can be performed on given node.
-     *
+     * 
      * @param node
      *            node to refine
      * @param refine
@@ -245,9 +245,9 @@ public class RefineUtils {
      * <li>reference</li>
      * <li>config</li>
      * </ul>
-     *
+     * 
      * These parameters may be refined for any node.
-     *
+     * 
      * @param node
      *            node to refine
      * @param refine
@@ -291,7 +291,7 @@ public class RefineUtils {
 
     /**
      * Perform refine operation on given node.
-     *
+     * 
      * @param nodeToRefine
      *            builder of node to refine
      * @param refine
index 0cd9a7b6e1d21f8414252196f5944bc9de4d59e2..62304cdd6f26f7bfeaa7ab58e1c8aee9eb68525f 100644 (file)
@@ -304,7 +304,7 @@ public class TypesResolutionTest {
         assertEquals("iit", identity.getPrefix());
         assertEquals("service-type", identity.getLocalName());
 
-        LeafSchemaNode type = (LeafSchemaNode)tested.getDataChildByName("type");
+        LeafSchemaNode type = (LeafSchemaNode) tested.getDataChildByName("type");
         assertNotNull(type);
     }