Added validation of range and length constraints. 92/492/1
authorMartin Vitez <mvitez@cisco.com>
Mon, 17 Jun 2013 13:04:54 +0000 (15:04 +0200)
committerMartin Vitez <mvitez@cisco.com>
Mon, 17 Jun 2013 13:04:54 +0000 (15:04 +0200)
Fixed base range constraints of yang uint built-in types. Made rpc input and output statement optional.
Changed formatting of files to conform new sun_coding_style template. Added more tests.

Signed-off-by: Martin Vitez <mvitez@cisco.com>
20 files changed:
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ChoiceBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/RpcDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/TypeConstraints.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/UnknownBoundaryNumber.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/YangParserNegativeTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/YangParserTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile1.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile3.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/negative-scenario/testfile5.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/negative-scenario/testfile6.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/ChoiceNode.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractUnsignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint8.java

index a9e2b3b..f520bf9 100644 (file)
@@ -102,8 +102,7 @@ public final class ChoiceBuilder implements DataSchemaNodeBuilder, AugmentationT
 
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         if (!(childNode instanceof ChoiceCaseBuilder)) {
-            ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(
-                    childNode.getQName(), childNode.getLine());
+            ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(childNode.getQName(), childNode.getLine());
             caseBuilder.addChildNode(childNode);
             cases.add(caseBuilder);
         } else {
@@ -203,7 +202,6 @@ public final class ChoiceBuilder implements DataSchemaNodeBuilder, AugmentationT
         this.defaultCase = defaultCase;
     }
 
-
     private final class ChoiceNodeImpl implements ChoiceNode {
         private final QName qname;
         private SchemaPath path;
@@ -297,8 +295,7 @@ public final class ChoiceBuilder implements DataSchemaNodeBuilder, AugmentationT
             return augmentations;
         }
 
-        private void setAvailableAugmentations(
-                Set<AugmentationSchema> availableAugmentations) {
+        private void setAvailableAugmentations(Set<AugmentationSchema> availableAugmentations) {
             if (availableAugmentations != null) {
                 this.augmentations = availableAugmentations;
             }
@@ -309,8 +306,7 @@ public final class ChoiceBuilder implements DataSchemaNodeBuilder, AugmentationT
             return unknownNodes;
         }
 
-        private void setUnknownSchemaNodes(
-                List<UnknownSchemaNode> unknownSchemaNodes) {
+        private void setUnknownSchemaNodes(List<UnknownSchemaNode> unknownSchemaNodes) {
             if (unknownSchemaNodes != null) {
                 this.unknownNodes = unknownSchemaNodes;
             }
@@ -327,6 +323,7 @@ public final class ChoiceBuilder implements DataSchemaNodeBuilder, AugmentationT
             }
         }
 
+        @Override
         public String getDefaultCase() {
             return defaultCase;
         }
@@ -375,8 +372,7 @@ public final class ChoiceBuilder implements DataSchemaNodeBuilder, AugmentationT
 
         @Override
         public String toString() {
-            StringBuilder sb = new StringBuilder(
-                    ChoiceNodeImpl.class.getSimpleName());
+            StringBuilder sb = new StringBuilder(ChoiceNodeImpl.class.getSimpleName());
             sb.append("[");
             sb.append("qname=" + qname);
             sb.append("]");
index 6cbcec1..855d026 100644 (file)
@@ -26,8 +26,7 @@ import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 
-public final class RpcDefinitionBuilder implements SchemaNodeBuilder,
-        TypeDefinitionAwareBuilder {
+public final class RpcDefinitionBuilder implements SchemaNodeBuilder, TypeDefinitionAwareBuilder {
     private boolean isBuilt;
     private final RpcDefinitionImpl instance;
     private final int line;
@@ -48,8 +47,8 @@ public final class RpcDefinitionBuilder implements SchemaNodeBuilder,
     @Override
     public RpcDefinition build() {
         if (!isBuilt) {
-            final ContainerSchemaNode input = inputBuilder.build();
-            final ContainerSchemaNode output = outputBuilder.build();
+            final ContainerSchemaNode input = inputBuilder == null ? null : inputBuilder.build();
+            final ContainerSchemaNode output = outputBuilder == null ? null : outputBuilder.build();
             instance.setInput(input);
             instance.setOutput(output);
 
@@ -314,8 +313,7 @@ public final class RpcDefinitionBuilder implements SchemaNodeBuilder,
 
         @Override
         public String toString() {
-            StringBuilder sb = new StringBuilder(
-                    RpcDefinitionImpl.class.getSimpleName() + "[");
+            StringBuilder sb = new StringBuilder(RpcDefinitionImpl.class.getSimpleName() + "[");
             sb.append("qname=" + qname);
             sb.append(", path=" + path);
             sb.append(", input=" + input);
index 9443717..6814322 100644 (file)
@@ -84,8 +84,7 @@ import com.google.common.collect.Sets;
 
 public final class YangParserImpl implements YangModelParser {
 
-    private static final Logger logger = LoggerFactory
-            .getLogger(YangParserImpl.class);
+    private static final Logger logger = LoggerFactory.getLogger(YangParserImpl.class);
 
     @Override
     public Map<File, Module> parseYangModelsMapped(List<File> yangFiles) {
@@ -96,27 +95,22 @@ public final class YangParserImpl implements YangModelParser {
                 try {
                     inputStreams.put(new FileInputStream(yangFile), yangFile);
                 } catch (FileNotFoundException e) {
-                    logger.warn("Exception while reading yang file: "
-                            + yangFile.getName(), e);
+                    logger.warn("Exception while reading yang file: " + yangFile.getName(), e);
                 }
             }
 
-            Map<ModuleBuilder, InputStream> builderToStreamMap = Maps
-                    .newHashMap();
+            Map<ModuleBuilder, InputStream> builderToStreamMap = Maps.newHashMap();
 
             final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuilders(
-                    Lists.newArrayList(inputStreams.keySet()),
-                    builderToStreamMap);
+                    Lists.newArrayList(inputStreams.keySet()), builderToStreamMap);
             // return new LinkedHashSet<Module>(build(modules).values());
 
             Map<File, Module> retVal = Maps.newLinkedHashMap();
             Map<ModuleBuilder, Module> builderToModuleMap = build(modules);
 
-            for (Entry<ModuleBuilder, Module> builderToModule : builderToModuleMap
-                    .entrySet()) {
-                retVal.put(inputStreams.get(builderToStreamMap
-                        .get(builderToModule.getKey())), builderToModule
-                        .getValue());
+            for (Entry<ModuleBuilder, Module> builderToModule : builderToModuleMap.entrySet()) {
+                retVal.put(inputStreams.get(builderToStreamMap.get(builderToModule.getKey())),
+                        builderToModule.getValue());
             }
 
             return retVal;
@@ -130,26 +124,21 @@ public final class YangParserImpl implements YangModelParser {
     }
 
     @Override
-    public Set<Module> parseYangModelsFromStreams(
-            final List<InputStream> yangModelStreams) {
-        return Sets.newHashSet(parseYangModelsFromStreamsMapped(
-                yangModelStreams).values());
+    public Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams) {
+        return Sets.newHashSet(parseYangModelsFromStreamsMapped(yangModelStreams).values());
     }
 
     @Override
-    public Map<InputStream, Module> parseYangModelsFromStreamsMapped(
-            final List<InputStream> yangModelStreams) {
+    public Map<InputStream, Module> parseYangModelsFromStreamsMapped(final List<InputStream> yangModelStreams) {
         Map<ModuleBuilder, InputStream> builderToStreamMap = Maps.newHashMap();
 
-        final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuilders(
-                yangModelStreams, builderToStreamMap);
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuilders(yangModelStreams,
+                builderToStreamMap);
         Map<InputStream, Module> retVal = Maps.newLinkedHashMap();
         Map<ModuleBuilder, Module> builderToModuleMap = build(modules);
 
-        for (Entry<ModuleBuilder, Module> builderToModule : builderToModuleMap
-                .entrySet()) {
-            retVal.put(builderToStreamMap.get(builderToModule.getKey()),
-                    builderToModule.getValue());
+        for (Entry<ModuleBuilder, Module> builderToModule : builderToModuleMap.entrySet()) {
+            retVal.put(builderToStreamMap.get(builderToModule.getKey()), builderToModule.getValue());
         }
         return retVal;
     }
@@ -182,12 +171,10 @@ public final class YangParserImpl implements YangModelParser {
         return builders;
     }
 
-    private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(
-            final List<InputStream> yangFileStreams,
+    private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(final List<InputStream> yangFileStreams,
             Map<ModuleBuilder, InputStream> streamToBuilderMap) {
 
-        final ModuleBuilder[] builders = parseModuleBuilders(yangFileStreams,
-                streamToBuilderMap);
+        final ModuleBuilder[] builders = parseModuleBuilders(yangFileStreams, streamToBuilderMap);
 
         // Linked Hash Map MUST be used because Linked Hash Map preserves ORDER
         // of items stored in map.
@@ -202,8 +189,7 @@ public final class YangParserImpl implements YangModelParser {
             if (builderRevision == null) {
                 builderRevision = new Date(0L);
             }
-            TreeMap<Date, ModuleBuilder> builderByRevision = modules
-                    .get(builderName);
+            TreeMap<Date, ModuleBuilder> builderByRevision = modules.get(builderName);
             if (builderByRevision == null) {
                 builderByRevision = new TreeMap<Date, ModuleBuilder>();
             }
@@ -236,13 +222,10 @@ public final class YangParserImpl implements YangModelParser {
         return result;
     }
 
-    private Map<ModuleBuilder, Module> build(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules) {
+    private Map<ModuleBuilder, Module> build(final Map<String, TreeMap<Date, ModuleBuilder>> modules) {
         // fix unresolved nodes
-        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules
-                .entrySet()) {
-            for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue()
-                    .entrySet()) {
+        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+            for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
                 final ModuleBuilder moduleBuilder = childEntry.getValue();
                 fixUnresolvedNodes(modules, moduleBuilder);
             }
@@ -254,11 +237,9 @@ public final class YangParserImpl implements YangModelParser {
         // order!
         // http://docs.oracle.com/javase/6/docs/api/java/util/LinkedHashMap.html
         final Map<ModuleBuilder, Module> result = new LinkedHashMap<ModuleBuilder, Module>();
-        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules
-                .entrySet()) {
+        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             final Map<Date, Module> modulesByRevision = new HashMap<Date, Module>();
-            for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue()
-                    .entrySet()) {
+            for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
                 final ModuleBuilder moduleBuilder = childEntry.getValue();
                 final Module module = moduleBuilder.build();
                 modulesByRevision.put(childEntry.getKey(), module);
@@ -268,9 +249,7 @@ public final class YangParserImpl implements YangModelParser {
         return result;
     }
 
-    private void fixUnresolvedNodes(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
+    private void fixUnresolvedNodes(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder builder) {
         resolveDirtyNodes(modules, builder);
         resolveIdentities(modules, builder);
         resolveUsesRefines(modules, builder);
@@ -286,26 +265,19 @@ public final class YangParserImpl implements YangModelParser {
      * @param module
      *            current module
      */
-    private void resolveDirtyNodes(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
-        final Map<List<String>, TypeAwareBuilder> dirtyNodes = module
-                .getDirtyNodes();
+    private void resolveDirtyNodes(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+        final Map<List<String>, TypeAwareBuilder> dirtyNodes = module.getDirtyNodes();
         if (!dirtyNodes.isEmpty()) {
-            for (Map.Entry<List<String>, TypeAwareBuilder> entry : dirtyNodes
-                    .entrySet()) {
+            for (Map.Entry<List<String>, TypeAwareBuilder> entry : dirtyNodes.entrySet()) {
                 final TypeAwareBuilder nodeToResolve = entry.getValue();
 
                 if (nodeToResolve instanceof UnionTypeBuilder) {
                     // special handling for union types
-                    resolveTypeUnion((UnionTypeBuilder) nodeToResolve, modules,
-                            module);
+                    resolveTypeUnion((UnionTypeBuilder) nodeToResolve, modules, module);
                 } else if (nodeToResolve.getTypedef() instanceof IdentityrefTypeBuilder) {
                     // special handling for identityref types
-                    IdentityrefTypeBuilder idref = (IdentityrefTypeBuilder) nodeToResolve
-                            .getTypedef();
-                    nodeToResolve.setType(new IdentityrefType(findFullQName(
-                            modules, module, idref), idref.getPath()));
+                    IdentityrefTypeBuilder idref = (IdentityrefTypeBuilder) nodeToResolve.getTypedef();
+                    nodeToResolve.setType(new IdentityrefType(findFullQName(modules, module, idref), idref.getPath()));
                 } else {
                     resolveType(nodeToResolve, modules, module);
                 }
@@ -314,46 +286,45 @@ public final class YangParserImpl implements YangModelParser {
     }
 
     private void resolveType(final TypeAwareBuilder nodeToResolve,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder builder) {
         TypeDefinitionBuilder resolvedType = null;
         final int line = nodeToResolve.getLine();
-        final TypeDefinition<?> typedefType = nodeToResolve.getType();
-        final QName unknownTypeQName = typedefType.getBaseType().getQName();
-        final ModuleBuilder dependentModule = findDependentModule(modules,
-                builder, unknownTypeQName.getPrefix(), line);
-
-        final TypeDefinitionBuilder targetTypeBuilder = findTypeDefinitionBuilder(
-                nodeToResolve.getPath(), dependentModule,
-                unknownTypeQName.getLocalName(), builder.getName(), line);
-
-        if (typedefType instanceof ExtendedType) {
-            final ExtendedType extType = (ExtendedType) typedefType;
-            final TypeDefinitionBuilder newType = extendedTypeWithNewBaseType(
-                    nodeToResolve, targetTypeBuilder, extType, modules, builder);
+        final TypeDefinition<?> nodeToResolveType = nodeToResolve.getType();
+        final QName unknownTypeQName = nodeToResolveType.getBaseType().getQName();
+        final ModuleBuilder dependentModule = findDependentModule(modules, builder, unknownTypeQName.getPrefix(), line);
+
+        final TypeDefinitionBuilder targetTypeBuilder = findTypeDefinitionBuilder(nodeToResolve.getPath(),
+                dependentModule, unknownTypeQName.getLocalName(), builder.getName(), line);
+
+        if (nodeToResolveType instanceof ExtendedType) {
+            final ExtendedType extType = (ExtendedType) nodeToResolveType;
+            final TypeDefinitionBuilder newType = extendedTypeWithNewBaseType(nodeToResolve, targetTypeBuilder,
+                    extType, modules, builder);
             resolvedType = newType;
         } else {
             resolvedType = targetTypeBuilder;
         }
+
+        // validate constraints
+        final TypeConstraints constraints = findConstraints(nodeToResolve, new TypeConstraints(builder.getName(),
+                nodeToResolve.getLine()), modules, builder);
+        constraints.validateConstraints();
+
         nodeToResolve.setTypedef(resolvedType);
     }
 
     private void resolveTypeUnion(final UnionTypeBuilder union,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder builder) {
 
         final List<TypeDefinition<?>> unionTypes = union.getTypes();
         final List<TypeDefinition<?>> toRemove = new ArrayList<TypeDefinition<?>>();
         for (TypeDefinition<?> unionType : unionTypes) {
             if (unionType instanceof UnknownType) {
                 final UnknownType ut = (UnknownType) unionType;
-                final ModuleBuilder dependentModule = findDependentModule(
-                        modules, builder, ut.getQName().getPrefix(),
-                        union.getLine());
-                final TypeDefinitionBuilder resolvedType = findTypeDefinitionBuilder(
-                        union.getPath(), dependentModule, ut.getQName()
-                                .getLocalName(), builder.getName(),
+                final ModuleBuilder dependentModule = findDependentModule(modules, builder, ut.getQName().getPrefix(),
                         union.getLine());
+                final TypeDefinitionBuilder resolvedType = findTypeDefinitionBuilder(union.getPath(), dependentModule,
+                        ut.getQName().getLocalName(), builder.getName(), union.getLine());
                 union.setTypedef(resolvedType);
                 toRemove.add(ut);
             } else if (unionType instanceof ExtendedType) {
@@ -361,17 +332,13 @@ public final class YangParserImpl implements YangModelParser {
                 TypeDefinition<?> extTypeBase = extType.getBaseType();
                 if (extTypeBase instanceof UnknownType) {
                     final UnknownType ut = (UnknownType) extTypeBase;
-                    final ModuleBuilder dependentModule = findDependentModule(
-                            modules, builder, ut.getQName().getPrefix(),
-                            union.getLine());
-                    final TypeDefinitionBuilder targetTypeBuilder = findTypeDefinitionBuilder(
-                            union.getPath(), dependentModule, ut.getQName()
-                                    .getLocalName(), builder.getName(),
-                            union.getLine());
-
-                    final TypeDefinitionBuilder newType = extendedTypeWithNewBaseType(
-                            targetTypeBuilder, targetTypeBuilder, extType,
-                            modules, builder);
+                    final ModuleBuilder dependentModule = findDependentModule(modules, builder, ut.getQName()
+                            .getPrefix(), union.getLine());
+                    final TypeDefinitionBuilder targetTypeBuilder = findTypeDefinitionBuilder(union.getPath(),
+                            dependentModule, ut.getQName().getLocalName(), builder.getName(), union.getLine());
+
+                    final TypeDefinitionBuilder newType = extendedTypeWithNewBaseType(targetTypeBuilder,
+                            targetTypeBuilder, extType, modules, builder);
 
                     union.setTypedef(newType);
                     toRemove.add(extType);
@@ -381,16 +348,13 @@ public final class YangParserImpl implements YangModelParser {
         unionTypes.removeAll(toRemove);
     }
 
-    private TypeDefinitionBuilder extendedTypeWithNewBaseType(
-            final TypeAwareBuilder nodeToResolve,
-            final TypeDefinitionBuilder newBaseType,
-            final ExtendedType oldExtendedType,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
-        final TypeConstraints constraints = findConstraints(nodeToResolve,
-                new TypeConstraints(), modules, builder);
-        final TypeDefinitionBuilderImpl newType = new TypeDefinitionBuilderImpl(
-                oldExtendedType.getQName(), nodeToResolve.getLine());
+    private TypeDefinitionBuilder extendedTypeWithNewBaseType(final TypeAwareBuilder nodeToResolve,
+            final TypeDefinitionBuilder newBaseType, final ExtendedType oldExtendedType,
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder builder) {
+        final TypeConstraints constraints = findConstraints(nodeToResolve, new TypeConstraints(builder.getName(),
+                nodeToResolve.getLine()), modules, builder);
+        final TypeDefinitionBuilderImpl newType = new TypeDefinitionBuilderImpl(oldExtendedType.getQName(),
+                nodeToResolve.getLine());
         newType.setTypedef(newBaseType);
         newType.setPath(oldExtendedType.getPath());
         newType.setDescription(oldExtendedType.getDescription());
@@ -406,11 +370,8 @@ public final class YangParserImpl implements YangModelParser {
         return newType;
     }
 
-    private TypeConstraints findConstraints(
-            final TypeAwareBuilder nodeToResolve,
-            final TypeConstraints constraints,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
+    private TypeConstraints findConstraints(final TypeAwareBuilder nodeToResolve, final TypeConstraints constraints,
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder builder) {
 
         // union type cannot be restricted
         if (nodeToResolve instanceof UnionTypeBuilder) {
@@ -427,19 +388,14 @@ public final class YangParserImpl implements YangModelParser {
 
         TypeDefinition<?> type = nodeToResolve.getType();
         if (type == null) {
-            return findConstraints(nodeToResolve.getTypedef(), constraints,
-                    modules, builder);
+            return findConstraints(nodeToResolve.getTypedef(), constraints, modules, builder);
         } else {
             if (type instanceof UnknownType) {
-                ModuleBuilder dependentModule = findDependentModule(modules,
-                        builder, type.getQName().getPrefix(),
+                ModuleBuilder dependentModule = findDependentModule(modules, builder, type.getQName().getPrefix(),
                         nodeToResolve.getLine());
-                TypeDefinitionBuilder tdb = findTypeDefinitionBuilder(
-                        nodeToResolve.getPath(), dependentModule, type
-                                .getQName().getLocalName(), builder.getName(),
-                        nodeToResolve.getLine());
-                return findConstraints(tdb, constraints, modules,
-                        dependentModule);
+                TypeDefinitionBuilder tdb = findTypeDefinitionBuilder(nodeToResolve.getPath(), dependentModule, type
+                        .getQName().getLocalName(), builder.getName(), nodeToResolve.getLine());
+                return findConstraints(tdb, constraints, modules, dependentModule);
             } else if (type instanceof ExtendedType) {
                 ExtendedType extType = (ExtendedType) type;
                 constraints.addFractionDigits(extType.getFractionDigits());
@@ -449,15 +405,11 @@ public final class YangParserImpl implements YangModelParser {
 
                 TypeDefinition<?> base = extType.getBaseType();
                 if (base instanceof UnknownType) {
-                    ModuleBuilder dependentModule = findDependentModule(
-                            modules, builder, base.getQName().getPrefix(),
+                    ModuleBuilder dependentModule = findDependentModule(modules, builder, base.getQName().getPrefix(),
                             nodeToResolve.getLine());
-                    TypeDefinitionBuilder tdb = findTypeDefinitionBuilder(
-                            nodeToResolve.getPath(), dependentModule, base
-                                    .getQName().getLocalName(),
-                            builder.getName(), nodeToResolve.getLine());
-                    return findConstraints(tdb, constraints, modules,
-                            dependentModule);
+                    TypeDefinitionBuilder tdb = findTypeDefinitionBuilder(nodeToResolve.getPath(), dependentModule,
+                            base.getQName().getLocalName(), builder.getName(), nodeToResolve.getLine());
+                    return findConstraints(tdb, constraints, modules, dependentModule);
                 } else {
                     // it has to be base yang type
                     mergeConstraints(type, constraints);
@@ -486,15 +438,12 @@ public final class YangParserImpl implements YangModelParser {
      *            current line in yang model
      * @return
      */
-    private TypeDefinitionBuilder findTypeDefinitionBuilder(
-            SchemaPath dirtyNodeSchemaPath,
-            final ModuleBuilder dependentModule, final String typeName,
-            final String currentModuleName, final int line) {
+    private TypeDefinitionBuilder findTypeDefinitionBuilder(SchemaPath dirtyNodeSchemaPath,
+            final ModuleBuilder dependentModule, final String typeName, final String currentModuleName, final int line) {
         final List<QName> path = dirtyNodeSchemaPath.getPath();
         TypeDefinitionBuilder result = null;
 
-        Set<TypeDefinitionBuilder> typedefs = dependentModule
-                .getModuleTypedefs();
+        Set<TypeDefinitionBuilder> typedefs = dependentModule.getModuleTypedefs();
         result = findTdb(typedefs, typeName);
 
         if (result == null) {
@@ -508,11 +457,9 @@ public final class YangParserImpl implements YangModelParser {
                 currentNode = dependentModule.getModuleNode(currentPath);
 
                 if (currentNode instanceof RpcDefinitionBuilder) {
-                    typedefs = ((RpcDefinitionBuilder) currentNode)
-                            .getTypeDefinitions();
+                    typedefs = ((RpcDefinitionBuilder) currentNode).getTypeDefinitions();
                 } else if (currentNode instanceof DataNodeContainerBuilder) {
-                    typedefs = ((DataNodeContainerBuilder) currentNode)
-                            .getTypeDefinitions();
+                    typedefs = ((DataNodeContainerBuilder) currentNode).getTypeDefinitions();
                 } else {
                     typedefs = Collections.emptySet();
                 }
@@ -527,12 +474,10 @@ public final class YangParserImpl implements YangModelParser {
         if (result != null) {
             return result;
         }
-        throw new YangParseException(currentModuleName, line,
-                "Referenced type '" + typeName + "' not found.");
+        throw new YangParseException(currentModuleName, line, "Referenced type '" + typeName + "' not found.");
     }
 
-    private TypeDefinitionBuilder findTdb(Set<TypeDefinitionBuilder> types,
-            String name) {
+    private TypeDefinitionBuilder findTdb(Set<TypeDefinitionBuilder> types, String name) {
         for (TypeDefinitionBuilder td : types) {
             if (td.getQName().getLocalName().equals(name)) {
                 return td;
@@ -547,26 +492,18 @@ public final class YangParserImpl implements YangModelParser {
      * @param referencedType
      * @param constraints
      */
-    private void mergeConstraints(final TypeDefinition<?> referencedType,
-            final TypeConstraints constraints) {
+    private void mergeConstraints(final TypeDefinition<?> referencedType, final TypeConstraints constraints) {
 
         if (referencedType instanceof DecimalTypeDefinition) {
-            constraints.addRanges(((DecimalTypeDefinition) referencedType)
-                    .getRangeStatements());
-            constraints
-                    .addFractionDigits(((DecimalTypeDefinition) referencedType)
-                            .getFractionDigits());
+            constraints.addRanges(((DecimalTypeDefinition) referencedType).getRangeStatements());
+            constraints.addFractionDigits(((DecimalTypeDefinition) referencedType).getFractionDigits());
         } else if (referencedType instanceof IntegerTypeDefinition) {
-            constraints.addRanges(((IntegerTypeDefinition) referencedType)
-                    .getRangeStatements());
+            constraints.addRanges(((IntegerTypeDefinition) referencedType).getRangeStatements());
         } else if (referencedType instanceof StringTypeDefinition) {
-            constraints.addPatterns(((StringTypeDefinition) referencedType)
-                    .getPatterns());
-            constraints.addLengths(((StringTypeDefinition) referencedType)
-                    .getLengthStatements());
+            constraints.addPatterns(((StringTypeDefinition) referencedType).getPatterns());
+            constraints.addLengths(((StringTypeDefinition) referencedType).getLengthStatements());
         } else if (referencedType instanceof BinaryTypeDefinition) {
-            constraints.addLengths(((BinaryTypeDefinition) referencedType)
-                    .getLengthConstraints());
+            constraints.addLengths(((BinaryTypeDefinition) referencedType).getLengthConstraints());
         }
     }
 
@@ -577,14 +514,11 @@ public final class YangParserImpl implements YangModelParser {
      * @param modules
      *            all available modules
      */
-    private void resolveAugments(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules) {
+    private void resolveAugments(final Map<String, TreeMap<Date, ModuleBuilder>> modules) {
         final List<ModuleBuilder> allModulesList = new ArrayList<ModuleBuilder>();
         final Set<ModuleBuilder> allModulesSet = new HashSet<ModuleBuilder>();
-        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules
-                .entrySet()) {
-            for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue()
-                    .entrySet()) {
+        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+            for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 allModulesList.add(inner.getValue());
                 allModulesSet.add(inner.getValue());
             }
@@ -595,19 +529,15 @@ public final class YangParserImpl implements YangModelParser {
             // try to resolve augments in module
             resolveAugment(modules, module);
             // while all augments are not resolved
-            final Iterator<ModuleBuilder> allModulesIterator = allModulesSet
-                    .iterator();
-            while (!(module.getAugmentsResolved() == module.getAugments()
-                    .size())) {
+            final Iterator<ModuleBuilder> allModulesIterator = allModulesSet.iterator();
+            while (!(module.getAugmentsResolved() == module.getAugments().size())) {
                 ModuleBuilder nextModule = null;
                 // try resolve other module augments
                 try {
                     nextModule = allModulesIterator.next();
                     resolveAugment(modules, nextModule);
                 } catch (NoSuchElementException e) {
-                    throw new YangParseException(
-                            "Failed to resolve augments in module '"
-                                    + module.getName() + "'.", e);
+                    throw new YangParseException("Failed to resolve augments in module '" + module.getName() + "'.", e);
                 }
                 // then try to resolve first module again
                 resolveAugment(modules, module);
@@ -622,16 +552,12 @@ public final class YangParserImpl implements YangModelParser {
      * @param module
      *            current module
      */
-    private void resolveAugment(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
+    private void resolveAugment(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         if (module.getAugmentsResolved() < module.getAugments().size()) {
-            for (AugmentationSchemaBuilder augmentBuilder : module
-                    .getAugments()) {
+            for (AugmentationSchemaBuilder augmentBuilder : module.getAugments()) {
 
                 if (!augmentBuilder.isResolved()) {
-                    final SchemaPath augmentTargetSchemaPath = augmentBuilder
-                            .getTargetPath();
+                    final SchemaPath augmentTargetSchemaPath = augmentBuilder.getTargetPath();
                     final List<QName> path = augmentTargetSchemaPath.getPath();
 
                     final QName qname = path.get(0);
@@ -641,13 +567,11 @@ public final class YangParserImpl implements YangModelParser {
                     }
 
                     DataSchemaNodeBuilder currentParent = null;
-                    final ModuleBuilder dependentModule = findDependentModule(
-                            modules, module, prefix, augmentBuilder.getLine());
-                    for (DataSchemaNodeBuilder child : dependentModule
-                            .getChildNodes()) {
+                    final ModuleBuilder dependentModule = findDependentModule(modules, module, prefix,
+                            augmentBuilder.getLine());
+                    for (DataSchemaNodeBuilder child : dependentModule.getChildNodes()) {
                         final QName childQName = child.getQName();
-                        if (childQName.getLocalName().equals(
-                                qname.getLocalName())) {
+                        if (childQName.getLocalName().equals(qname.getLocalName())) {
                             currentParent = child;
                             break;
                         }
@@ -660,11 +584,9 @@ public final class YangParserImpl implements YangModelParser {
                     for (int i = 1; i < path.size(); i++) {
                         final QName currentQName = path.get(i);
                         DataSchemaNodeBuilder newParent = null;
-                        for (DataSchemaNodeBuilder child : ((DataNodeContainerBuilder) currentParent)
-                                .getChildNodes()) {
+                        for (DataSchemaNodeBuilder child : ((DataNodeContainerBuilder) currentParent).getChildNodes()) {
                             final QName childQName = child.getQName();
-                            if (childQName.getLocalName().equals(
-                                    currentQName.getLocalName())) {
+                            if (childQName.getLocalName().equals(currentQName.getLocalName())) {
                                 newParent = child;
                                 break;
                             }
@@ -677,23 +599,17 @@ public final class YangParserImpl implements YangModelParser {
                     }
 
                     final QName currentQName = currentParent.getQName();
-                    final QName lastAugmentPathElement = path
-                            .get(path.size() - 1);
-                    if (currentQName.getLocalName().equals(
-                            lastAugmentPathElement.getLocalName())) {
+                    final QName lastAugmentPathElement = path.get(path.size() - 1);
+                    if (currentQName.getLocalName().equals(lastAugmentPathElement.getLocalName())) {
 
                         if (currentParent instanceof ChoiceBuilder) {
-                            ParserUtils.fillAugmentTarget(augmentBuilder,
-                                    (ChoiceBuilder) currentParent);
+                            ParserUtils.fillAugmentTarget(augmentBuilder, (ChoiceBuilder) currentParent);
                         } else {
-                            ParserUtils.fillAugmentTarget(augmentBuilder,
-                                    (DataNodeContainerBuilder) currentParent);
+                            ParserUtils.fillAugmentTarget(augmentBuilder, (DataNodeContainerBuilder) currentParent);
                         }
-                        ((AugmentationTargetBuilder) currentParent)
-                                .addAugmentation(augmentBuilder);
+                        ((AugmentationTargetBuilder) currentParent).addAugmentation(augmentBuilder);
                         SchemaPath oldPath = currentParent.getPath();
-                        augmentBuilder.setTargetPath(new SchemaPath(oldPath
-                                .getPath(), oldPath.isAbsolute()));
+                        augmentBuilder.setTargetPath(new SchemaPath(oldPath.getPath(), oldPath.isAbsolute()));
                         augmentBuilder.setResolved(true);
                         module.augmentResolved();
                     }
@@ -712,11 +628,8 @@ public final class YangParserImpl implements YangModelParser {
      * @param module
      *            module being resolved
      */
-    private void resolveIdentities(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
-        final Set<IdentitySchemaNodeBuilder> identities = module
-                .getIdentities();
+    private void resolveIdentities(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+        final Set<IdentitySchemaNodeBuilder> identities = module.getIdentities();
         for (IdentitySchemaNodeBuilder identity : identities) {
             final String baseIdentityName = identity.getBaseIdentityName();
             if (baseIdentityName != null) {
@@ -730,14 +643,12 @@ public final class YangParserImpl implements YangModelParser {
                     baseIdentityPrefix = module.getPrefix();
                     baseIdentityLocalName = baseIdentityName;
                 }
-                final ModuleBuilder dependentModule = findDependentModule(
-                        modules, module, baseIdentityPrefix, identity.getLine());
+                final ModuleBuilder dependentModule = findDependentModule(modules, module, baseIdentityPrefix,
+                        identity.getLine());
 
-                final Set<IdentitySchemaNodeBuilder> dependentModuleIdentities = dependentModule
-                        .getIdentities();
+                final Set<IdentitySchemaNodeBuilder> dependentModuleIdentities = dependentModule.getIdentities();
                 for (IdentitySchemaNodeBuilder idBuilder : dependentModuleIdentities) {
-                    if (idBuilder.getQName().getLocalName()
-                            .equals(baseIdentityLocalName)) {
+                    if (idBuilder.getQName().getLocalName().equals(baseIdentityLocalName)) {
                         identity.setBaseIdentity(idBuilder);
                     }
                 }
@@ -754,13 +665,9 @@ public final class YangParserImpl implements YangModelParser {
      * @param module
      *            module being resolved
      */
-    private void resolveUsesRefines(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
-        final Map<List<String>, UsesNodeBuilder> moduleUses = module
-                .getUsesNodes();
-        for (Map.Entry<List<String>, UsesNodeBuilder> entry : moduleUses
-                .entrySet()) {
+    private void resolveUsesRefines(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+        final Map<List<String>, UsesNodeBuilder> moduleUses = module.getUsesNodes();
+        for (Map.Entry<List<String>, UsesNodeBuilder> entry : moduleUses.entrySet()) {
             final UsesNodeBuilder usesNode = entry.getValue();
             final int line = usesNode.getLine();
 
@@ -768,8 +675,7 @@ public final class YangParserImpl implements YangModelParser {
             usesNode.setGroupingPath(targetGrouping.getPath());
 
             for (RefineHolder refine : usesNode.getRefines()) {
-                SchemaNodeBuilder refineTarget = getRefineNodeBuilderCopy(
-                        targetGrouping, refine, modules, module);
+                SchemaNodeBuilder refineTarget = getRefineNodeBuilderCopy(targetGrouping, refine, modules, module);
                 ParserUtils.checkRefine(refineTarget, refine);
                 ParserUtils.refineDefault(refineTarget, refine, line);
                 if (refineTarget instanceof LeafSchemaNodeBuilder) {
@@ -805,18 +711,16 @@ public final class YangParserImpl implements YangModelParser {
         }
     }
 
-    private GroupingBuilder getTargetGrouping(
-            final UsesNodeBuilder usesBuilder,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
+    private GroupingBuilder getTargetGrouping(final UsesNodeBuilder usesBuilder,
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         final int line = usesBuilder.getLine();
         String groupingString = usesBuilder.getGroupingName();
         String groupingPrefix;
         String groupingName;
 
-        if(groupingString.contains(":")) {
+        if (groupingString.contains(":")) {
             String[] splitted = groupingString.split(":");
-            if(splitted.length != 2 || groupingString.contains("/")) {
+            if (splitted.length != 2 || groupingString.contains("/")) {
                 throw new YangParseException(module.getName(), line, "Invalid name of target grouping");
             }
             groupingPrefix = splitted[0];
@@ -827,13 +731,12 @@ public final class YangParserImpl implements YangModelParser {
         }
 
         ModuleBuilder dependentModule = null;
-        if(groupingPrefix.equals(module.getPrefix())) {
+        if (groupingPrefix.equals(module.getPrefix())) {
             dependentModule = module;
         } else {
             dependentModule = findDependentModule(modules, module, groupingPrefix, line);
         }
 
-
         List<QName> path = usesBuilder.getPath().getPath();
         GroupingBuilder result = null;
         Set<GroupingBuilder> groupings = dependentModule.getModuleGroupings();
@@ -867,12 +770,10 @@ public final class YangParserImpl implements YangModelParser {
         if (result != null) {
             return result;
         }
-        throw new YangParseException(module.getName(), line,
-                "Referenced grouping '" + groupingName + "' not found.");
+        throw new YangParseException(module.getName(), line, "Referenced grouping '" + groupingName + "' not found.");
     }
 
-    private GroupingBuilder findGrouping(Set<GroupingBuilder> groupings,
-            String name) {
+    private GroupingBuilder findGrouping(Set<GroupingBuilder> groupings, String name) {
         for (GroupingBuilder grouping : groupings) {
             if (grouping.getQName().getLocalName().equals(name)) {
                 return grouping;
@@ -900,40 +801,29 @@ public final class YangParserImpl implements YangModelParser {
      * @return copy of node to be refined if it is present in grouping, null
      *         otherwise
      */
-    private SchemaNodeBuilder getRefineNodeBuilderCopy(
-            final GroupingBuilder targetGrouping, final RefineHolder refine,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
+    private SchemaNodeBuilder getRefineNodeBuilderCopy(final GroupingBuilder targetGrouping, final RefineHolder refine,
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         Builder result = null;
-        final Builder lookedUpBuilder = findRefineTargetBuilder(targetGrouping,
-                refine, modules, module);
+        final Builder lookedUpBuilder = findRefineTargetBuilder(targetGrouping, refine, modules, module);
         if (lookedUpBuilder instanceof LeafSchemaNodeBuilder) {
-            result = ParserUtils
-                    .copyLeafBuilder((LeafSchemaNodeBuilder) lookedUpBuilder);
+            result = ParserUtils.copyLeafBuilder((LeafSchemaNodeBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof ContainerSchemaNodeBuilder) {
-            result = ParserUtils
-                    .copyContainerBuilder((ContainerSchemaNodeBuilder) lookedUpBuilder);
+            result = ParserUtils.copyContainerBuilder((ContainerSchemaNodeBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof ListSchemaNodeBuilder) {
-            result = ParserUtils
-                    .copyListBuilder((ListSchemaNodeBuilder) lookedUpBuilder);
+            result = ParserUtils.copyListBuilder((ListSchemaNodeBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof LeafListSchemaNodeBuilder) {
-            result = ParserUtils
-                    .copyLeafListBuilder((LeafListSchemaNodeBuilder) lookedUpBuilder);
+            result = ParserUtils.copyLeafListBuilder((LeafListSchemaNodeBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof ChoiceBuilder) {
-            result = ParserUtils
-                    .copyChoiceBuilder((ChoiceBuilder) lookedUpBuilder);
+            result = ParserUtils.copyChoiceBuilder((ChoiceBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof AnyXmlBuilder) {
-            result = ParserUtils
-                    .copyAnyXmlBuilder((AnyXmlBuilder) lookedUpBuilder);
+            result = ParserUtils.copyAnyXmlBuilder((AnyXmlBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof GroupingBuilder) {
-            result = ParserUtils
-                    .copyGroupingBuilder((GroupingBuilder) lookedUpBuilder);
+            result = ParserUtils.copyGroupingBuilder((GroupingBuilder) lookedUpBuilder);
         } else if (lookedUpBuilder instanceof TypeDefinitionBuilder) {
-            result = ParserUtils
-                    .copyTypedefBuilder((TypeDefinitionBuilderImpl) lookedUpBuilder);
+            result = ParserUtils.copyTypedefBuilder((TypeDefinitionBuilderImpl) lookedUpBuilder);
         } else {
-            throw new YangParseException(module.getName(), refine.getLine(),
-                    "Target '" + refine.getName() + "' can not be refined");
+            throw new YangParseException(module.getName(), refine.getLine(), "Target '" + refine.getName()
+                    + "' can not be refined");
         }
         return (SchemaNodeBuilder) result;
     }
@@ -952,10 +842,8 @@ public final class YangParserImpl implements YangModelParser {
      * @return Builder object of refine node if it is present in grouping, null
      *         otherwise
      */
-    private Builder findRefineTargetBuilder(final GroupingBuilder builder,
-            final RefineHolder refine,
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
+    private Builder findRefineTargetBuilder(final GroupingBuilder builder, final RefineHolder refine,
+            final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         final String refineNodeName = refine.getName();
         Builder result = builder.getChildNode(refineNodeName);
         if (result == null) {
@@ -979,49 +867,38 @@ public final class YangParserImpl implements YangModelParser {
         return result;
     }
 
-    private QName findFullQName(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module, final IdentityrefTypeBuilder idref) {
+    private QName findFullQName(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module,
+            final IdentityrefTypeBuilder idref) {
         QName result = null;
         String baseString = idref.getBaseString();
         if (baseString.contains(":")) {
             String[] splittedBase = baseString.split(":");
             if (splittedBase.length > 2) {
-                throw new YangParseException(module.getName(), idref.getLine(),
-                        "Failed to parse identityref base: " + baseString);
+                throw new YangParseException(module.getName(), idref.getLine(), "Failed to parse identityref base: "
+                        + baseString);
             }
             String prefix = splittedBase[0];
             String name = splittedBase[1];
-            ModuleBuilder dependentModule = findDependentModule(modules,
-                    module, prefix, idref.getLine());
-            result = new QName(dependentModule.getNamespace(),
-                    dependentModule.getRevision(), prefix, name);
+            ModuleBuilder dependentModule = findDependentModule(modules, module, prefix, idref.getLine());
+            result = new QName(dependentModule.getNamespace(), dependentModule.getRevision(), prefix, name);
         } else {
-            result = new QName(module.getNamespace(), module.getRevision(),
-                    module.getPrefix(), baseString);
+            result = new QName(module.getNamespace(), module.getRevision(), module.getPrefix(), baseString);
         }
         return result;
     }
 
-    private void resolveUnknownNodes(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module) {
+    private void resolveUnknownNodes(final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         for (UnknownSchemaNodeBuilder usnb : module.getUnknownNodes()) {
             QName nodeType = usnb.getNodeType();
-            if (nodeType.getNamespace() == null
-                    || nodeType.getRevision() == null) {
+            if (nodeType.getNamespace() == null || nodeType.getRevision() == null) {
                 try {
-                    ModuleBuilder dependentModule = findDependentModule(
-                            modules, module, nodeType.getPrefix(),
+                    ModuleBuilder dependentModule = findDependentModule(modules, module, nodeType.getPrefix(),
                             usnb.getLine());
-                    QName newNodeType = new QName(
-                            dependentModule.getNamespace(),
-                            dependentModule.getRevision(),
+                    QName newNodeType = new QName(dependentModule.getNamespace(), dependentModule.getRevision(),
                             nodeType.getPrefix(), nodeType.getLocalName());
                     usnb.setNodeType(newNodeType);
                 } catch (YangParseException e) {
-                    logger.debug(module.getName(), usnb.getLine(),
-                            "Failed to find unknown node type: " + nodeType);
+                    logger.debug(module.getName(), usnb.getLine(), "Failed to find unknown node type: " + nodeType);
                 }
             }
         }
@@ -1040,8 +917,7 @@ public final class YangParserImpl implements YangModelParser {
      *            current line in yang model
      * @return
      */
-    private ModuleBuilder findDependentModule(
-            final Map<String, TreeMap<Date, ModuleBuilder>> modules,
+    private ModuleBuilder findDependentModule(final Map<String, TreeMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder module, final String prefix, final int line) {
         ModuleBuilder dependentModule = null;
         Date dependentModuleRevision = null;
@@ -1049,37 +925,28 @@ public final class YangParserImpl implements YangModelParser {
         if (prefix.equals(module.getPrefix())) {
             dependentModule = module;
         } else {
-            final ModuleImport dependentModuleImport = ParserUtils
-                    .getModuleImport(module, prefix);
+            final ModuleImport dependentModuleImport = ParserUtils.getModuleImport(module, prefix);
             if (dependentModuleImport == null) {
-                throw new YangParseException(module.getName(), line,
-                        "No import found with prefix '" + prefix + "'.");
+                throw new YangParseException(module.getName(), line, "No import found with prefix '" + prefix + "'.");
             }
-            final String dependentModuleName = dependentModuleImport
-                    .getModuleName();
+            final String dependentModuleName = dependentModuleImport.getModuleName();
             dependentModuleRevision = dependentModuleImport.getRevision();
 
-            final TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules
-                    .get(dependentModuleName);
+            final TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules.get(dependentModuleName);
             if (moduleBuildersByRevision == null) {
-                throw new YangParseException(module.getName(), line,
-                        "Failed to find dependent module '"
-                                + dependentModuleName + "'.");
+                throw new YangParseException(module.getName(), line, "Failed to find dependent module '"
+                        + dependentModuleName + "'.");
             }
             if (dependentModuleRevision == null) {
-                dependentModule = moduleBuildersByRevision.lastEntry()
-                        .getValue();
+                dependentModule = moduleBuildersByRevision.lastEntry().getValue();
             } else {
-                dependentModule = moduleBuildersByRevision
-                        .get(dependentModuleRevision);
+                dependentModule = moduleBuildersByRevision.get(dependentModuleRevision);
             }
         }
 
         if (dependentModule == null) {
-            throw new YangParseException(module.getName(), line,
-                    "Failed to find dependent module with prefix '" + prefix
-                            + "' and revision '" + dependentModuleRevision
-                            + "'.");
+            throw new YangParseException(module.getName(), line, "Failed to find dependent module with prefix '"
+                    + prefix + "' and revision '" + dependentModuleRevision + "'.");
         }
         return dependentModule;
     }
index 1c01cd4..5bd46d1 100644 (file)
@@ -81,19 +81,15 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public final class YangParserListenerImpl extends YangParserBaseListener {
-
-    private static final Logger logger = LoggerFactory
-            .getLogger(YangParserListenerImpl.class);
+    private static final Logger logger = LoggerFactory.getLogger(YangParserListenerImpl.class);
 
     private ModuleBuilder moduleBuilder;
-
     private String moduleName;
     private URI namespace;
     private String yangModelPrefix;
     private Date revision = new Date(0L);
 
-    public final static DateFormat simpleDateFormat = new SimpleDateFormat(
-            "yyyy-MM-dd");
+    public final static DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
     private final Stack<String> actualPath = new Stack<String>();
 
     @Override
@@ -173,8 +169,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     }
 
     @Override
-    public void exitSubmodule_header_stmts(
-            YangParser.Submodule_header_stmtsContext ctx) {
+    public void exitSubmodule_header_stmts(YangParser.Submodule_header_stmtsContext ctx) {
         final String submodule = actualPath.pop();
         logger.debug("exiting submodule " + submodule);
     }
@@ -206,8 +201,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 }
             }
         } catch (ParseException e) {
-            final String message = "Failed to parse revision string: "
-                    + revisionDateStr;
+            final String message = "Failed to parse revision string: " + revisionDateStr;
             logger.warn(message);
         }
     }
@@ -228,8 +222,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 try {
                     importRevision = simpleDateFormat.parse(importRevisionStr);
                 } catch (ParseException e) {
-                    logger.warn("Failed to parse import revision-date: "
-                            + importRevisionStr);
+                    logger.warn("Failed to parse import revision-date: " + importRevisionStr);
                 }
             }
         }
@@ -239,8 +232,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {
         final String augmentPath = stringFromNode(ctx);
-        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(
-                augmentPath, actualPath, ctx.getStart().getLine());
+        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(augmentPath, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(augmentPath);
 
@@ -273,8 +265,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     public void enterExtension_stmt(YangParser.Extension_stmtContext ctx) {
         final String extName = stringFromNode(ctx);
         QName qname = new QName(namespace, revision, yangModelPrefix, extName);
-        ExtensionBuilder builder = moduleBuilder.addExtension(qname, ctx
-                .getStart().getLine());
+        ExtensionBuilder builder = moduleBuilder.addExtension(qname, ctx.getStart().getLine());
         parseSchemaNodeArgs(ctx, builder);
 
         String argument = null;
@@ -294,15 +285,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterTypedef_stmt(YangParser.Typedef_stmtContext ctx) {
         final String typedefName = stringFromNode(ctx);
-        QName typedefQName = new QName(namespace, revision, yangModelPrefix,
-                typedefName);
-        TypeDefinitionBuilder builder = moduleBuilder.addTypedef(typedefQName,
-                actualPath, ctx.getStart().getLine());
+        QName typedefQName = new QName(namespace, revision, yangModelPrefix, typedefName);
+        TypeDefinitionBuilder builder = moduleBuilder.addTypedef(typedefQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(typedefName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         builder.setUnits(parseUnits(ctx));
     }
@@ -335,35 +323,27 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 // check for types which must have body
                 checkMissingBody(typeName, moduleName, line);
                 // if there are no constraints, just grab default base yang type
-                type = YangTypesConverter.javaTypeForBaseYangType(actualPath,
-                        namespace, revision, typeName);
+                type = YangTypesConverter.javaTypeForBaseYangType(actualPath, namespace, revision, typeName);
                 moduleBuilder.setType(type, actualPath);
             } else {
                 if ("union".equals(typeName)) {
                     List<String> typePath = new ArrayList<String>(actualPath);
                     typePath.add(typeName);
-                    SchemaPath p = createActualSchemaPath(typePath, namespace,
-                            revision, yangModelPrefix);
-                    UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(
-                            actualPath, namespace, revision, line);
+                    SchemaPath p = createActualSchemaPath(typePath, namespace, revision, yangModelPrefix);
+                    UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(actualPath, namespace, revision, line);
                     moduleBuilder.enterNode(unionBuilder);
                     unionBuilder.setPath(p);
                 } else if ("identityref".equals(typeName)) {
-                    SchemaPath path = createActualSchemaPath(actualPath,
-                            namespace, revision, yangModelPrefix);
-                    moduleBuilder.addIdentityrefType(
-                            getIdentityrefBase(typeBody), actualPath, path,
-                            line);
+                    SchemaPath path = createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix);
+                    moduleBuilder.addIdentityrefType(getIdentityrefBase(typeBody), actualPath, path, line);
                 } else {
-                    type = parseTypeBody(typeName, typeBody, actualPath,
-                            namespace, revision, yangModelPrefix,
-                            moduleBuilder.getActualNode());
+                    type = parseTypeBody(moduleName, typeName, typeBody, actualPath, namespace, revision,
+                            yangModelPrefix, moduleBuilder.getActualNode());
                     moduleBuilder.setType(type, actualPath);
                 }
             }
         } else {
-            type = parseUnknownTypeBody(typeQName, typeBody, actualPath,
-                    namespace, revision, yangModelPrefix,
+            type = parseUnknownTypeBody(typeQName, typeBody, actualPath, namespace, revision, yangModelPrefix,
                     moduleBuilder.getActualNode(), moduleBuilder);
             // mark parent node of this type statement as dirty
             moduleBuilder.addDirtyNode(actualPath);
@@ -385,8 +365,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 typeQName = new QName(null, null, prefix, name);
             }
         } else {
-            typeQName = new QName(namespace, revision, yangModelPrefix,
-                    typeName);
+            typeQName = new QName(namespace, revision, yangModelPrefix, typeName);
         }
         return typeQName;
     }
@@ -405,14 +384,11 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterGrouping_stmt(YangParser.Grouping_stmtContext ctx) {
         final String groupName = stringFromNode(ctx);
-        QName groupQName = new QName(namespace, revision, yangModelPrefix,
-                groupName);
-        GroupingBuilder builder = moduleBuilder.addGrouping(groupQName,
-                actualPath, ctx.getStart().getLine());
+        QName groupQName = new QName(namespace, revision, yangModelPrefix, groupName);
+        GroupingBuilder builder = moduleBuilder.addGrouping(groupQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(groupName);
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
     }
 
@@ -426,15 +402,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterContainer_stmt(Container_stmtContext ctx) {
         final String containerName = stringFromNode(ctx);
-        QName containerQName = new QName(namespace, revision, yangModelPrefix,
-                containerName);
-        ContainerSchemaNodeBuilder builder = moduleBuilder.addContainerNode(
-                containerQName, actualPath, ctx.getStart().getLine());
+        QName containerQName = new QName(namespace, revision, yangModelPrefix, containerName);
+        ContainerSchemaNodeBuilder builder = moduleBuilder.addContainerNode(containerQName, actualPath, ctx.getStart()
+                .getLine());
         moduleBuilder.enterNode(builder);
         updatePath(containerName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
 
@@ -457,15 +431,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterLeaf_stmt(Leaf_stmtContext ctx) {
         final String leafName = stringFromNode(ctx);
-        QName leafQName = new QName(namespace, revision, yangModelPrefix,
-                leafName);
-        LeafSchemaNodeBuilder builder = moduleBuilder.addLeafNode(leafQName,
-                actualPath, ctx.getStart().getLine());
+        QName leafQName = new QName(namespace, revision, yangModelPrefix, leafName);
+        LeafSchemaNodeBuilder builder = moduleBuilder.addLeafNode(leafQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(leafName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
 
@@ -493,13 +464,11 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {
         final String groupingPathStr = stringFromNode(ctx);
-        UsesNodeBuilder builder = moduleBuilder.addUsesNode(groupingPathStr,
-                actualPath, ctx.getStart().getLine());
+        UsesNodeBuilder builder = moduleBuilder.addUsesNode(groupingPathStr, actualPath, ctx.getStart().getLine());
 
         moduleBuilder.enterNode(builder);
         updatePath(groupingPathStr);
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
     }
 
     @Override
@@ -528,15 +497,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterLeaf_list_stmt(Leaf_list_stmtContext ctx) {
         final String leafListName = stringFromNode(ctx);
-        QName leafListQName = new QName(namespace, revision, yangModelPrefix,
-                leafListName);
-        LeafListSchemaNodeBuilder builder = moduleBuilder.addLeafListNode(
-                leafListQName, actualPath, ctx.getStart().getLine());
+        QName leafListQName = new QName(namespace, revision, yangModelPrefix, leafListName);
+        LeafListSchemaNodeBuilder builder = moduleBuilder.addLeafListNode(leafListQName, actualPath, ctx.getStart()
+                .getLine());
         moduleBuilder.enterNode(builder);
         updatePath(leafListName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
 
@@ -561,15 +528,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterList_stmt(List_stmtContext ctx) {
         final String containerName = stringFromNode(ctx);
-        QName containerQName = new QName(namespace, revision, yangModelPrefix,
-                containerName);
-        ListSchemaNodeBuilder builder = moduleBuilder.addListNode(
-                containerQName, actualPath, ctx.getStart().getLine());
+        QName containerQName = new QName(namespace, revision, yangModelPrefix, containerName);
+        ListSchemaNodeBuilder builder = moduleBuilder.addListNode(containerQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(containerName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
 
@@ -582,8 +546,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 builder.setUserOrdered(userOrdered);
             } else if (childNode instanceof Key_stmtContext) {
                 keyDefinition = stringFromNode(childNode);
-                List<QName> key = createListKey(keyDefinition, namespace,
-                        revision, yangModelPrefix);
+                List<QName> key = createListKey(keyDefinition, namespace, revision, yangModelPrefix);
                 builder.setKeyDefinition(key);
             }
         }
@@ -599,15 +562,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterAnyxml_stmt(YangParser.Anyxml_stmtContext ctx) {
         final String anyXmlName = stringFromNode(ctx);
-        QName anyXmlQName = new QName(namespace, revision, yangModelPrefix,
-                anyXmlName);
-        AnyXmlBuilder builder = moduleBuilder.addAnyXml(anyXmlQName,
-                actualPath, ctx.getStart().getLine());
+        QName anyXmlQName = new QName(namespace, revision, yangModelPrefix, anyXmlName);
+        AnyXmlBuilder builder = moduleBuilder.addAnyXml(anyXmlQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(anyXmlName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
     }
@@ -622,15 +582,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterChoice_stmt(YangParser.Choice_stmtContext ctx) {
         final String choiceName = stringFromNode(ctx);
-        QName choiceQName = new QName(namespace, revision, yangModelPrefix,
-                choiceName);
-        ChoiceBuilder builder = moduleBuilder.addChoice(choiceQName,
-                actualPath, ctx.getStart().getLine());
+        QName choiceQName = new QName(namespace, revision, yangModelPrefix, choiceName);
+        ChoiceBuilder builder = moduleBuilder.addChoice(choiceQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
 
         updatePath(choiceName);
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
 
@@ -655,15 +612,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterCase_stmt(YangParser.Case_stmtContext ctx) {
         final String caseName = stringFromNode(ctx);
-        QName choiceQName = new QName(namespace, revision, yangModelPrefix,
-                caseName);
-        ChoiceCaseBuilder builder = moduleBuilder.addCase(choiceQName,
-                actualPath, ctx.getStart().getLine());
+        QName choiceQName = new QName(namespace, revision, yangModelPrefix, caseName);
+        ChoiceCaseBuilder builder = moduleBuilder.addCase(choiceQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
 
         updatePath(caseName);
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
     }
@@ -678,15 +632,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterNotification_stmt(YangParser.Notification_stmtContext ctx) {
         final String notificationName = stringFromNode(ctx);
-        QName notificationQName = new QName(namespace, revision,
-                yangModelPrefix, notificationName);
-        NotificationBuilder builder = moduleBuilder.addNotification(
-                notificationQName, actualPath, ctx.getStart().getLine());
+        QName notificationQName = new QName(namespace, revision, yangModelPrefix, notificationName);
+        NotificationBuilder builder = moduleBuilder.addNotification(notificationQName, actualPath, ctx.getStart()
+                .getLine());
         moduleBuilder.enterNode(builder);
         updatePath(notificationName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
     }
 
@@ -706,11 +658,9 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String nodeTypeStr = ctx.getChild(0).getText();
         final String[] splittedElement = nodeTypeStr.split(":");
         if (splittedElement.length == 1) {
-            nodeType = new QName(null, null, yangModelPrefix,
-                    splittedElement[0]);
+            nodeType = new QName(null, null, yangModelPrefix, splittedElement[0]);
         } else {
-            nodeType = new QName(null, null, splittedElement[0],
-                    splittedElement[1]);
+            nodeType = new QName(null, null, splittedElement[0], splittedElement[1]);
         }
 
         QName qname;
@@ -719,21 +669,18 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
             if (splittedName.length == 2) {
                 qname = new QName(null, null, splittedName[0], splittedName[1]);
             } else {
-                qname = new QName(namespace, revision, yangModelPrefix,
-                        splittedName[0]);
+                qname = new QName(namespace, revision, yangModelPrefix, splittedName[0]);
             }
         } else {
-            qname = new QName(namespace, revision, yangModelPrefix,
-                    nodeParameter);
+            qname = new QName(namespace, revision, yangModelPrefix, nodeParameter);
         }
 
-        UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(
-                qname, actualPath, ctx.getStart().getLine());
+        UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(qname, actualPath, ctx.getStart()
+                .getLine());
         builder.setNodeType(nodeType);
         builder.setNodeParameter(nodeParameter);
         updatePath(nodeParameter);
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         moduleBuilder.enterNode(builder);
     }
@@ -748,15 +695,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterRpc_stmt(YangParser.Rpc_stmtContext ctx) {
         final String rpcName = stringFromNode(ctx);
-        QName rpcQName = new QName(namespace, revision, yangModelPrefix,
-                rpcName);
-        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,
-                actualPath, ctx.getStart().getLine());
+        QName rpcQName = new QName(namespace, revision, yangModelPrefix, rpcName);
+        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(rpcBuilder);
         updatePath(rpcName);
 
-        rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace,
-                revision, yangModelPrefix));
+        rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, rpcBuilder);
     }
 
@@ -771,13 +715,11 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     public void enterInput_stmt(YangParser.Input_stmtContext ctx) {
         final String input = "input";
         QName rpcQName = new QName(namespace, revision, yangModelPrefix, input);
-        ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcInput(
-                rpcQName, ctx.getStart().getLine());
+        ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcInput(rpcQName, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(input);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
     }
@@ -793,13 +735,11 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     public void enterOutput_stmt(YangParser.Output_stmtContext ctx) {
         final String output = "output";
         QName rpcQName = new QName(namespace, revision, yangModelPrefix, output);
-        ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcOutput(
-                rpcQName, ctx.getStart().getLine());
+        ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcOutput(rpcQName, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(output);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
     }
@@ -814,15 +754,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterFeature_stmt(YangParser.Feature_stmtContext ctx) {
         final String featureName = stringFromNode(ctx);
-        QName featureQName = new QName(namespace, revision, yangModelPrefix,
-                featureName);
-        FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,
-                actualPath, ctx.getStart().getLine());
+        QName featureQName = new QName(namespace, revision, yangModelPrefix, featureName);
+        FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(featureBuilder);
         updatePath(featureName);
 
-        featureBuilder.setPath(createActualSchemaPath(actualPath, namespace,
-                revision, yangModelPrefix));
+        featureBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, featureBuilder);
     }
 
@@ -838,8 +775,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String targetPath = stringFromNode(ctx);
         String reference = null;
         String deviate = null;
-        DeviationBuilder builder = moduleBuilder.addDeviation(targetPath,
-                actualPath, ctx.getStart().getLine());
+        DeviationBuilder builder = moduleBuilder.addDeviation(targetPath, actualPath, ctx.getStart().getLine());
         moduleBuilder.enterNode(builder);
         updatePath(targetPath);
 
@@ -871,22 +807,19 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterConfig_stmt(YangParser.Config_stmtContext ctx) {
         boolean configuration = parseConfig(ctx);
-        moduleBuilder.addConfiguration(configuration, actualPath, ctx
-                .getStart().getLine());
+        moduleBuilder.addConfiguration(configuration, actualPath, ctx.getStart().getLine());
     }
 
     @Override
     public void enterIdentity_stmt(YangParser.Identity_stmtContext ctx) {
         final String identityName = stringFromNode(ctx);
-        final QName identityQName = new QName(namespace, revision,
-                yangModelPrefix, identityName);
-        IdentitySchemaNodeBuilder builder = moduleBuilder.addIdentity(
-                identityQName, actualPath, ctx.getStart().getLine());
+        final QName identityQName = new QName(namespace, revision, yangModelPrefix, identityName);
+        IdentitySchemaNodeBuilder builder = moduleBuilder.addIdentity(identityQName, actualPath, ctx.getStart()
+                .getLine());
         moduleBuilder.enterNode(builder);
         updatePath(identityName);
 
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
         parseSchemaNodeArgs(ctx, builder);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
index 670c1d5..17307b4 100644 (file)
@@ -20,17 +20,24 @@ import org.opendaylight.controller.yang.model.util.BaseConstraints;
  * Holder object for holding YANG type constraints.
  */
 public final class TypeConstraints {
+    private final String moduleName;
+    private final int line;
     private final List<List<RangeConstraint>> ranges = new ArrayList<List<RangeConstraint>>();
     private final List<List<LengthConstraint>> lengths = new ArrayList<List<LengthConstraint>>();
     private final List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();
     private final List<Integer> fractionDigits = new ArrayList<Integer>();
 
+    public TypeConstraints(final String moduleName, final int line) {
+        this.moduleName = moduleName;
+        this.line = line;
+    }
+
     List<List<RangeConstraint>> getAllRanges() {
         return ranges;
     }
 
     public List<RangeConstraint> getRange() {
-        if (ranges.isEmpty()) {
+        if (ranges.size() < 2) {
             return Collections.emptyList();
         }
 
@@ -40,8 +47,10 @@ public final class TypeConstraints {
         Number min = firstRange.getMin();
         Number max = lastRange.getMax();
 
-        if (!(min instanceof UnknownBoundaryNumber)
-                && !(max instanceof UnknownBoundaryNumber)) {
+        if (!(min instanceof UnknownBoundaryNumber) && !(max instanceof UnknownBoundaryNumber)) {
+            if (ranges.size() > 1) {
+                validateRange(resolved);
+            }
             return resolved;
         }
 
@@ -52,28 +61,28 @@ public final class TypeConstraints {
             if (max instanceof UnknownBoundaryNumber) {
                 max = resolveMaxRange(max);
             }
-            firstRange = BaseConstraints.rangeConstraint(min, max,
-                    firstRange.getDescription(), firstRange.getReference());
+            firstRange = BaseConstraints.rangeConstraint(min, max, firstRange.getDescription(),
+                    firstRange.getReference());
             resolved.set(0, firstRange);
-            lastRange = BaseConstraints.rangeConstraint(min, max,
-                    lastRange.getDescription(), lastRange.getReference());
+            lastRange = BaseConstraints.rangeConstraint(min, max, lastRange.getDescription(), lastRange.getReference());
             resolved.set(resolved.size() - 1, lastRange);
         } else {
             if (min instanceof UnknownBoundaryNumber) {
                 min = resolveMinRange(min);
-                firstRange = BaseConstraints.rangeConstraint(min,
-                        firstRange.getMax(), firstRange.getDescription(),
+                firstRange = BaseConstraints.rangeConstraint(min, firstRange.getMax(), firstRange.getDescription(),
                         firstRange.getReference());
                 resolved.set(0, firstRange);
             }
             if (max instanceof UnknownBoundaryNumber) {
                 max = resolveMaxRange(max);
-                lastRange = BaseConstraints.rangeConstraint(lastRange.getMin(),
-                        max, lastRange.getDescription(),
+                lastRange = BaseConstraints.rangeConstraint(lastRange.getMin(), max, lastRange.getDescription(),
                         lastRange.getReference());
                 resolved.set(resolved.size() - 1, lastRange);
             }
         }
+        if (this.ranges.size() > 1) {
+            validateRange(resolved);
+        }
         return resolved;
     }
 
@@ -108,7 +117,7 @@ public final class TypeConstraints {
     }
 
     public List<LengthConstraint> getLength() {
-        if (lengths.isEmpty()) {
+        if (lengths.size() < 2) {
             return Collections.emptyList();
         }
 
@@ -118,8 +127,10 @@ public final class TypeConstraints {
         Number min = firstLength.getMin();
         Number max = lastLength.getMax();
 
-        if (!(min instanceof UnknownBoundaryNumber)
-                && !(max instanceof UnknownBoundaryNumber)) {
+        if (!(min instanceof UnknownBoundaryNumber) && !(max instanceof UnknownBoundaryNumber)) {
+            if (lengths.size() > 1) {
+                validateLength(resolved);
+            }
             return resolved;
         }
 
@@ -130,28 +141,30 @@ public final class TypeConstraints {
             if (max instanceof UnknownBoundaryNumber) {
                 max = resolveMaxLength(max);
             }
-            firstLength = BaseConstraints.lengthConstraint(min, max,
-                    firstLength.getDescription(), firstLength.getReference());
+            firstLength = BaseConstraints.lengthConstraint(min, max, firstLength.getDescription(),
+                    firstLength.getReference());
             resolved.set(0, firstLength);
-            lastLength = BaseConstraints.lengthConstraint(min, max,
-                    lastLength.getDescription(), lastLength.getReference());
+            lastLength = BaseConstraints.lengthConstraint(min, max, lastLength.getDescription(),
+                    lastLength.getReference());
             resolved.set(resolved.size() - 1, lastLength);
         } else {
             if (min instanceof UnknownBoundaryNumber) {
                 min = resolveMinLength(min);
-                firstLength = BaseConstraints.lengthConstraint(min,
-                        firstLength.getMax(), firstLength.getDescription(),
+                firstLength = BaseConstraints.lengthConstraint(min, firstLength.getMax(), firstLength.getDescription(),
                         firstLength.getReference());
                 resolved.set(0, firstLength);
             }
             if (max instanceof UnknownBoundaryNumber) {
                 max = resolveMaxLength(max);
-                lastLength = BaseConstraints.lengthConstraint(
-                        lastLength.getMin(), max, lastLength.getDescription(),
+                lastLength = BaseConstraints.lengthConstraint(lastLength.getMin(), max, lastLength.getDescription(),
                         lastLength.getReference());
                 resolved.set(resolved.size() - 1, lastLength);
             }
         }
+
+        if (lengths.size() > 1) {
+            validateLength(resolved);
+        }
         return resolved;
     }
 
@@ -200,4 +213,167 @@ public final class TypeConstraints {
         this.fractionDigits.add(fractionDigits);
     }
 
+    public void validateConstraints() {
+        validateLength();
+        validateRange();
+    }
+
+    private void validateRange() {
+        if (ranges.size() < 2) {
+            return;
+        }
+        List<RangeConstraint> typeRange = getRange();
+
+        for (RangeConstraint range : typeRange) {
+            if (range.getMin() instanceof UnknownBoundaryNumber || range.getMax() instanceof UnknownBoundaryNumber) {
+                throw new YangParseException(line, "Unresolved range constraints");
+            }
+            final long min = range.getMin().longValue();
+            final long max = range.getMax().longValue();
+
+            List<RangeConstraint> parentRanges = ranges.get(1);
+            boolean check = false;
+            for (RangeConstraint r : parentRanges) {
+                Number parentMinNumber = r.getMin();
+                if (parentMinNumber instanceof UnknownBoundaryNumber) {
+                    parentMinNumber = resolveMinRange(parentMinNumber);
+                }
+                long parentMin = parentMinNumber.longValue();
+
+                Number parentMaxNumber = r.getMax();
+                if (parentMaxNumber instanceof UnknownBoundaryNumber) {
+                    parentMaxNumber = resolveMaxRange(parentMaxNumber);
+                }
+                long parentMax = parentMaxNumber.longValue();
+
+                if (parentMin <= min && parentMax >= max) {
+                    check = true;
+                    break;
+                }
+            }
+            if (!check) {
+                throw new YangParseException(moduleName, line, "Invalid range constraint: <" + min + ", " + max
+                        + "> (parent: " + parentRanges + ").");
+            }
+        }
+    }
+
+    private void validateRange(List<RangeConstraint> typeRange) {
+        if (ranges.size() < 2) {
+            return;
+        }
+
+        for (RangeConstraint range : typeRange) {
+            if (range.getMin() instanceof UnknownBoundaryNumber || range.getMax() instanceof UnknownBoundaryNumber) {
+                throw new YangParseException(line, "Unresolved range constraints");
+            }
+            final long min = range.getMin().longValue();
+            final long max = range.getMax().longValue();
+
+            List<RangeConstraint> parentRanges = ranges.get(1);
+            boolean check = false;
+            for (RangeConstraint r : parentRanges) {
+                Number parentMinNumber = r.getMin();
+                if (parentMinNumber instanceof UnknownBoundaryNumber) {
+                    parentMinNumber = resolveMinRange(parentMinNumber);
+                }
+                long parentMin = parentMinNumber.longValue();
+
+                Number parentMaxNumber = r.getMax();
+                if (parentMaxNumber instanceof UnknownBoundaryNumber) {
+                    parentMaxNumber = resolveMaxRange(parentMaxNumber);
+                }
+                long parentMax = parentMaxNumber.longValue();
+
+                if (parentMin <= min && parentMax >= max) {
+                    check = true;
+                    break;
+                }
+            }
+            if (!check) {
+                throw new YangParseException(moduleName, line, "Invalid range constraint: <" + min + ", " + max
+                        + "> (parent: " + parentRanges + ").");
+            }
+        }
+    }
+
+    private void validateLength() {
+        if (lengths.size() < 2) {
+            return;
+        }
+        List<LengthConstraint> typeLength = getLength();
+
+        for (LengthConstraint length : typeLength) {
+            if (length.getMin() instanceof UnknownBoundaryNumber || length.getMax() instanceof UnknownBoundaryNumber) {
+                throw new YangParseException(line, "Unresolved length constraints");
+            }
+            final long min = length.getMin().longValue();
+            final long max = length.getMax().longValue();
+
+            List<LengthConstraint> parentLengths = lengths.get(1);
+            boolean check = false;
+            for (LengthConstraint lc : parentLengths) {
+                Number parentMinNumber = lc.getMin();
+                if (parentMinNumber instanceof UnknownBoundaryNumber) {
+                    parentMinNumber = resolveMinLength(parentMinNumber);
+                }
+                long parentMin = parentMinNumber.longValue();
+
+                Number parentMaxNumber = lc.getMax();
+                if (parentMaxNumber instanceof UnknownBoundaryNumber) {
+                    parentMaxNumber = resolveMaxLength(parentMaxNumber);
+                }
+                long parentMax = parentMaxNumber.longValue();
+
+                if (parentMin <= min && parentMax >= max) {
+                    check = true;
+                    break;
+                }
+            }
+            if (!check) {
+                throw new YangParseException(moduleName, line, "Invalid length constraint: <" + min + ", " + max
+                        + "> (parent: " + parentLengths + ").");
+            }
+        }
+    }
+
+    private void validateLength(List<LengthConstraint> typeLength) {
+        if (lengths.size() < 2) {
+            return;
+        }
+
+        for (LengthConstraint length : typeLength) {
+            if (length.getMin() instanceof UnknownBoundaryNumber || length.getMax() instanceof UnknownBoundaryNumber) {
+                throw new YangParseException(line, "Unresolved length constraints");
+            }
+            final long min = length.getMin().longValue();
+            final long max = length.getMax().longValue();
+
+            List<LengthConstraint> parentLengths = lengths.get(1);
+            boolean check = false;
+            for (LengthConstraint lc : parentLengths) {
+                Number parentMinNumber = lc.getMin();
+                if (parentMinNumber instanceof UnknownBoundaryNumber) {
+                    parentMinNumber = resolveMinLength(parentMinNumber);
+                }
+                long parentMin = parentMinNumber.longValue();
+
+                Number parentMaxNumber = lc.getMax();
+                if (parentMaxNumber instanceof UnknownBoundaryNumber) {
+                    parentMaxNumber = resolveMaxLength(parentMaxNumber);
+                }
+                long parentMax = parentMaxNumber.longValue();
+
+                if (parentMin <= min && parentMax >= max) {
+                    check = true;
+                    break;
+                }
+            }
+            if (!check) {
+                throw new YangParseException(moduleName, line, "Invalid length constraint: <" + min + ", " + max
+                        + "> (parent: " + parentLengths + ").");
+            }
+        }
+    }
+
 }
index 1e55b24..ae405c0 100644 (file)
@@ -118,8 +118,7 @@ import org.slf4j.LoggerFactory;
 
 public final class YangModelBuilderUtil {
 
-    private static final Logger logger = LoggerFactory
-            .getLogger(YangModelBuilderUtil.class);
+    private static final Logger logger = LoggerFactory.getLogger(YangModelBuilderUtil.class);
 
     private YangModelBuilderUtil() {
     }
@@ -135,8 +134,7 @@ public final class YangModelBuilderUtil {
         final String result = "";
         for (int i = 0; i < treeNode.getChildCount(); ++i) {
             if (treeNode.getChild(i) instanceof StringContext) {
-                final StringContext context = (StringContext) treeNode
-                        .getChild(i);
+                final StringContext context = (StringContext) treeNode.getChild(i);
                 if (context != null) {
                     return context.getChild(0).getText().replace("\"", "");
                 }
@@ -154,8 +152,7 @@ public final class YangModelBuilderUtil {
      * @param builder
      *            builder to fill in with parsed statements
      */
-    public static void parseSchemaNodeArgs(final ParseTree ctx,
-            final SchemaNodeBuilder builder) {
+    public static void parseSchemaNodeArgs(final ParseTree ctx, final SchemaNodeBuilder builder) {
         for (int i = 0; i < ctx.getChildCount(); i++) {
             final ParseTree child = ctx.getChild(i);
             if (child instanceof Description_stmtContext) {
@@ -229,8 +226,7 @@ public final class YangModelBuilderUtil {
      * @param prefix
      * @return SchemaPath object.
      */
-    public static SchemaPath createActualSchemaPath(
-            final List<String> actualPath, final URI namespace,
+    public static SchemaPath createActualSchemaPath(final List<String> actualPath, final URI namespace,
             final Date revision, final String prefix) {
         final List<QName> path = new ArrayList<QName>();
         QName qname;
@@ -260,8 +256,7 @@ public final class YangModelBuilderUtil {
                 if (splittedElement.length == 1) {
                     name = new QName(null, null, null, splittedElement[0]);
                 } else {
-                    name = new QName(null, null, splittedElement[0],
-                            splittedElement[1]);
+                    name = new QName(null, null, splittedElement[0], splittedElement[1]);
                 }
                 path.add(name);
             }
@@ -283,8 +278,8 @@ public final class YangModelBuilderUtil {
      *            current prefix
      * @return YANG list key as java.util.List of QName objects
      */
-    public static List<QName> createListKey(final String keyDefinition,
-            final URI namespace, final Date revision, final String prefix) {
+    public static List<QName> createListKey(final String keyDefinition, final URI namespace, final Date revision,
+            final String prefix) {
         List<QName> key = new ArrayList<QName>();
         String[] splittedKey = keyDefinition.split(" ");
 
@@ -310,9 +305,8 @@ public final class YangModelBuilderUtil {
      * @param prefix
      * @return List of EnumPair object parsed from given context
      */
-    private static List<EnumTypeDefinition.EnumPair> getEnumConstants(
-            final Type_body_stmtsContext ctx, final List<String> path,
-            final URI namespace, final Date revision, final String prefix) {
+    private static List<EnumTypeDefinition.EnumPair> getEnumConstants(final Type_body_stmtsContext ctx,
+            final List<String> path, final URI namespace, final Date revision, final String prefix) {
         List<EnumTypeDefinition.EnumPair> enumConstants = new ArrayList<EnumTypeDefinition.EnumPair>();
 
         for (int j = 0; j < ctx.getChildCount(); j++) {
@@ -322,9 +316,8 @@ public final class YangModelBuilderUtil {
                 for (int k = 0; k < enumSpecChild.getChildCount(); k++) {
                     ParseTree enumChild = enumSpecChild.getChild(k);
                     if (enumChild instanceof Enum_stmtContext) {
-                        EnumPair enumPair = createEnumPair(
-                                (Enum_stmtContext) enumChild, highestValue,
-                                path, namespace, revision, prefix);
+                        EnumPair enumPair = createEnumPair((Enum_stmtContext) enumChild, highestValue, path, namespace,
+                                revision, prefix);
                         if (enumPair.getValue() > highestValue) {
                             highestValue = enumPair.getValue();
                         }
@@ -350,10 +343,8 @@ public final class YangModelBuilderUtil {
      * @param prefix
      * @return EnumPair object parsed from given context
      */
-    private static EnumTypeDefinition.EnumPair createEnumPair(
-            final Enum_stmtContext ctx, final int highestValue,
-            final List<String> path, final URI namespace, final Date revision,
-            final String prefix) {
+    private static EnumTypeDefinition.EnumPair createEnumPair(final Enum_stmtContext ctx, final int highestValue,
+            final List<String> path, final URI namespace, final Date revision, final String prefix) {
         final String name = stringFromNode(ctx);
         final QName qname = new QName(namespace, revision, prefix, name);
         Integer value = null;
@@ -383,18 +374,13 @@ public final class YangModelBuilderUtil {
             value = highestValue + 1;
         }
         if (value < -2147483648 || value > 2147483647) {
-            throw new YangParseException(
-                    ctx.getStart().getLine(),
-                    "Error on enum '"
-                            + name
-                            + "': the enum value MUST be in the range from -2147483648 to 2147483647, but was: "
-                            + value);
+            throw new YangParseException(ctx.getStart().getLine(), "Error on enum '" + name
+                    + "': the enum value MUST be in the range from -2147483648 to 2147483647, but was: " + value);
         }
 
         EnumPairImpl result = new EnumPairImpl();
         result.qname = qname;
-        result.path = createActualSchemaPath(enumPairPath, namespace, revision,
-                prefix);
+        result.path = createActualSchemaPath(enumPairPath, namespace, revision, prefix);
         result.description = description;
         result.reference = reference;
         result.status = status;
@@ -412,8 +398,7 @@ public final class YangModelBuilderUtil {
         private String description;
         private String reference;
         private Status status;
-        private List<UnknownSchemaNode> extensionSchemaNodes = Collections
-                .emptyList();
+        private List<UnknownSchemaNode> extensionSchemaNodes = Collections.emptyList();
         private String name;
         private Integer value;
 
@@ -463,10 +448,7 @@ public final class YangModelBuilderUtil {
             int result = 1;
             result = prime * result + ((qname == null) ? 0 : qname.hashCode());
             result = prime * result + ((path == null) ? 0 : path.hashCode());
-            result = prime
-                    * result
-                    + ((extensionSchemaNodes == null) ? 0
-                            : extensionSchemaNodes.hashCode());
+            result = prime * result + ((extensionSchemaNodes == null) ? 0 : extensionSchemaNodes.hashCode());
             result = prime * result + ((name == null) ? 0 : name.hashCode());
             result = prime * result + ((value == null) ? 0 : value.hashCode());
             return result;
@@ -524,8 +506,7 @@ public final class YangModelBuilderUtil {
 
         @Override
         public String toString() {
-            return EnumTypeDefinition.EnumPair.class.getSimpleName() + "[name="
-                    + name + ", value=" + value + "]";
+            return EnumTypeDefinition.EnumPair.class.getSimpleName() + "[name=" + name + ", value=" + value + "]";
         }
     }
 
@@ -536,8 +517,7 @@ public final class YangModelBuilderUtil {
      *            type body context to parse
      * @return List of RangeConstraint created from this context
      */
-    private static List<RangeConstraint> getRangeConstraints(
-            final Type_body_stmtsContext ctx) {
+    private static List<RangeConstraint> getRangeConstraints(final Type_body_stmtsContext ctx) {
         List<RangeConstraint> rangeConstraints = Collections.emptyList();
         outer: for (int j = 0; j < ctx.getChildCount(); j++) {
             ParseTree numRestrChild = ctx.getChild(j);
@@ -561,8 +541,7 @@ public final class YangModelBuilderUtil {
      *            range context to parse
      * @return List of RangeConstraints parsed from this context
      */
-    private static List<RangeConstraint> parseRangeConstraints(
-            final Range_stmtContext ctx) {
+    private static List<RangeConstraint> parseRangeConstraints(final Range_stmtContext ctx) {
         final int line = ctx.getStart().getLine();
         List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();
         String description = null;
@@ -585,14 +564,12 @@ public final class YangModelBuilderUtil {
             Number min;
             Number max;
             if (splittedRangeDef.length == 1) {
-                min = max = parseNumberConstraintValue(splittedRangeDef[0],
-                        line);
+                min = max = parseNumberConstraintValue(splittedRangeDef[0], line);
             } else {
                 min = parseNumberConstraintValue(splittedRangeDef[0], line);
                 max = parseNumberConstraintValue(splittedRangeDef[1], line);
             }
-            RangeConstraint range = BaseConstraints.rangeConstraint(min, max,
-                    description, reference);
+            RangeConstraint range = BaseConstraints.rangeConstraint(min, max, description, reference);
             rangeConstraints.add(range);
         }
 
@@ -606,8 +583,7 @@ public final class YangModelBuilderUtil {
      *            type body context to parse
      * @return List of LengthConstraint created from this context
      */
-    private static List<LengthConstraint> getLengthConstraints(
-            final Type_body_stmtsContext ctx) {
+    private static List<LengthConstraint> getLengthConstraints(final Type_body_stmtsContext ctx) {
         List<LengthConstraint> lengthConstraints = Collections.emptyList();
         outer: for (int j = 0; j < ctx.getChildCount(); j++) {
             ParseTree stringRestrChild = ctx.getChild(j);
@@ -631,8 +607,7 @@ public final class YangModelBuilderUtil {
      *            length context to parse
      * @return List of LengthConstraints parsed from this context
      */
-    private static List<LengthConstraint> parseLengthConstraints(
-            final Length_stmtContext ctx) {
+    private static List<LengthConstraint> parseLengthConstraints(final Length_stmtContext ctx) {
         final int line = ctx.getStart().getLine();
         List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();
         String description = null;
@@ -655,14 +630,12 @@ public final class YangModelBuilderUtil {
             Number min;
             Number max;
             if (splittedRangeDef.length == 1) {
-                min = max = parseNumberConstraintValue(splittedRangeDef[0],
-                        line);
+                min = max = parseNumberConstraintValue(splittedRangeDef[0], line);
             } else {
                 min = parseNumberConstraintValue(splittedRangeDef[0], line);
                 max = parseNumberConstraintValue(splittedRangeDef[1], line);
             }
-            LengthConstraint range = BaseConstraints.lengthConstraint(min, max,
-                    description, reference);
+            LengthConstraint range = BaseConstraints.lengthConstraint(min, max, description, reference);
             lengthConstraints.add(range);
         }
 
@@ -675,8 +648,7 @@ public final class YangModelBuilderUtil {
      * @return wrapper object of primitive java type or UnknownBoundaryNumber if
      *         type is one of special YANG values 'min' or 'max'
      */
-    private static Number parseNumberConstraintValue(final String value,
-            final int line) {
+    private static Number parseNumberConstraintValue(final String value, final int line) {
         Number result = null;
         if ("min".equals(value) || "max".equals(value)) {
             result = new UnknownBoundaryNumber(value);
@@ -684,8 +656,7 @@ public final class YangModelBuilderUtil {
             try {
                 result = Long.valueOf(value);
             } catch (NumberFormatException e) {
-                throw new YangParseException(line,
-                        "Unable to parse range value '" + value + "'.", e);
+                throw new YangParseException(line, "Unable to parse range value '" + value + "'.", e);
             }
         }
         return result;
@@ -698,8 +669,7 @@ public final class YangModelBuilderUtil {
      *            type body
      * @return list of pattern constraints
      */
-    private static List<PatternConstraint> getPatternConstraint(
-            final Type_body_stmtsContext ctx) {
+    private static List<PatternConstraint> getPatternConstraint(final Type_body_stmtsContext ctx) {
         List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();
 
         outer: for (int j = 0; j < ctx.getChildCount(); j++) {
@@ -726,8 +696,7 @@ public final class YangModelBuilderUtil {
      *            pattern context
      * @return PatternConstraint object
      */
-    private static PatternConstraint parsePatternConstraint(
-            final Pattern_stmtContext ctx) {
+    private static PatternConstraint parsePatternConstraint(final Pattern_stmtContext ctx) {
         String description = null;
         String reference = null;
         for (int i = 0; i < ctx.getChildCount(); i++) {
@@ -739,8 +708,7 @@ public final class YangModelBuilderUtil {
             }
         }
         String pattern = patternStringFromNode(ctx);
-        return BaseConstraints.patternConstraint(pattern, description,
-                reference);
+        return BaseConstraints.patternConstraint(pattern, description, reference);
     }
 
     /**
@@ -758,8 +726,7 @@ public final class YangModelBuilderUtil {
                 for (int j = 0; j < child.getChildCount(); j++) {
                     if (j % 2 == 0) {
                         String patternToken = child.getChild(j).getText();
-                        result.append(patternToken.substring(1,
-                                patternToken.length() - 1));
+                        result.append(patternToken.substring(1, patternToken.length() - 1));
                     }
                 }
             }
@@ -793,8 +760,7 @@ public final class YangModelBuilderUtil {
      *            decimal64 context
      * @return fraction-digits value as Integer
      */
-    private static Integer parseFractionDigits(
-            Decimal64_specificationContext ctx) {
+    private static Integer parseFractionDigits(Decimal64_specificationContext ctx) {
         Integer result = null;
         for (int k = 0; k < ctx.getChildCount(); k++) {
             ParseTree fdChild = ctx.getChild(k);
@@ -803,9 +769,8 @@ public final class YangModelBuilderUtil {
                 try {
                     result = Integer.valueOf(value);
                 } catch (NumberFormatException e) {
-                    throw new YangParseException(ctx.getStart().getLine(),
-                            "Unable to parse fraction digits value '" + value
-                                    + "'.", e);
+                    throw new YangParseException(ctx.getStart().getLine(), "Unable to parse fraction digits value '"
+                            + value + "'.", e);
                 }
             }
         }
@@ -825,9 +790,8 @@ public final class YangModelBuilderUtil {
      * @param prefix
      * @return List of Bit objects created from this context
      */
-    private static List<BitsTypeDefinition.Bit> getBits(
-            Type_body_stmtsContext ctx, List<String> actualPath, URI namespace,
-            Date revision, String prefix) {
+    private static List<BitsTypeDefinition.Bit> getBits(Type_body_stmtsContext ctx, List<String> actualPath,
+            URI namespace, Date revision, String prefix) {
         final List<BitsTypeDefinition.Bit> bits = new ArrayList<BitsTypeDefinition.Bit>();
         for (int j = 0; j < ctx.getChildCount(); j++) {
             ParseTree bitsSpecChild = ctx.getChild(j);
@@ -836,8 +800,7 @@ public final class YangModelBuilderUtil {
                 for (int k = 0; k < bitsSpecChild.getChildCount(); k++) {
                     ParseTree bitChild = bitsSpecChild.getChild(k);
                     if (bitChild instanceof Bit_stmtContext) {
-                        Bit bit = parseBit((Bit_stmtContext) bitChild,
-                                highestPosition, actualPath, namespace,
+                        Bit bit = parseBit((Bit_stmtContext) bitChild, highestPosition, actualPath, namespace,
                                 revision, prefix);
                         if (bit.getPosition() > highestPosition) {
                             highestPosition = bit.getPosition();
@@ -864,9 +827,8 @@ public final class YangModelBuilderUtil {
      * @param prefix
      * @return Bit object parsed from this context
      */
-    private static BitsTypeDefinition.Bit parseBit(final Bit_stmtContext ctx,
-            long highestPosition, List<String> actualPath, final URI namespace,
-            final Date revision, final String prefix) {
+    private static BitsTypeDefinition.Bit parseBit(final Bit_stmtContext ctx, long highestPosition,
+            List<String> actualPath, final URI namespace, final Date revision, final String prefix) {
         String name = stringFromNode(ctx);
         final QName qname = new QName(namespace, revision, prefix, name);
         Long position = null;
@@ -879,8 +841,7 @@ public final class YangModelBuilderUtil {
         bitPath.addAll(actualPath);
         bitPath.add(name);
 
-        SchemaPath schemaPath = createActualSchemaPath(bitPath, namespace,
-                revision, prefix);
+        SchemaPath schemaPath = createActualSchemaPath(bitPath, namespace, revision, prefix);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
@@ -900,16 +861,12 @@ public final class YangModelBuilderUtil {
             position = highestPosition + 1;
         }
         if (position < 0 || position > 4294967295L) {
-            throw new YangParseException(
-                    ctx.getStart().getLine(),
-                    "Error on bit '"
-                            + name
-                            + "': the position value MUST be in the range 0 to 4294967295");
+            throw new YangParseException(ctx.getStart().getLine(), "Error on bit '" + name
+                    + "': the position value MUST be in the range 0 to 4294967295");
         }
 
         final List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
-        return new BitImpl(position, qname, schemaPath, description, reference,
-                status, unknownNodes);
+        return new BitImpl(position, qname, schemaPath, description, reference, status, unknownNodes);
     }
 
     /**
@@ -971,9 +928,8 @@ public final class YangModelBuilderUtil {
      *            type body
      * @return UnknownType object with constraints from parsed type body
      */
-    public static TypeDefinition<?> parseUnknownTypeBody(QName typedefQName,
-            Type_body_stmtsContext ctx, final List<String> actualPath,
-            final URI namespace, final Date revision, final String prefix,
+    public static TypeDefinition<?> parseUnknownTypeBody(QName typedefQName, Type_body_stmtsContext ctx,
+            final List<String> actualPath, final URI namespace, final Date revision, final String prefix,
             Builder parent, ModuleBuilder moduleBuilder) {
         String typeName = typedefQName.getLocalName();
 
@@ -998,10 +954,9 @@ public final class YangModelBuilderUtil {
                 QName qname = new QName(namespace, revision, prefix, typeName);
                 ExtendedType.Builder typeBuilder = null;
 
-                SchemaPath schemaPath = createTypeSchemaPath(actualPath,
-                        namespace, revision, prefix, typeName, false, false);
-                typeBuilder = new ExtendedType.Builder(qname, baseType, "", "",
-                        schemaPath);
+                SchemaPath schemaPath = createTypeSchemaPath(actualPath, namespace, revision, prefix, typeName, false,
+                        false);
+                typeBuilder = new ExtendedType.Builder(qname, baseType, "", "", schemaPath);
 
                 typeBuilder.ranges(rangeStatements);
                 typeBuilder.lengths(lengthStatements);
@@ -1034,9 +989,8 @@ public final class YangModelBuilderUtil {
      *            current prefix
      * @return TypeDefinition object based on parsed values.
      */
-    public static TypeDefinition<?> parseTypeBody(final String typeName,
-            final Type_body_stmtsContext typeBody,
-            final List<String> actualPath, final URI namespace,
+    public static TypeDefinition<?> parseTypeBody(final String moduleName, final String typeName,
+            final Type_body_stmtsContext typeBody, final List<String> actualPath, final URI namespace,
             final Date revision, final String prefix, Builder parent) {
         TypeDefinition<?> baseType = null;
 
@@ -1044,19 +998,18 @@ public final class YangModelBuilderUtil {
         Integer fractionDigits = getFractionDigits(typeBody);
         List<LengthConstraint> lengthStatements = getLengthConstraints(typeBody);
         List<PatternConstraint> patternStatements = getPatternConstraint(typeBody);
-        List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(
-                typeBody, actualPath, namespace, revision, prefix);
+        List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(typeBody, actualPath, namespace, revision,
+                prefix);
 
-        TypeConstraints constraints = new TypeConstraints();
+        TypeConstraints constraints = new TypeConstraints(moduleName, typeBody.getStart().getLine());
         constraints.addFractionDigits(fractionDigits);
         constraints.addLengths(lengthStatements);
         constraints.addPatterns(patternStatements);
         constraints.addRanges(rangeStatements);
 
-        SchemaPath baseTypePathFinal = createTypeSchemaPath(actualPath,
-                namespace, revision, prefix, typeName, true, true);
-        SchemaPath baseTypePath = createTypeSchemaPath(actualPath, namespace,
-                revision, prefix, typeName, true, false);
+        SchemaPath baseTypePathFinal = createTypeSchemaPath(actualPath, namespace, revision, prefix, typeName, true,
+                true);
+        SchemaPath baseTypePath = createTypeSchemaPath(actualPath, namespace, revision, prefix, typeName, true, false);
 
         if ("decimal64".equals(typeName)) {
             if (rangeStatements.isEmpty()) {
@@ -1098,13 +1051,11 @@ public final class YangModelBuilderUtil {
             constraints.addLengths(stringType.getLengthStatements());
             baseType = stringType;
         } else if ("bits".equals(typeName)) {
-            return new BitsType(baseTypePathFinal, getBits(typeBody,
-                    actualPath, namespace, revision, prefix));
+            return new BitsType(baseTypePathFinal, getBits(typeBody, actualPath, namespace, revision, prefix));
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
-            RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path,
-                    absolute);
+            RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path, absolute);
             return new Leafref(baseTypePathFinal, xpath);
         } else if ("binary".equals(typeName)) {
             BinaryTypeDefinition binaryType = new BinaryType(baseTypePath);
@@ -1112,12 +1063,10 @@ public final class YangModelBuilderUtil {
             baseType = binaryType;
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            baseType = new InstanceIdentifier(baseTypePath, null,
-                    requireInstance);
+            baseType = new InstanceIdentifier(baseTypePath, null, requireInstance);
         }
 
-        if (parent instanceof TypeDefinitionBuilder
-                && !(parent instanceof UnionTypeBuilder)) {
+        if (parent instanceof TypeDefinitionBuilder && !(parent instanceof UnionTypeBuilder)) {
             TypeDefinitionBuilder typedef = (TypeDefinitionBuilder) parent;
             typedef.setRanges(constraints.getRange());
             typedef.setLengths(constraints.getLength());
@@ -1130,10 +1079,8 @@ public final class YangModelBuilderUtil {
         QName qname = new QName(namespace, revision, prefix, typeName);
         ExtendedType.Builder typeBuilder = null;
 
-        SchemaPath schemaPath = createTypeSchemaPath(actualPath, namespace,
-                revision, prefix, typeName, false, false);
-        typeBuilder = new ExtendedType.Builder(qname, baseType, "", "",
-                schemaPath);
+        SchemaPath schemaPath = createTypeSchemaPath(actualPath, namespace, revision, prefix, typeName, false, false);
+        typeBuilder = new ExtendedType.Builder(qname, baseType, "", "", schemaPath);
 
         typeBuilder.ranges(constraints.getRange());
         typeBuilder.lengths(constraints.getLength());
@@ -1160,10 +1107,9 @@ public final class YangModelBuilderUtil {
      *            if this is base yang type without restrictions
      * @return SchemaPath object.
      */
-    private static SchemaPath createTypeSchemaPath(
-            final List<String> actualPath, final URI namespace,
-            final Date revision, final String prefix, final String typeName,
-            final boolean isBaseYangType, final boolean isBaseYangTypeFinal) {
+    private static SchemaPath createTypeSchemaPath(final List<String> actualPath, final URI namespace,
+            final Date revision, final String prefix, final String typeName, final boolean isBaseYangType,
+            final boolean isBaseYangTypeFinal) {
         List<String> typePath = new ArrayList<String>(actualPath);
         if (isBaseYangType && !isBaseYangTypeFinal) {
             typePath.add(typeName);
@@ -1279,8 +1225,7 @@ public final class YangModelBuilderUtil {
                     for (int j = 0; j < context.getChildCount(); j++) {
                         String mustPart = context.getChild(j).getText();
                         if (j == 0) {
-                            mustText.append(mustPart.substring(0,
-                                    mustPart.length() - 1));
+                            mustText.append(mustPart.substring(0, mustPart.length() - 1));
                             continue;
                         }
                         if (j % 2 == 0) {
@@ -1299,8 +1244,8 @@ public final class YangModelBuilderUtil {
             }
         }
 
-        MustDefinition must = new MustDefinitionImpl(mustText.toString(),
-                description, reference, errorAppTag, errorMessage);
+        MustDefinition must = new MustDefinitionImpl(mustText.toString(), description, reference, errorAppTag,
+                errorMessage);
         return must;
     }
 
@@ -1312,8 +1257,7 @@ public final class YangModelBuilderUtil {
      * @param constraints
      *            ConstraintsBuilder to fill
      */
-    public static void parseConstraints(final ParseTree ctx,
-            final ConstraintsBuilder constraints) {
+    public static void parseConstraints(final ParseTree ctx, final ConstraintsBuilder constraints) {
         for (int i = 0; i < ctx.getChildCount(); ++i) {
             final ParseTree childNode = ctx.getChild(i);
             if (childNode instanceof Max_elements_stmtContext) {
@@ -1329,8 +1273,7 @@ public final class YangModelBuilderUtil {
                 for (int j = 0; j < childNode.getChildCount(); j++) {
                     ParseTree mandatoryTree = ctx.getChild(j);
                     if (mandatoryTree instanceof Mandatory_argContext) {
-                        Boolean mandatory = Boolean
-                                .valueOf(stringFromNode(mandatoryTree));
+                        Boolean mandatory = Boolean.valueOf(stringFromNode(mandatoryTree));
                         constraints.setMandatory(mandatory);
                     }
                 }
@@ -1354,8 +1297,7 @@ public final class YangModelBuilderUtil {
             }
             return result;
         } catch (Exception e) {
-            throw new YangParseException(ctx.getStart().getLine(),
-                    "Failed to parse min-elements.", e);
+            throw new YangParseException(ctx.getStart().getLine(), "Failed to parse min-elements.", e);
         }
     }
 
@@ -1373,8 +1315,7 @@ public final class YangModelBuilderUtil {
             }
             return result;
         } catch (Exception e) {
-            throw new YangParseException(ctx.getStart().getLine(),
-                    "Failed to parse max-elements.", e);
+            throw new YangParseException(ctx.getStart().getLine(), "Failed to parse max-elements.", e);
         }
     }
 
@@ -1418,8 +1359,8 @@ public final class YangModelBuilderUtil {
      *             if this is one of YANG type which MUST contain additional
      *             informations in its body
      */
-    public static void checkMissingBody(final String typeName,
-            final String moduleName, final int line) throws YangParseException {
+    public static void checkMissingBody(final String typeName, final String moduleName, final int line)
+            throws YangParseException {
         if ("decimal64".equals(typeName)) {
             throw new YangParseException(moduleName, line,
                     "The 'fraction-digits' statement MUST be present if the type is 'decimal64'.");
@@ -1430,8 +1371,7 @@ public final class YangModelBuilderUtil {
             throw new YangParseException(moduleName, line,
                     "The 'path' statement MUST be present if the type is 'leafref'.");
         } else if ("bits".equals(typeName)) {
-            throw new YangParseException(moduleName, line,
-                    "The 'bit' statement MUST be present if the type is 'bits'.");
+            throw new YangParseException(moduleName, line, "The 'bit' statement MUST be present if the type is 'bits'.");
         } else if ("enumeration".equals(typeName)) {
             throw new YangParseException(moduleName, line,
                     "The 'enum' statement MUST be present if the type is 'enumeration'.");
@@ -1449,8 +1389,7 @@ public final class YangModelBuilderUtil {
      */
     public static RefineHolder parseRefine(Refine_stmtContext refineCtx) {
         final String refineTarget = stringFromNode(refineCtx);
-        final RefineHolder refine = new RefineHolder(refineTarget, refineCtx
-                .getStart().getLine());
+        final RefineHolder refine = new RefineHolder(refineTarget, refineCtx.getStart().getLine());
         for (int j = 0; j < refineCtx.getChildCount(); j++) {
             ParseTree refinePom = refineCtx.getChild(j);
             if (refinePom instanceof Refine_pomContext) {
@@ -1459,23 +1398,17 @@ public final class YangModelBuilderUtil {
                     parseRefineDefault(refine, refineStmt);
 
                     if (refineStmt instanceof Refine_leaf_stmtsContext) {
-                        parseRefine(refine,
-                                (Refine_leaf_stmtsContext) refineStmt);
+                        parseRefine(refine, (Refine_leaf_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_container_stmtsContext) {
-                        parseRefine(refine,
-                                (Refine_container_stmtsContext) refineStmt);
+                        parseRefine(refine, (Refine_container_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_list_stmtsContext) {
-                        parseRefine(refine,
-                                (Refine_list_stmtsContext) refineStmt);
+                        parseRefine(refine, (Refine_list_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_leaf_list_stmtsContext) {
-                        parseRefine(refine,
-                                (Refine_leaf_list_stmtsContext) refineStmt);
+                        parseRefine(refine, (Refine_leaf_list_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_choice_stmtsContext) {
-                        parseRefine(refine,
-                                (Refine_choice_stmtsContext) refineStmt);
+                        parseRefine(refine, (Refine_choice_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_anyxml_stmtsContext) {
-                        parseRefine(refine,
-                                (Refine_anyxml_stmtsContext) refineStmt);
+                        parseRefine(refine, (Refine_anyxml_stmtsContext) refineStmt);
                     }
                 }
             }
@@ -1483,8 +1416,7 @@ public final class YangModelBuilderUtil {
         return refine;
     }
 
-    private static void parseRefineDefault(RefineHolder refine,
-            ParseTree refineStmt) {
+    private static void parseRefineDefault(RefineHolder refine, ParseTree refineStmt) {
         for (int i = 0; i < refineStmt.getChildCount(); i++) {
             ParseTree refineArg = refineStmt.getChild(i);
             if (refineArg instanceof Description_stmtContext) {
@@ -1500,8 +1432,7 @@ public final class YangModelBuilderUtil {
         }
     }
 
-    private static RefineHolder parseRefine(RefineHolder refine,
-            Refine_leaf_stmtsContext refineStmt) {
+    private static RefineHolder parseRefine(RefineHolder refine, Refine_leaf_stmtsContext refineStmt) {
         for (int i = 0; i < refineStmt.getChildCount(); i++) {
             ParseTree refineArg = refineStmt.getChild(i);
             if (refineArg instanceof Default_stmtContext) {
@@ -1511,8 +1442,7 @@ public final class YangModelBuilderUtil {
                 for (int j = 0; j < refineArg.getChildCount(); j++) {
                     ParseTree mandatoryTree = refineArg.getChild(j);
                     if (mandatoryTree instanceof Mandatory_argContext) {
-                        Boolean mandatory = Boolean
-                                .valueOf(stringFromNode(mandatoryTree));
+                        Boolean mandatory = Boolean.valueOf(stringFromNode(mandatoryTree));
                         refine.setMandatory(mandatory);
                     }
                 }
@@ -1525,8 +1455,7 @@ public final class YangModelBuilderUtil {
         return refine;
     }
 
-    private static RefineHolder parseRefine(RefineHolder refine,
-            Refine_container_stmtsContext refineStmt) {
+    private static RefineHolder parseRefine(RefineHolder refine, Refine_container_stmtsContext refineStmt) {
         for (int m = 0; m < refineStmt.getChildCount(); m++) {
             ParseTree refineArg = refineStmt.getChild(m);
             if (refineArg instanceof Must_stmtContext) {
@@ -1539,8 +1468,7 @@ public final class YangModelBuilderUtil {
         return refine;
     }
 
-    private static RefineHolder parseRefine(RefineHolder refine,
-            Refine_list_stmtsContext refineStmt) {
+    private static RefineHolder parseRefine(RefineHolder refine, Refine_list_stmtsContext refineStmt) {
         for (int m = 0; m < refineStmt.getChildCount(); m++) {
             ParseTree refineArg = refineStmt.getChild(m);
             if (refineArg instanceof Must_stmtContext) {
@@ -1557,8 +1485,7 @@ public final class YangModelBuilderUtil {
         return refine;
     }
 
-    private static RefineHolder parseRefine(RefineHolder refine,
-            Refine_leaf_list_stmtsContext refineStmt) {
+    private static RefineHolder parseRefine(RefineHolder refine, Refine_leaf_list_stmtsContext refineStmt) {
         for (int m = 0; m < refineStmt.getChildCount(); m++) {
             ParseTree refineArg = refineStmt.getChild(m);
             if (refineArg instanceof Must_stmtContext) {
@@ -1575,8 +1502,7 @@ public final class YangModelBuilderUtil {
         return refine;
     }
 
-    private static RefineHolder parseRefine(RefineHolder refine,
-            Refine_choice_stmtsContext refineStmt) {
+    private static RefineHolder parseRefine(RefineHolder refine, Refine_choice_stmtsContext refineStmt) {
         for (int i = 0; i < refineStmt.getChildCount(); i++) {
             ParseTree refineArg = refineStmt.getChild(i);
             if (refineArg instanceof Default_stmtContext) {
@@ -1586,8 +1512,7 @@ public final class YangModelBuilderUtil {
                 for (int j = 0; j < refineArg.getChildCount(); j++) {
                     ParseTree mandatoryTree = refineArg.getChild(j);
                     if (mandatoryTree instanceof Mandatory_argContext) {
-                        Boolean mandatory = Boolean
-                                .valueOf(stringFromNode(mandatoryTree));
+                        Boolean mandatory = Boolean.valueOf(stringFromNode(mandatoryTree));
                         refine.setMandatory(mandatory);
                     }
                 }
@@ -1596,8 +1521,7 @@ public final class YangModelBuilderUtil {
         return refine;
     }
 
-    private static RefineHolder parseRefine(RefineHolder refine,
-            Refine_anyxml_stmtsContext refineStmt) {
+    private static RefineHolder parseRefine(RefineHolder refine, Refine_anyxml_stmtsContext refineStmt) {
         for (int i = 0; i < refineStmt.getChildCount(); i++) {
             ParseTree refineArg = refineStmt.getChild(i);
             if (refineArg instanceof Must_stmtContext) {
@@ -1607,8 +1531,7 @@ public final class YangModelBuilderUtil {
                 for (int j = 0; j < refineArg.getChildCount(); j++) {
                     ParseTree mandatoryTree = refineArg.getChild(j);
                     if (mandatoryTree instanceof Mandatory_argContext) {
-                        Boolean mandatory = Boolean
-                                .valueOf(stringFromNode(mandatoryTree));
+                        Boolean mandatory = Boolean.valueOf(stringFromNode(mandatoryTree));
                         refine.setMandatory(mandatory);
                     }
                 }
index 35bfb1b..3070c74 100644 (file)
@@ -24,12 +24,12 @@ public class YangParserNegativeTest {
     @Test
     public void testInvalidImport() throws IOException {
         try {
-            try (InputStream stream = new FileInputStream(getClass().getResource
-                    ("/negative-scenario/testfile1.yang").getPath())) {
+            try (InputStream stream = new FileInputStream(getClass().getResource("/negative-scenario/testfile1.yang")
+                    .getPath())) {
                 TestUtils.loadModule(stream);
                 fail("ValidationException should by thrown");
             }
-        } catch(YangValidationException e) {
+        } catch (YangValidationException e) {
             assertTrue(e.getMessage().contains("Not existing module imported"));
         }
     }
@@ -37,13 +37,14 @@ public class YangParserNegativeTest {
     @Test
     public void testTypeNotFound() throws IOException {
         try {
-            try (InputStream stream = new FileInputStream(getClass().getResource
-                    ("/negative-scenario/testfile2.yang").getPath())) {
+            try (InputStream stream = new FileInputStream(getClass().getResource("/negative-scenario/testfile2.yang")
+                    .getPath())) {
                 TestUtils.loadModule(stream);
                 fail("YangParseException should by thrown");
             }
-        } catch(YangParseException e) {
-            assertTrue(e.getMessage().contains("Error in module 'test2' on line 24: Referenced type 'int-ext' not found."));
+        } catch (YangParseException e) {
+            assertTrue(e.getMessage().contains(
+                    "Error in module 'test2' on line 24: Referenced type 'int-ext' not found."));
         }
     }
 
@@ -51,19 +52,18 @@ public class YangParserNegativeTest {
     public void testInvalidAugmentTarget() throws IOException {
         try {
             final List<InputStream> streams = new ArrayList<>(2);
-            try (InputStream testFile0 = new FileInputStream(getClass().getResource
-                    ("/negative-scenario/testfile0.yang").getPath())) {
+            try (InputStream testFile0 = new FileInputStream(getClass()
+                    .getResource("/negative-scenario/testfile0.yang").getPath())) {
                 streams.add(testFile0);
-                try (InputStream testFile3 = new FileInputStream(getClass().getResource
-                        ("/negative-scenario/testfile3.yang").getPath())) {
+                try (InputStream testFile3 = new FileInputStream(getClass().getResource(
+                        "/negative-scenario/testfile3.yang").getPath())) {
                     streams.add(testFile3);
-                    assertEquals("Expected loaded files count is 2", 2,
-                            streams.size());
+                    assertEquals("Expected loaded files count is 2", 2, streams.size());
                     TestUtils.loadModules(streams);
                     fail("YangParseException should by thrown");
                 }
             }
-        } catch(YangParseException e) {
+        } catch (YangParseException e) {
             assertTrue(e.getMessage().contains("Failed to resolve augments in module 'test3'."));
         }
     }
@@ -71,14 +71,42 @@ public class YangParserNegativeTest {
     @Test
     public void testInvalidRefine() throws IOException {
         try {
-            try (InputStream stream = new FileInputStream(getClass().getResource
-                    ("/negative-scenario/testfile4.yang").getPath())) {
+            try (InputStream stream = new FileInputStream(getClass().getResource("/negative-scenario/testfile4.yang")
+                    .getPath())) {
                 TestUtils.loadModule(stream);
                 fail("YangParseException should by thrown");
             }
-        } catch(YangParseException e) {
+        } catch (YangParseException e) {
             assertTrue(e.getMessage().contains("Can not refine 'presence' for 'node'."));
         }
     }
 
+    @Test
+    public void testInvalidLength() throws IOException {
+        try {
+            try (InputStream stream = new FileInputStream(getClass().getResource("/negative-scenario/testfile5.yang")
+                    .getPath())) {
+                TestUtils.loadModule(stream);
+                fail("YangParseException should by thrown");
+            }
+        } catch (YangParseException e) {
+            assertTrue(e.getMessage().contains("Invalid length constraint: <4, 10>"));
+        }
+
+    }
+
+    @Test
+    public void testInvalidRange() throws IOException {
+        try {
+            try (InputStream stream = new FileInputStream(getClass().getResource("/negative-scenario/testfile6.yang")
+                    .getPath())) {
+                TestUtils.loadModule(stream);
+                fail("YangParseException should by thrown");
+            }
+        } catch (YangParseException e) {
+            assertTrue(e.getMessage().contains("Invalid range constraint: <5, 20>"));
+        }
+
+    }
+
 }
index ba31e51..9006f93 100644 (file)
@@ -63,8 +63,7 @@ import org.opendaylight.controller.yang.model.util.Uint32;
 import org.opendaylight.controller.yang.model.util.UnionType;
 
 public class YangParserTest {
-    private final DateFormat simpleDateFormat = new SimpleDateFormat(
-            "yyyy-MM-dd");
+    private final DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
 
     private Set<Module> modules;
 
@@ -109,14 +108,12 @@ public class YangParserTest {
         String expectedPrefix = "t2";
         Date expectedRevision = TestUtils.createDate("2013-02-27");
 
-        ContainerSchemaNode interfaces = (ContainerSchemaNode) test
-                .getDataChildByName("interfaces");
+        ContainerSchemaNode interfaces = (ContainerSchemaNode) test.getDataChildByName("interfaces");
         // test SchemaNode args
-        QName expectedQName = new QName(expectedNamespace, expectedRevision,
-                expectedPrefix, "interfaces");
+        QName expectedQName = new QName(expectedNamespace, expectedRevision, expectedPrefix, "interfaces");
         assertEquals(expectedQName, interfaces.getQName());
-        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace,
-                expectedRevision, expectedPrefix, "interfaces");
+        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, expectedRevision, expectedPrefix,
+                "interfaces");
         assertEquals(expectedPath, interfaces.getPath());
         assertNull(interfaces.getDescription());
         assertNull(interfaces.getReference());
@@ -141,8 +138,7 @@ public class YangParserTest {
         assertEquals(0, interfaces.getGroupings().size());
         assertEquals(0, interfaces.getUses().size());
 
-        ListSchemaNode ifEntry = (ListSchemaNode) interfaces
-                .getDataChildByName("ifEntry");
+        ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
         assertNotNull(ifEntry);
     }
 
@@ -153,17 +149,14 @@ public class YangParserTest {
         String expectedPrefix = "t2";
         Date expectedRevision = TestUtils.createDate("2013-02-27");
 
-        ContainerSchemaNode interfaces = (ContainerSchemaNode) test
-                .getDataChildByName("interfaces");
+        ContainerSchemaNode interfaces = (ContainerSchemaNode) test.getDataChildByName("interfaces");
 
-        ListSchemaNode ifEntry = (ListSchemaNode) interfaces
-                .getDataChildByName("ifEntry");
+        ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
         // test SchemaNode args
-        QName expectedQName = new QName(expectedNamespace, expectedRevision,
-                expectedPrefix, "ifEntry");
+        QName expectedQName = new QName(expectedNamespace, expectedRevision, expectedPrefix, "ifEntry");
         assertEquals(expectedQName, ifEntry.getQName());
-        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace,
-                expectedRevision, expectedPrefix, "interfaces", "ifEntry");
+        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, expectedRevision, expectedPrefix,
+                "interfaces", "ifEntry");
         assertEquals(expectedPath, ifEntry.getPath());
         assertNull(ifEntry.getDescription());
         assertNull(ifEntry.getReference());
@@ -179,13 +172,11 @@ public class YangParserTest {
         assertEquals(1, (int) constraints.getMinElements());
         assertEquals(11, (int) constraints.getMaxElements());
         // test AugmentationTarget args
-        Set<AugmentationSchema> availableAugmentations = ifEntry
-                .getAvailableAugmentations();
+        Set<AugmentationSchema> availableAugmentations = ifEntry.getAvailableAugmentations();
         assertEquals(2, availableAugmentations.size());
         // test ListSchemaNode args
         List<QName> expectedKey = new ArrayList<QName>();
-        expectedKey.add(new QName(expectedNamespace, expectedRevision,
-                expectedPrefix, "ifIndex"));
+        expectedKey.add(new QName(expectedNamespace, expectedRevision, expectedPrefix, "ifIndex"));
         assertEquals(expectedKey, ifEntry.getKeyDefinition());
         assertFalse(ifEntry.isUserOrdered());
         // test DataNodeContainer args
@@ -194,11 +185,9 @@ public class YangParserTest {
         assertEquals(0, ifEntry.getGroupings().size());
         assertEquals(0, ifEntry.getUses().size());
 
-        LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry
-                .getDataChildByName("ifIndex");
+        LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName("ifIndex");
         assertTrue(ifIndex.getType() instanceof Uint32);
-        LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry
-                .getDataChildByName("ifMtu");
+        LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName("ifMtu");
         assertTrue(ifMtu.getType() instanceof Int32);
     }
 
@@ -207,8 +196,7 @@ public class YangParserTest {
         Module test = TestUtils.findModule(modules, "types2");
 
         // leaf if-name
-        LeafSchemaNode ifName = (LeafSchemaNode) test
-                .getDataChildByName("if-name");
+        LeafSchemaNode ifName = (LeafSchemaNode) test.getDataChildByName("if-name");
         Leafref ifNameType = (Leafref) ifName.getType();
         QName qname = ifNameType.getQName();
 
@@ -229,8 +217,7 @@ public class YangParserTest {
         assertEquals("string", nameQName.getLocalName());
 
         // leaf count
-        LeafSchemaNode count = (LeafSchemaNode) test
-                .getDataChildByName("count");
+        LeafSchemaNode count = (LeafSchemaNode) test.getDataChildByName("count");
         ExtendedType countType = (ExtendedType) count.getType();
         QName countTypeQName = countType.getQName();
 
@@ -255,46 +242,40 @@ public class YangParserTest {
         // testfile1
         Module module1 = TestUtils.findModule(modules, "types1");
 
-        Set<AugmentationSchema> module1Augmentations = module1
-                .getAugmentations();
+        Set<AugmentationSchema> module1Augmentations = module1.getAugmentations();
         AugmentationSchema augment1 = module1Augmentations.iterator().next();
-        LeafSchemaNode augmentedLeafDefinition = (LeafSchemaNode) augment1
-                .getDataChildByName("ds0ChannelNumber");
+        LeafSchemaNode augmentedLeafDefinition = (LeafSchemaNode) augment1.getDataChildByName("ds0ChannelNumber");
         assertTrue(augmentedLeafDefinition.isAugmenting());
 
         // testfile2
         Module module2 = TestUtils.findModule(modules, "types2");
 
-        ContainerSchemaNode interfaces = (ContainerSchemaNode) module2
-                .getDataChildByName("interfaces");
-        ListSchemaNode ifEntry = (ListSchemaNode) interfaces
-                .getDataChildByName("ifEntry");
-        ContainerSchemaNode augmentedContainer = (ContainerSchemaNode) ifEntry
-                .getDataChildByName("augment-holder");
+        ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName("interfaces");
+        ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
+        ContainerSchemaNode augmentedContainer = (ContainerSchemaNode) ifEntry.getDataChildByName("augment-holder");
+
+        ContainerSchemaNode schemas = (ContainerSchemaNode) augmentedContainer.getDataChildByName("schemas");
+        LeafSchemaNode linkleaf = (LeafSchemaNode) schemas.getDataChildByName("linkleaf");
+        assertNotNull(linkleaf);
 
         // augmentation defined in testfile1 and augmentation returned from
         // augmented container have to be same
-        Set<AugmentationSchema> augmentedContainerAugments = augmentedContainer
-                .getAvailableAugmentations();
-        AugmentationSchema augmentDefinition = augmentedContainerAugments
-                .iterator().next();
+        Set<AugmentationSchema> augmentedContainerAugments = augmentedContainer.getAvailableAugmentations();
+        AugmentationSchema augmentDefinition = augmentedContainerAugments.iterator().next();
         assertEquals(augment1, augmentDefinition);
 
-        LeafSchemaNode augmentedLeaf = (LeafSchemaNode) augmentedContainer
-                .getDataChildByName("ds0ChannelNumber");
+        LeafSchemaNode augmentedLeaf = (LeafSchemaNode) augmentedContainer.getDataChildByName("ds0ChannelNumber");
         assertTrue(augmentedLeaf.isAugmenting());
         assertEquals(augmentedLeafDefinition, augmentedLeaf);
 
-        Set<AugmentationSchema> ifEntryAugments = ifEntry
-                .getAvailableAugmentations();
+        Set<AugmentationSchema> ifEntryAugments = ifEntry.getAvailableAugmentations();
         assertEquals(2, ifEntryAugments.size());
 
         // testfile3
         Module module3 = TestUtils.findModule(modules, "types3");
 
-        Set<AugmentationSchema> module3Augmentations = module3
-                .getAugmentations();
-        assertEquals(2, module3Augmentations.size());
+        Set<AugmentationSchema> module3Augmentations = module3.getAugmentations();
+        assertEquals(3, module3Augmentations.size());
         AugmentationSchema augment3 = null;
         for (AugmentationSchema as : module3Augmentations) {
             if ("if:ifType='ds0'".equals(as.getWhenCondition().toString())) {
@@ -314,12 +295,9 @@ public class YangParserTest {
     public void testAugmentTarget() {
         Module test = TestUtils.findModule(modules, "types2");
 
-        ContainerSchemaNode interfaces = (ContainerSchemaNode) test
-                .getDataChildByName("interfaces");
-        ListSchemaNode ifEntry = (ListSchemaNode) interfaces
-                .getDataChildByName("ifEntry");
-        Set<AugmentationSchema> augmentations = ifEntry
-                .getAvailableAugmentations();
+        ContainerSchemaNode interfaces = (ContainerSchemaNode) test.getDataChildByName("interfaces");
+        ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
+        Set<AugmentationSchema> augmentations = ifEntry.getAvailableAugmentations();
         assertEquals(2, augmentations.size());
 
         AugmentationSchema augment = null;
@@ -328,29 +306,25 @@ public class YangParserTest {
                 augment = as;
             }
         }
-        ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment
-                .getDataChildByName("augment-holder");
+        ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment.getDataChildByName("augment-holder");
         assertNotNull(augmentHolder);
         assertTrue(augmentHolder.isAugmenting());
         QName augmentHolderQName = augmentHolder.getQName();
         assertEquals("augment-holder", augmentHolderQName.getLocalName());
         assertEquals("t3", augmentHolderQName.getPrefix());
-        assertEquals("Description for augment holder",
-                augmentHolder.getDescription());
+        assertEquals("Description for augment holder", augmentHolder.getDescription());
     }
 
     @Test
     public void testTypedefRangesResolving() throws ParseException {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("testleaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("testleaf");
         ExtendedType leafType = (ExtendedType) testleaf.getType();
         QName leafTypeQName = leafType.getQName();
         assertEquals("my-type1", leafTypeQName.getLocalName());
         assertEquals("t1", leafTypeQName.getPrefix());
-        assertEquals(URI.create("urn:simple.container.demo"),
-                leafTypeQName.getNamespace());
+        assertEquals(URI.create("urn:simple.container.demo"), leafTypeQName.getNamespace());
         Date expectedDate = simpleDateFormat.parse("2013-02-27");
         assertEquals(expectedDate, leafTypeQName.getRevision());
         assertEquals(1, leafType.getRanges().size());
@@ -359,15 +333,14 @@ public class YangParserTest {
         QName baseTypeQName = baseType.getQName();
         assertEquals("my-type1", baseTypeQName.getLocalName());
         assertEquals("t2", baseTypeQName.getPrefix());
-        assertEquals(URI.create("urn:simple.types.data.demo"),
-                baseTypeQName.getNamespace());
+        assertEquals(URI.create("urn:simple.types.data.demo"), baseTypeQName.getNamespace());
         assertEquals(expectedDate, baseTypeQName.getRevision());
         assertEquals(2, baseType.getRanges().size());
 
         List<RangeConstraint> ranges = leafType.getRanges();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
-        assertEquals(3L, range.getMin());
+        assertEquals(12L, range.getMin());
         assertEquals(20L, range.getMax());
     }
 
@@ -375,8 +348,7 @@ public class YangParserTest {
     public void testTypedefPatternsResolving() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("test-string-leaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("test-string-leaf");
         ExtendedType testleafType = (ExtendedType) testleaf.getType();
         QName testleafTypeQName = testleafType.getQName();
         assertEquals("my-string-type-ext", testleafTypeQName.getLocalName());
@@ -403,8 +375,7 @@ public class YangParserTest {
     public void testTypedefLengthsResolving() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("leaf-with-length");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("leaf-with-length");
         ExtendedType testleafType = (ExtendedType) testleaf.getType();
         assertEquals("my-string-type", testleafType.getQName().getLocalName());
 
@@ -420,8 +391,7 @@ public class YangParserTest {
     public void testTypeDef() {
         Module testModule = TestUtils.findModule(modules, "types2");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("nested-type-leaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("nested-type-leaf");
         ExtendedType testleafType = (ExtendedType) testleaf.getType();
         assertEquals("my-type1", testleafType.getQName().getLocalName());
 
@@ -430,8 +400,7 @@ public class YangParserTest {
 
         Int32 int32Type = (Int32) baseType.getBaseType();
         QName qname = int32Type.getQName();
-        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"),
-                qname.getNamespace());
+        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"), qname.getNamespace());
         assertNull(qname.getRevision());
         assertEquals("", qname.getPrefix());
         assertEquals("int32", qname.getLocalName());
@@ -446,8 +415,7 @@ public class YangParserTest {
     public void testTypedefDecimal1() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("test-decimal-leaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("test-decimal-leaf");
         ExtendedType type = (ExtendedType) testleaf.getType();
         assertEquals(4, (int) type.getFractionDigits());
 
@@ -463,8 +431,7 @@ public class YangParserTest {
     public void testTypedefDecimal2() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("test-decimal-leaf2");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("test-decimal-leaf2");
         TypeDefinition<?> baseType = testleaf.getType().getBaseType();
         assertTrue(testleaf.getType().getBaseType() instanceof Decimal64);
         Decimal64 baseTypeCast = (Decimal64) baseType;
@@ -475,8 +442,7 @@ public class YangParserTest {
     public void testTypedefUnion() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("union-leaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("union-leaf");
         ExtendedType testleafType = (ExtendedType) testleaf.getType();
         assertEquals("my-union-ext", testleafType.getQName().getLocalName());
 
@@ -501,8 +467,7 @@ public class YangParserTest {
     public void testNestedUnionResolving1() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("nested-union-leaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("nested-union-leaf");
 
         ExtendedType nestedUnion1 = (ExtendedType) testleaf.getType();
         assertEquals("nested-union1", nestedUnion1.getQName().getLocalName());
@@ -517,14 +482,11 @@ public class YangParserTest {
         assertTrue(unionTypes.get(1) instanceof ExtendedType);
 
         ExtendedType extendedUnion = (ExtendedType) unionTypes.get(1);
-        ExtendedType extendedUnionBase = (ExtendedType) extendedUnion
-                .getBaseType();
+        ExtendedType extendedUnionBase = (ExtendedType) extendedUnion.getBaseType();
         assertEquals("my-union", extendedUnionBase.getQName().getLocalName());
 
-        UnionType extendedTargetUnion = (UnionType) extendedUnionBase
-                .getBaseType();
-        List<TypeDefinition<?>> extendedTargetTypes = extendedTargetUnion
-                .getTypes();
+        UnionType extendedTargetUnion = (UnionType) extendedUnionBase.getBaseType();
+        List<TypeDefinition<?>> extendedTargetTypes = extendedTargetUnion.getTypes();
         assertTrue(extendedTargetTypes.get(0).getBaseType() instanceof Int16);
         assertTrue(extendedTargetTypes.get(1) instanceof Int32);
 
@@ -541,24 +503,19 @@ public class YangParserTest {
     public void testNestedUnionResolving2() {
         Module testModule = TestUtils.findModule(modules, "types1");
 
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule
-                .getDataChildByName("custom-union-leaf");
+        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("custom-union-leaf");
 
         ExtendedType testleafType = (ExtendedType) testleaf.getType();
         QName testleafTypeQName = testleafType.getQName();
-        assertEquals(URI.create("urn:simple.container.demo.test"),
-                testleafTypeQName.getNamespace());
-        assertEquals(TestUtils.createDate("2013-02-27"),
-                testleafTypeQName.getRevision());
+        assertEquals(URI.create("urn:simple.container.demo.test"), testleafTypeQName.getNamespace());
+        assertEquals(TestUtils.createDate("2013-02-27"), testleafTypeQName.getRevision());
         assertEquals("t3", testleafTypeQName.getPrefix());
         assertEquals("union1", testleafTypeQName.getLocalName());
 
         ExtendedType union2 = (ExtendedType) testleafType.getBaseType();
         QName union2QName = union2.getQName();
-        assertEquals(URI.create("urn:simple.container.demo.test"),
-                union2QName.getNamespace());
-        assertEquals(TestUtils.createDate("2013-02-27"),
-                union2QName.getRevision());
+        assertEquals(URI.create("urn:simple.container.demo.test"), union2QName.getNamespace());
+        assertEquals(TestUtils.createDate("2013-02-27"), union2QName.getRevision());
         assertEquals("t3", union2QName.getPrefix());
         assertEquals("union2", union2QName.getLocalName());
 
@@ -570,10 +527,8 @@ public class YangParserTest {
 
         ExtendedType nestedUnion2 = (ExtendedType) unionTypes.get(1);
         QName nestedUnion2QName = nestedUnion2.getQName();
-        assertEquals(URI.create("urn:simple.types.data.demo"),
-                nestedUnion2QName.getNamespace());
-        assertEquals(TestUtils.createDate("2013-02-27"),
-                nestedUnion2QName.getRevision());
+        assertEquals(URI.create("urn:simple.types.data.demo"), nestedUnion2QName.getNamespace());
+        assertEquals(TestUtils.createDate("2013-02-27"), nestedUnion2QName.getRevision());
         assertEquals("t2", nestedUnion2QName.getPrefix());
         assertEquals("nested-union2", nestedUnion2QName.getLocalName());
 
@@ -585,19 +540,15 @@ public class YangParserTest {
 
         ExtendedType myUnionExt = (ExtendedType) nestedUnion2Types.get(1);
         QName myUnionExtQName = myUnionExt.getQName();
-        assertEquals(URI.create("urn:simple.types.data.demo"),
-                myUnionExtQName.getNamespace());
-        assertEquals(TestUtils.createDate("2013-02-27"),
-                myUnionExtQName.getRevision());
+        assertEquals(URI.create("urn:simple.types.data.demo"), myUnionExtQName.getNamespace());
+        assertEquals(TestUtils.createDate("2013-02-27"), myUnionExtQName.getRevision());
         assertEquals("t2", myUnionExtQName.getPrefix());
         assertEquals("my-union-ext", myUnionExtQName.getLocalName());
 
         ExtendedType myUnion = (ExtendedType) myUnionExt.getBaseType();
         QName myUnionQName = myUnion.getQName();
-        assertEquals(URI.create("urn:simple.types.data.demo"),
-                myUnionQName.getNamespace());
-        assertEquals(TestUtils.createDate("2013-02-27"),
-                myUnionQName.getRevision());
+        assertEquals(URI.create("urn:simple.types.data.demo"), myUnionQName.getNamespace());
+        assertEquals(TestUtils.createDate("2013-02-27"), myUnionQName.getRevision());
         assertEquals("t2", myUnionQName.getPrefix());
         assertEquals("my-union", myUnionQName.getLocalName());
 
@@ -618,10 +569,8 @@ public class YangParserTest {
     public void testRefine() {
         Module testModule = TestUtils.findModule(modules, "types2");
 
-        ContainerSchemaNode peer = (ContainerSchemaNode) testModule
-                .getDataChildByName("peer");
-        ContainerSchemaNode destination = (ContainerSchemaNode) peer
-                .getDataChildByName("destination");
+        ContainerSchemaNode peer = (ContainerSchemaNode) testModule.getDataChildByName("peer");
+        ContainerSchemaNode destination = (ContainerSchemaNode) peer.getDataChildByName("destination");
         Set<UsesNode> usesNodes = destination.getUses();
         assertEquals(1, usesNodes.size());
         UsesNode usesNode = usesNodes.iterator().next();
@@ -651,53 +600,39 @@ public class YangParserTest {
         // leaf address
         assertNotNull(refineLeaf);
         assertEquals("address", refineLeaf.getQName().getLocalName());
-        assertEquals("description of address defined by refine",
-                refineLeaf.getDescription());
-        assertEquals("address reference added by refine",
-                refineLeaf.getReference());
+        assertEquals("description of address defined by refine", refineLeaf.getDescription());
+        assertEquals("address reference added by refine", refineLeaf.getReference());
         assertFalse(refineLeaf.isConfiguration());
         assertTrue(refineLeaf.getConstraints().isMandatory());
-        Set<MustDefinition> leafMustConstraints = refineLeaf.getConstraints()
-                .getMustConstraints();
+        Set<MustDefinition> leafMustConstraints = refineLeaf.getConstraints().getMustConstraints();
         assertEquals(1, leafMustConstraints.size());
         MustDefinition leafMust = leafMustConstraints.iterator().next();
-        assertEquals(
-                "\"ifType != 'ethernet' or (ifType = 'ethernet' and ifMTU = 1500)\"",
-                leafMust.toString());
+        assertEquals("\"ifType != 'ethernet' or (ifType = 'ethernet' and ifMTU = 1500)\"", leafMust.toString());
 
         // container port
         assertNotNull(refineContainer);
-        Set<MustDefinition> mustConstraints = refineContainer.getConstraints()
-                .getMustConstraints();
+        Set<MustDefinition> mustConstraints = refineContainer.getConstraints().getMustConstraints();
         assertTrue(mustConstraints.isEmpty());
-        assertEquals("description of port defined by refine",
-                refineContainer.getDescription());
-        assertEquals("port reference added by refine",
-                refineContainer.getReference());
+        assertEquals("description of port defined by refine", refineContainer.getDescription());
+        assertEquals("port reference added by refine", refineContainer.getReference());
         assertFalse(refineContainer.isConfiguration());
         assertTrue(refineContainer.isPresenceContainer());
 
         // list addresses
         assertNotNull(refineList);
-        assertEquals("description of addresses defined by refine",
-                refineList.getDescription());
-        assertEquals("addresses reference added by refine",
-                refineList.getReference());
+        assertEquals("description of addresses defined by refine", refineList.getDescription());
+        assertEquals("addresses reference added by refine", refineList.getReference());
         assertFalse(refineList.isConfiguration());
         assertEquals(2, (int) refineList.getConstraints().getMinElements());
         assertEquals(12, (int) refineList.getConstraints().getMaxElements());
 
         // grouping target-inner
         assertNotNull(refineGrouping);
-        Set<DataSchemaNode> refineGroupingChildren = refineGrouping
-                .getChildNodes();
+        Set<DataSchemaNode> refineGroupingChildren = refineGrouping.getChildNodes();
         assertEquals(1, refineGroupingChildren.size());
-        LeafSchemaNode refineGroupingLeaf = (LeafSchemaNode) refineGroupingChildren
-                .iterator().next();
-        assertEquals("inner-grouping-id", refineGroupingLeaf.getQName()
-                .getLocalName());
-        assertEquals("new target-inner grouping description",
-                refineGrouping.getDescription());
+        LeafSchemaNode refineGroupingLeaf = (LeafSchemaNode) refineGroupingChildren.iterator().next();
+        assertEquals("inner-grouping-id", refineGroupingLeaf.getQName().getLocalName());
+        assertEquals("new target-inner grouping description", refineGrouping.getDescription());
 
         // typedef group-type
         assertNotNull(typedef);
@@ -709,8 +644,7 @@ public class YangParserTest {
     @Test
     public void testChoice() {
         Module testModule = TestUtils.findModule(modules, "types1");
-        ContainerSchemaNode peer = (ContainerSchemaNode) testModule
-                .getDataChildByName("transfer");
+        ContainerSchemaNode peer = (ContainerSchemaNode) testModule.getDataChildByName("transfer");
         ChoiceNode how = (ChoiceNode) peer.getDataChildByName("how");
         Set<ChoiceCaseNode> cases = how.getCases();
         assertEquals(3, cases.size());
@@ -719,8 +653,7 @@ public class YangParserTest {
     @Test
     public void testAnyXml() {
         Module testModule = TestUtils.findModule(modules, "types1");
-        AnyXmlSchemaNode data = (AnyXmlSchemaNode) testModule
-                .getDataChildByName("data");
+        AnyXmlSchemaNode data = (AnyXmlSchemaNode) testModule.getDataChildByName("data");
         assertNotNull(data);
     }
 
@@ -731,8 +664,7 @@ public class YangParserTest {
         assertEquals(1, deviations.size());
 
         Deviation dev = deviations.iterator().next();
-        SchemaPath expectedPath = TestUtils.createPath(true, null, null,
-                "data", "system", "user");
+        SchemaPath expectedPath = TestUtils.createPath(true, null, null, "data", "system", "user");
         assertEquals(expectedPath, dev.getTargetPath());
         assertEquals(Deviate.ADD, dev.getDeviate());
     }
@@ -740,8 +672,7 @@ public class YangParserTest {
     @Test
     public void testUnknownNode() {
         Module testModule = TestUtils.findModule(modules, "types3");
-        ContainerSchemaNode network = (ContainerSchemaNode) testModule
-                .getDataChildByName("network");
+        ContainerSchemaNode network = (ContainerSchemaNode) testModule.getDataChildByName("network");
         List<UnknownSchemaNode> unknownNodes = network.getUnknownSchemaNodes();
         assertEquals(1, unknownNodes.size());
         UnknownSchemaNode unknownNode = unknownNodes.get(0);
@@ -759,8 +690,7 @@ public class YangParserTest {
     @Test
     public void testExtension() {
         Module testModule = TestUtils.findModule(modules, "types3");
-        List<ExtensionDefinition> extensions = testModule
-                .getExtensionSchemaNodes();
+        List<ExtensionDefinition> extensions = testModule.getExtensionSchemaNodes();
         assertEquals(1, extensions.size());
         ExtensionDefinition extension = extensions.get(0);
         assertEquals("name", extension.getArgument());
@@ -774,17 +704,15 @@ public class YangParserTest {
         String expectedPrefix = "t3";
         Date expectedRevision = TestUtils.createDate("2013-02-27");
 
-        Set<NotificationDefinition> notifications = testModule
-                .getNotifications();
+        Set<NotificationDefinition> notifications = testModule.getNotifications();
         assertEquals(1, notifications.size());
 
         NotificationDefinition notification = notifications.iterator().next();
         // test SchemaNode args
-        QName expectedQName = new QName(expectedNamespace, expectedRevision,
-                expectedPrefix, "event");
+        QName expectedQName = new QName(expectedNamespace, expectedRevision, expectedPrefix, "event");
         assertEquals(expectedQName, notification.getQName());
-        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace,
-                expectedRevision, expectedPrefix, "event");
+        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, expectedRevision, expectedPrefix,
+                "event");
         assertEquals(expectedPath, notification.getPath());
         assertNull(notification.getDescription());
         assertNull(notification.getReference());
@@ -796,14 +724,11 @@ public class YangParserTest {
         assertEquals(0, notification.getGroupings().size());
         assertEquals(0, notification.getUses().size());
 
-        LeafSchemaNode eventClass = (LeafSchemaNode) notification
-                .getDataChildByName("event-class");
+        LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName("event-class");
         assertTrue(eventClass.getType() instanceof StringType);
-        AnyXmlSchemaNode reportingEntity = (AnyXmlSchemaNode) notification
-                .getDataChildByName("reporting-entity");
+        AnyXmlSchemaNode reportingEntity = (AnyXmlSchemaNode) notification.getDataChildByName("reporting-entity");
         assertNotNull(reportingEntity);
-        LeafSchemaNode severity = (LeafSchemaNode) notification
-                .getDataChildByName("severity");
+        LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName("severity");
         assertTrue(severity.getType() instanceof StringType);
     }
 
@@ -815,8 +740,7 @@ public class YangParserTest {
         assertEquals(1, rpcs.size());
 
         RpcDefinition rpc = rpcs.iterator().next();
-        assertEquals("Retrieve all or part of a specified configuration.",
-                rpc.getDescription());
+        assertEquals("Retrieve all or part of a specified configuration.", rpc.getDescription());
         assertEquals("RFC 6241, Section 7.1", rpc.getReference());
 
         ContainerSchemaNode input = rpc.getInput();
@@ -843,49 +767,41 @@ public class YangParserTest {
         assertEquals(1, augments.size());
         AugmentationSchema augment = augments.iterator().next();
 
-        LeafSchemaNode ifcId = (LeafSchemaNode) augment
-                .getDataChildByName("interface-id");
+        LeafSchemaNode ifcId = (LeafSchemaNode) augment.getDataChildByName("interface-id");
         Leafref ifcIdType = (Leafref) ifcId.getType();
         SchemaPath ifcIdTypeSchemaPath = ifcIdType.getPath();
         List<QName> ifcIdTypePath = ifcIdTypeSchemaPath.getPath();
-        
+
         URI types1URI = URI.create("urn:simple.container.demo");
         URI types2URI = URI.create("urn:simple.types.data.demo");
         URI types3URI = URI.create("urn:simple.container.demo.test");
         Date expectedDate = simpleDateFormat.parse("2013-02-27");
-        
-        QName q0 = new QName(types2URI,
-                expectedDate, "data", "interfaces");
-        QName q1 = new QName(types2URI,
-                expectedDate, "data", "ifEntry");
-        QName q2 = new QName(types3URI,
-                expectedDate, "data", "augment-holder");
-        QName q3 = new QName(types1URI,
-                expectedDate, "data", "interface-id");
+
+        QName q0 = new QName(types2URI, expectedDate, "data", "interfaces");
+        QName q1 = new QName(types2URI, expectedDate, "data", "ifEntry");
+        QName q2 = new QName(types3URI, expectedDate, "data", "augment-holder");
+        QName q3 = new QName(types1URI, expectedDate, "data", "interface-id");
         assertEquals(q0, ifcIdTypePath.get(0));
         assertEquals(q1, ifcIdTypePath.get(1));
         assertEquals(q2, ifcIdTypePath.get(2));
         assertEquals(q3, ifcIdTypePath.get(3));
 
-        LeafListSchemaNode higherLayer = (LeafListSchemaNode) augment
-                .getDataChildByName("higher-layer-if");
+        LeafListSchemaNode higherLayer = (LeafListSchemaNode) augment.getDataChildByName("higher-layer-if");
         Leafref higherLayerType = (Leafref) higherLayer.getType();
         SchemaPath higherLayerTypeSchemaPath = higherLayerType.getPath();
         List<QName> higherLayerTypePath = higherLayerTypeSchemaPath.getPath();
         assertEquals(q0, higherLayerTypePath.get(0));
         assertEquals(q1, higherLayerTypePath.get(1));
         assertEquals(q2, higherLayerTypePath.get(2));
-        q3 = new QName(types1URI,
-                expectedDate, "data", "higher-layer-if");
+        q3 = new QName(types1URI, expectedDate, "data", "higher-layer-if");
         assertEquals(q3, higherLayerTypePath.get(3));
-        
-        LeafSchemaNode myType = (LeafSchemaNode) augment
-                .getDataChildByName("my-type");
-        ExtendedType leafType = (ExtendedType)myType.getType();
-        
+
+        LeafSchemaNode myType = (LeafSchemaNode) augment.getDataChildByName("my-type");
+        ExtendedType leafType = (ExtendedType) myType.getType();
+
         testModule = TestUtils.findModule(modules, "types2");
         TypeDefinition<?> typedef = TestUtils.findTypedef(testModule.getTypeDefinitions(), "my-type1");
-        
+
         assertEquals(typedef, leafType);
     }
 
@@ -895,8 +811,7 @@ public class YangParserTest {
         Set<TypeDefinition<?>> types = test.getTypeDefinitions();
 
         // my-base-int32-type
-        ExtendedType int32Typedef = (ExtendedType) TestUtils.findTypedef(types,
-                "my-base-int32-type");
+        ExtendedType int32Typedef = (ExtendedType) TestUtils.findTypedef(types, "my-base-int32-type");
         QName int32TypedefQName = int32Typedef.getQName();
 
         URI expectedNS = URI.create("urn:simple.types.data.demo");
@@ -914,8 +829,7 @@ public class YangParserTest {
         // my-base-int32-type/int32
         Int32 int32 = (Int32) int32Typedef.getBaseType();
         QName int32QName = int32.getQName();
-        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"),
-                int32QName.getNamespace());
+        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"), int32QName.getNamespace());
         assertNull(int32QName.getRevision());
         assertEquals("", int32QName.getPrefix());
         assertEquals("int32", int32QName.getLocalName());
@@ -933,8 +847,7 @@ public class YangParserTest {
         Set<TypeDefinition<?>> types = test.getTypeDefinitions();
 
         // my-base-int32-type
-        ExtendedType myDecType = (ExtendedType) TestUtils.findTypedef(types,
-                "my-decimal-type");
+        ExtendedType myDecType = (ExtendedType) TestUtils.findTypedef(types, "my-decimal-type");
         QName myDecTypeQName = myDecType.getQName();
 
         URI expectedNS = URI.create("urn:simple.types.data.demo");
@@ -953,8 +866,7 @@ public class YangParserTest {
         Decimal64 dec64 = (Decimal64) myDecType.getBaseType();
         QName dec64QName = dec64.getQName();
 
-        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"),
-                dec64QName.getNamespace());
+        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"), dec64QName.getNamespace());
         assertNull(dec64QName.getRevision());
         assertEquals("", dec64QName.getPrefix());
         assertEquals("decimal64", dec64QName.getLocalName());
index 3dbfa78..f6bc34d 100644 (file)
@@ -22,7 +22,7 @@ module types1 {
 
     leaf testleaf {
         type data:my-type1 {
-            range "min..max";
+            range "12..max";
         }
     }
 
@@ -126,6 +126,8 @@ module types1 {
         leaf my-type {
             type data:my-type1;
         }
+        container schemas {
+        }
     }
     
     container mycont {
index 7aadc9a..495653c 100644 (file)
@@ -39,6 +39,13 @@ module types3 {
             description "Description for augment holder";
         }
     }
+    
+    augment "/data:interfaces/data:ifEntry/t3:augment-holder/t1:schemas" {
+        when "if:leafType='ds1'";
+        leaf linkleaf {
+            type binary;
+        }
+    }
 
     container network {
         mnt:mountpoint point {
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/negative-scenario/testfile5.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/negative-scenario/testfile5.yang
new file mode 100644 (file)
index 0000000..0d8de38
--- /dev/null
@@ -0,0 +1,19 @@
+module test5 {
+    yang-version 1;
+    namespace "urn:simple.container.demo";
+    prefix "t1";
+
+    typedef my-custom-string {
+        type string {
+            pattern "[a-k]*";
+            length "5..11";
+        }
+    }
+
+    typedef my-string-type {
+        type my-custom-string {
+            length "4..10";
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/negative-scenario/testfile6.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/negative-scenario/testfile6.yang
new file mode 100644 (file)
index 0000000..31a4c1e
--- /dev/null
@@ -0,0 +1,18 @@
+module test5 {
+    yang-version 1;
+    namespace "urn:simple.container.demo";
+    prefix "t1";
+
+    typedef my-custom-int {
+        type int32 {
+            range "5..11 | 15..20";
+        }
+    }
+
+    typedef my-int-type {
+        type my-custom-int {
+            range "min..max";
+        }
+    }
+
+}
index 6d5b5be..79b211f 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * 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,10 +28,10 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * <li>uint64 - represents integer values between 0 and 18446744073709551615,
  * inclusively.</li>
  * </ul>
- *
+ * 
  */
-public abstract class AbstractUnsignedInteger implements
-        UnsignedIntegerTypeDefinition {
+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;
@@ -40,28 +40,25 @@ public abstract class AbstractUnsignedInteger implements
     private final List<RangeConstraint> rangeStatements;
 
     /**
-     *
+     * 
      * @param actualPath
      * @param namespace
      * @param revision
      * @param name
      * @param description
-     * @param minRange
+     * @param MIN_VALUE
      * @param maxRange
      * @param units
      */
-    public AbstractUnsignedInteger(final SchemaPath path, final QName name,
-            final String description, final Number minRange,
+    public AbstractUnsignedInteger(final SchemaPath path, final QName name, final String description,
             final Number maxRange, final String units) {
         this.name = name;
         this.description = description;
         this.path = path;
         this.units = units;
         this.rangeStatements = new ArrayList<RangeConstraint>();
-        final String rangeDescription = "Integer values between " + minRange
-                + " and " + maxRange + ", inclusively.";
-        this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
-                maxRange, rangeDescription,
+        final String rangeDescription = "Integer values between " + MIN_VALUE + " and " + maxRange + ", inclusively.";
+        this.rangeStatements.add(BaseConstraints.rangeConstraint(MIN_VALUE, maxRange, rangeDescription,
                 "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
     }
 
@@ -71,8 +68,7 @@ public abstract class AbstractUnsignedInteger implements
      * @param rangeStatements
      * @param units
      */
-    public AbstractUnsignedInteger(final SchemaPath path, final QName name,
-            final String description,
+    public AbstractUnsignedInteger(final SchemaPath path, final QName name, final String description,
             final List<RangeConstraint> rangeStatements, final String units) {
         this.name = name;
         this.description = description;
@@ -125,14 +121,11 @@ public abstract class AbstractUnsignedInteger implements
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
+        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
-                + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.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;
     }
index 79ae467..6cae33b 100644 (file)
@@ -18,13 +18,14 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  */
 public final class Uint16 extends AbstractUnsignedInteger {
+    public static final int MAX_VALUE = 65535;
     private static final QName name = BaseTypes.constructQName("uint16");
     private Integer defaultValue = null;
     private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
     public Uint16(final SchemaPath path) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+        super(path, name, description, MAX_VALUE, "");
         this.baseType = this;
     }
 
@@ -55,8 +56,7 @@ public final class Uint16 extends AbstractUnsignedInteger {
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
         return result;
     }
 
@@ -92,4 +92,5 @@ public final class Uint16 extends AbstractUnsignedInteger {
         builder.append("]");
         return builder.toString();
     }
+
 }
index fddf0c4..2a06a60 100644 (file)
@@ -13,18 +13,18 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
 
 /**
  * Implementation of Yang uint32 built-in type. <br>
- * uint32 represents integer values between 0 and 4294967295, inclusively. The
- * Java counterpart of Yang uint32 built-in type is {@link Long}.
+ * uint32 represents integer values between 0 and 4294967295, inclusively.
  *
  */
 public final class Uint32 extends AbstractUnsignedInteger {
+    public static final long MAX_VALUE = 4294967295L;
     private static final QName name = BaseTypes.constructQName("uint32");
     private final Long defaultValue = null;
     private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
     public Uint32(final SchemaPath path) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+        super(path, name, description, MAX_VALUE, "");
         this.baseType = this;
     }
 
@@ -55,8 +55,7 @@ public final class Uint32 extends AbstractUnsignedInteger {
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
         return result;
     }
 
@@ -92,4 +91,5 @@ public final class Uint32 extends AbstractUnsignedInteger {
         builder.append("]");
         return builder.toString();
     }
+
 }
index 9252c08..e95a623 100644 (file)
@@ -21,13 +21,14 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  */
 public final class Uint64 extends AbstractUnsignedInteger {
+    public static final BigInteger MAX_VALUE = new BigInteger("18446744073709551615");
     private static final QName name = BaseTypes.constructQName("uint64");
     private final BigInteger defaultValue = null;
     private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
     public Uint64(final SchemaPath path) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+        super(path, name, description, MAX_VALUE, "");
         this.baseType = this;
     }
 
@@ -58,8 +59,7 @@ public final class Uint64 extends AbstractUnsignedInteger {
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
         return result;
     }
 
@@ -95,4 +95,5 @@ public final class Uint64 extends AbstractUnsignedInteger {
         builder.append("]");
         return builder.toString();
     }
+
 }
index fa9d35e..85e7aab 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.controller.yang.model.util;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -12,30 +12,28 @@ import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
- * Implementation of Yang uint8 built-in type.
- * <br>
- * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
- * Yang uint8 built-in type is {@link Short}.
+ * 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 final QName name = BaseTypes.constructQName("uint8");
     private final Short defaultValue = null;
-    private static final String description =
-            "uint8  represents integer values between 0 and 255, inclusively.";
+    private static final String description = "uint8  represents integer values between 0 and 255, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
     public Uint8(final SchemaPath path) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+        super(path, name, description, MAX_VALUE, "");
         this.baseType = this;
     }
 
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public UnsignedIntegerTypeDefinition getBaseType() {
@@ -45,7 +43,9 @@ public final class Uint8 extends AbstractUnsignedInteger {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -56,8 +56,7 @@ public final class Uint8 extends AbstractUnsignedInteger {
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
         return result;
     }
 
@@ -93,4 +92,5 @@ public final class Uint8 extends AbstractUnsignedInteger {
         builder.append("]");
         return builder.toString();
     }
+
 }