Sonar issues clean-up 45/18745/5
authorGregor Zatko <gzatko@cisco.com>
Wed, 22 Apr 2015 13:56:11 +0000 (15:56 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 22 Apr 2015 15:52:46 +0000 (17:52 +0200)
Change-Id: I9267a5e8dc8347f04a04977043b558369e35670b
Signed-off-by: Gregor Zatko <gzatko@cisco.com>
59 files changed:
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/SchemaNodeIdentifier.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaResolutionException.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaSourceFilter.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SourceIdentifier.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/BuilderUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/CopyUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/GroupingUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/RpcDefinitionBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/TypeUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/BasicValidations.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserListenerImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/URLSchemaContextResolver.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactory.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/NamespaceBehaviour.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementSupportBundle.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ModifierImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementDefinitionContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/CaseStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PrefixStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SubmoduleStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UsesStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedDataNodeContainer.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveSchemaContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AnyXmlEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AugmentEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ChoiceEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtensionEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IdentityEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafListEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ListEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NotificationEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OutputEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RpcEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TopologicalSort.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/builder/impl/BuilderUtilsTest.java

index 985a7cdd7d61184e10e6e7825a87acd3628b933b..cc8f6feebd684e317a80085ad86822a431b97d8b 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.yangtools.yang.common.QName;
  * Represents unique path to the every node inside the module.
  */
 public abstract class SchemaPath implements Immutable {
+
     /**
      * An absolute SchemaPath.
      */
@@ -97,6 +98,18 @@ public abstract class SchemaPath implements Immutable {
      */
     private volatile ImmutableList<QName> legacyPath;
 
+    protected SchemaPath(final SchemaPath parent, final QName qname) {
+        this.parent = parent;
+        this.qname = qname;
+
+        int h = parent == null ? 0 : parent.hashCode();
+        if (qname != null) {
+            h = h * 31 + qname.hashCode();
+        }
+
+        hash = h;
+    }
+
     private ImmutableList<QName> getLegacyPath() {
         ImmutableList<QName> ret = legacyPath;
         if (ret == null) {
@@ -120,18 +133,6 @@ public abstract class SchemaPath implements Immutable {
         return getLegacyPath();
     }
 
-    protected SchemaPath(final SchemaPath parent, final QName qname) {
-        this.parent = parent;
-        this.qname = qname;
-
-        int h = parent == null ? 0 : parent.hashCode();
-        if (qname != null) {
-            h = h * 31 + qname.hashCode();
-        }
-
-        hash = h;
-    }
-
     /**
      * Constructs new instance of this class with the concrete path.
      *
@@ -185,12 +186,12 @@ public abstract class SchemaPath implements Immutable {
             return this;
         }
 
-        SchemaPath parent = this;
+        SchemaPath parentPath = this;
         for (QName qname : relative) {
-            parent = parent.createInstance(parent, qname);
+            parentPath = parentPath.createInstance(parentPath, qname);
         }
 
-        return parent;
+        return parentPath;
     }
 
     /**
@@ -202,12 +203,12 @@ public abstract class SchemaPath implements Immutable {
     public SchemaPath createChild(final SchemaPath relative) {
         Preconditions.checkArgument(!relative.isAbsolute(), "Child creation requires relative path");
 
-        SchemaPath parent = this;
+        SchemaPath parentPath = this;
         for (QName qname : relative.getPathFromRoot()) {
-            parent = parent.createInstance(parent, qname);
+            parentPath = parentPath.createInstance(parentPath, qname);
         }
 
-        return parent;
+        return parentPath;
     }
 
     /**
index bacf0c41cccf85070460ae24994160a4cea0497f..77c36f1b8e6f4ef28084fa9b54db9090a99375e1 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.yangtools.yang.common.QName;
  *
  */
 public abstract class SchemaNodeIdentifier implements Immutable {
+
     /**
      * An absolute schema node identifier.
      */
@@ -99,6 +100,18 @@ public abstract class SchemaNodeIdentifier implements Immutable {
      */
     private volatile ImmutableList<QName> legacyPath;
 
+    protected SchemaNodeIdentifier(final SchemaNodeIdentifier parent, final QName qname) {
+        this.parent = parent;
+        this.qname = qname;
+
+        int h = parent == null ? 0 : parent.hashCode();
+        if (qname != null) {
+            h = h * 31 + qname.hashCode();
+        }
+
+        hash = h;
+    }
+
     private ImmutableList<QName> getLegacyPath() {
         ImmutableList<QName> ret = legacyPath;
         if (ret == null) {
@@ -122,18 +135,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
         return getLegacyPath();
     }
 
-    protected SchemaNodeIdentifier(final SchemaNodeIdentifier parent, final QName qname) {
-        this.parent = parent;
-        this.qname = qname;
-
-        int h = parent == null ? 0 : parent.hashCode();
-        if (qname != null) {
-            h = h * 31 + qname.hashCode();
-        }
-
-        hash = h;
-    }
-
     /**
      * Constructs new instance of this class with the concrete path.
      *
@@ -187,12 +188,12 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return this;
         }
 
-        SchemaNodeIdentifier parent = this;
+        SchemaNodeIdentifier parentNode = this;
         for (QName qname : relative) {
-            parent = parent.createInstance(parent, qname);
+            parentNode = parentNode.createInstance(parentNode, qname);
         }
 
-        return parent;
+        return parentNode;
     }
 
     /**
@@ -204,12 +205,12 @@ public abstract class SchemaNodeIdentifier implements Immutable {
     public SchemaNodeIdentifier createChild(final SchemaNodeIdentifier relative) {
         Preconditions.checkArgument(!relative.isAbsolute(), "Child creation requires relative path");
 
-        SchemaNodeIdentifier parent = this;
+        SchemaNodeIdentifier parentNode = this;
         for (QName qname : relative.getPathFromRoot()) {
-            parent = parent.createInstance(parent, qname);
+            parentNode = parentNode.createInstance(parentNode, qname);
         }
 
-        return parent;
+        return parentNode;
     }
 
     /**
index 0070cab71fe3d7bcf734060e9bfc4d6e63351d50..9f5e22bc9f9e22c827e51924ff8ae1a00f7de54b 100644 (file)
@@ -23,6 +23,9 @@ import org.opendaylight.yangtools.yang.model.api.ModuleImport;
  */
 @Beta
 public class SchemaResolutionException extends SchemaSourceException {
+
+    private static final String MESSAGE_BLUEPRINT = "%s, resolved sources: %s, unsatisfied imports: %s";
+
     private static final long serialVersionUID = 1L;
     private final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports;
     private final Collection<SourceIdentifier> resolvedSources;
@@ -48,7 +51,6 @@ public class SchemaResolutionException extends SchemaSourceException {
         this.resolvedSources = ImmutableList.copyOf(resolvedSources);
     }
 
-    private static final String MESSAGE_BLUEPRINT = "%s, resolved sources: %s, unsatisfied imports: %s";
     private static String formatMessage(final String message, final Collection<SourceIdentifier> resolvedSources, final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
         return String.format(MESSAGE_BLUEPRINT, message, resolvedSources, unsatisfiedImports);
     }
index 6da4ee301263ffbcb72c5200fdea0b54ee87c3da..85b26a52d4ba4b3bc334971a406914d15d673767 100644 (file)
@@ -24,12 +24,12 @@ public interface SchemaSourceFilter {
      * A {@link SchemaSourceFilter} which accepts any schema source it is presented with.
      */
     public static final SchemaSourceFilter ALWAYS_ACCEPT = new SchemaSourceFilter() {
-        private final Iterable<Class<? extends SchemaSourceRepresentation>> REPRESENTATIONS =
+        private final Iterable<Class<? extends SchemaSourceRepresentation>> Representations =
                 Collections.<Class<? extends SchemaSourceRepresentation>>singletonList(SchemaSourceRepresentation.class);
 
         @Override
         public Iterable<Class<? extends SchemaSourceRepresentation>> supportedRepresentations() {
-            return REPRESENTATIONS;
+            return Representations;
         }
 
         @Override
index f46ed3f426553be6f37a5a94e72b7d96b965c24c..0b74d4b63fbbe0549136c1e51ac805186457479f 100644 (file)
@@ -56,12 +56,22 @@ public final class SourceIdentifier implements Identifier, Immutable {
      */
     public static final Pattern REVISION_PATTERN = Pattern.compile("\\d\\d\\d\\d-\\d\\d-\\d\\d");
 
-
     private static final ObjectCache CACHE = ObjectCacheFactory.getObjectCache(SourceIdentifier.class);
     private static final long serialVersionUID = 1L;
     private final String revision;
     private final String name;
 
+    /**
+     *
+     * Creates new YANG Schema source identifier for sources without revision.
+     * {@link SourceIdentifier#NOT_PRESENT_FORMATTED_REVISION} as default revision.
+     *
+     * @param name Name of schema
+     */
+    public SourceIdentifier(final String name) {
+        this(name, NOT_PRESENT_FORMATTED_REVISION);
+    }
+
     /**
      * Creates new YANG Schema source identifier.
      *
@@ -93,17 +103,6 @@ public final class SourceIdentifier implements Identifier, Immutable {
         return CACHE.getReference(this);
     }
 
-    /**
-     *
-     * Creates new YANG Schema source identifier for sources without revision.
-     * {@link SourceIdentifier#NOT_PRESENT_FORMATTED_REVISION} as default revision.
-     *
-     * @param name Name of schema
-     */
-    public SourceIdentifier(final String name) {
-        this(name, NOT_PRESENT_FORMATTED_REVISION);
-    }
-
     /**
      * Returns model name
      *
index 975b683dd64e93e6aa962069a9c4c2eeb0838747..e98553e8009013e5b4f5c2bc2c60123fdd147630 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.NavigableMap;
 import java.util.Set;
 import java.util.TreeMap;
 import org.antlr.v4.runtime.tree.ParseTree;
@@ -83,6 +84,7 @@ public final class BuilderUtils {
     private static final Date NULL_DATE = new Date(0L);
     private static final String INPUT = "input";
     private static final String OUTPUT = "output";
+    private static final String CHILD_NOT_FOUND_IN_NODE_STR = "Child {} not found in node {}";
 
     private BuilderUtils() {
     }
@@ -148,7 +150,7 @@ public final class BuilderUtils {
      *            current line in yang model
      * @return module builder if found, null otherwise
      */
-    public static ModuleBuilder findModuleFromBuilders(final Map<String, TreeMap<Date, ModuleBuilder>> modules,
+    public static ModuleBuilder findModuleFromBuilders(final Map<String, NavigableMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder module, final String prefix, final int line) {
         ModuleBuilder dependentModule;
         Date dependentModuleRevision;
@@ -165,7 +167,7 @@ public final class BuilderUtils {
             String dependentModuleName = dependentModuleImport.getModuleName();
             dependentModuleRevision = dependentModuleImport.getRevision();
 
-            TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules.get(dependentModuleName);
+            NavigableMap<Date, ModuleBuilder> moduleBuildersByRevision = modules.get(dependentModuleName);
             if (moduleBuildersByRevision == null) {
                 return null;
             }
@@ -181,12 +183,10 @@ public final class BuilderUtils {
     public static ModuleBuilder findModuleFromBuilders(ModuleImport imp, Iterable<ModuleBuilder> modules) {
         String name = imp.getModuleName();
         Date revision = imp.getRevision();
-        TreeMap<Date, ModuleBuilder> map = new TreeMap<>();
+        NavigableMap<Date, ModuleBuilder> map = new TreeMap<>();
         for (ModuleBuilder module : modules) {
-            if (module != null) {
-                if (module.getName().equals(name)) {
-                    map.put(module.getRevision(), module);
-                }
+            if (module != null && module.getName().equals(name)) {
+                map.put(module.getRevision(), module);
             }
         }
         if (map.isEmpty()) {
@@ -216,7 +216,7 @@ public final class BuilderUtils {
      */
     public static Module findModuleFromContext(final SchemaContext context, final ModuleBuilder currentModule,
             final String prefix, final int line) {
-        TreeMap<Date, Module> modulesByRevision = new TreeMap<>();
+        NavigableMap<Date, Module> modulesByRevision = new TreeMap<>();
 
         ModuleImport dependentModuleImport = currentModule.getImport(prefix);
         if (dependentModuleImport == null) {
@@ -378,9 +378,9 @@ public final class BuilderUtils {
                     node = findUnknownNode(name, parent);
                 }
             } else if (parent instanceof RpcDefinitionBuilder) {
-                if ("input".equals(name)) {
+                if (INPUT.equals(name)) {
                     node = ((RpcDefinitionBuilder) parent).getInput();
-                } else if ("output".equals(name)) {
+                } else if (OUTPUT.equals(name)) {
                     node = ((RpcDefinitionBuilder) parent).getOutput();
                 } else {
                     if (node == null) {
@@ -457,9 +457,8 @@ public final class BuilderUtils {
             return castOptional(SchemaNodeBuilder.class, findCaseInChoice((ChoiceBuilder) parent, child));
         } else if (parent instanceof RpcDefinitionBuilder) {
             return castOptional(SchemaNodeBuilder.class, findContainerInRpc((RpcDefinitionBuilder) parent, child));
-
         } else {
-            LOG.trace("Child {} not found in node {}", child, parent);
+            LOG.trace(CHILD_NOT_FOUND_IN_NODE_STR, child, parent);
             return Optional.absent();
         }
     }
@@ -504,7 +503,7 @@ public final class BuilderUtils {
             final QName child) {
         if (INPUT.equals(child.getLocalName())) {
             if (parent.getInput() == null) {
-                QName qname = QName.create(parent.getQName().getModule(), "input");
+                QName qname = QName.create(parent.getQName().getModule(), INPUT);
                 final ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(parent.getModuleName(),
                         parent.getLine(), qname, parent.getPath().createChild(qname));
                 inputBuilder.setParent(parent);
@@ -514,7 +513,7 @@ public final class BuilderUtils {
             return Optional.of(parent.getInput());
         } else if (OUTPUT.equals(child.getLocalName())) {
             if (parent.getOutput() == null) {
-                QName qname = QName.create(parent.getQName().getModule(), "output");
+                QName qname = QName.create(parent.getQName().getModule(), OUTPUT);
                 final ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(parent.getModuleName(),
                         parent.getLine(), qname, parent.getPath().createChild(qname));
                 outputBuilder.setParent(parent);
@@ -523,7 +522,7 @@ public final class BuilderUtils {
             }
             return Optional.of(parent.getOutput());
         }
-        LOG.trace("Child {} not found in node {}", child, parent);
+        LOG.trace(CHILD_NOT_FOUND_IN_NODE_STR, child, parent);
         return Optional.absent();
     }
 
@@ -544,7 +543,7 @@ public final class BuilderUtils {
                 return Optional.of(caze);
             }
         }
-        LOG.trace("Child {} not found in node {}", child, parent);
+        LOG.trace(CHILD_NOT_FOUND_IN_NODE_STR, child, parent);
         return Optional.absent();
     }
 
@@ -565,7 +564,7 @@ public final class BuilderUtils {
                 return Optional.of(childNode);
             }
         }
-        LOG.trace("Child {} not found in node {}", child, parent);
+        LOG.trace(CHILD_NOT_FOUND_IN_NODE_STR, child, parent);
         return Optional.absent();
     }
 
@@ -625,7 +624,7 @@ public final class BuilderUtils {
                 return Optional.<SchemaNodeBuilder> of(childNode);
             }
         }
-        LOG.trace("Child {} not found in node {}", child, builder);
+        LOG.trace(CHILD_NOT_FOUND_IN_NODE_STR, child, builder);
         return Optional.absent();
     }
 
@@ -730,19 +729,19 @@ public final class BuilderUtils {
         final SchemaPath schemaPath = parentPath.createChild(qname);
 
         if (node instanceof AnyXmlSchemaNode) {
-            return new AnyXmlBuilder(moduleName, line, qname, schemaPath, ((AnyXmlSchemaNode) node));
+            return new AnyXmlBuilder(moduleName, line, qname, schemaPath, (AnyXmlSchemaNode) node);
         } else if (node instanceof ChoiceSchemaNode) {
-            return new ChoiceBuilder(moduleName, line, qname, schemaPath, ((ChoiceSchemaNode) node));
+            return new ChoiceBuilder(moduleName, line, qname, schemaPath, (ChoiceSchemaNode) node);
         } else if (node instanceof ContainerSchemaNode) {
-            return new ContainerSchemaNodeBuilder(moduleName, line, qname, schemaPath, ((ContainerSchemaNode) node));
+            return new ContainerSchemaNodeBuilder(moduleName, line, qname, schemaPath, (ContainerSchemaNode) node);
         } else if (node instanceof LeafSchemaNode) {
-            return new LeafSchemaNodeBuilder(moduleName, line, qname, schemaPath, ((LeafSchemaNode) node));
+            return new LeafSchemaNodeBuilder(moduleName, line, qname, schemaPath, (LeafSchemaNode) node);
         } else if (node instanceof LeafListSchemaNode) {
-            return new LeafListSchemaNodeBuilder(moduleName, line, qname, schemaPath, ((LeafListSchemaNode) node));
+            return new LeafListSchemaNodeBuilder(moduleName, line, qname, schemaPath, (LeafListSchemaNode) node);
         } else if (node instanceof ListSchemaNode) {
-            return new ListSchemaNodeBuilder(moduleName, line, qname, schemaPath, ((ListSchemaNode) node));
+            return new ListSchemaNodeBuilder(moduleName, line, qname, schemaPath, (ListSchemaNode) node);
         } else if (node instanceof ChoiceCaseNode) {
-            return new ChoiceCaseBuilder(moduleName, line, qname, schemaPath, ((ChoiceCaseNode) node));
+            return new ChoiceCaseBuilder(moduleName, line, qname, schemaPath, (ChoiceCaseNode) node);
         } else {
             throw new YangParseException(moduleName, line, "Failed to copy node: Unknown type of DataSchemaNode: "
                     + node);
@@ -767,7 +766,7 @@ public final class BuilderUtils {
         for (TypeDefinition<?> node : nodes) {
             QName qname = QName.create(parentQName, node.getQName().getLocalName());
             SchemaPath schemaPath = parentPath.createChild(qname);
-            result.add(new TypeDefinitionBuilderImpl(moduleName, line, qname, schemaPath, ((ExtendedType) node)));
+            result.add(new TypeDefinitionBuilderImpl(moduleName, line, qname, schemaPath, (ExtendedType) node));
         }
         return result;
     }
@@ -806,8 +805,8 @@ public final class BuilderUtils {
         }
     }
 
-    public static ModuleBuilder findModule(final QName qname, final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
-        TreeMap<Date, ModuleBuilder> map = modules.get(qname.getNamespace());
+    public static ModuleBuilder findModule(final QName qname, final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
+        NavigableMap<Date, ModuleBuilder> map = modules.get(qname.getNamespace());
         if (map == null) {
             return null;
         }
@@ -817,9 +816,9 @@ public final class BuilderUtils {
         return map.get(qname.getRevision());
     }
 
-    public static Map<String, TreeMap<Date, URI>> createYangNamespaceContext(
+    public static Map<String, NavigableMap<Date, URI>> createYangNamespaceContext(
             final Collection<? extends ParseTree> modules, final Optional<SchemaContext> context) {
-        Map<String, TreeMap<Date, URI>> namespaceContext = new HashMap<>();
+        Map<String, NavigableMap<Date, URI>> namespaceContext = new HashMap<>();
         Set<Submodule_stmtContext> submodules = new HashSet<>();
         // first read ParseTree collection and separate modules and submodules
         for (ParseTree module : modules) {
@@ -858,7 +857,7 @@ public final class BuilderUtils {
                         }
                     }
                     // update namespaceContext
-                    TreeMap<Date, URI> revToNs = namespaceContext.get(moduleName);
+                    NavigableMap<Date, URI> revToNs = namespaceContext.get(moduleName);
                     if (revToNs == null) {
                         revToNs = new TreeMap<>();
                         revToNs.put(rev, namespace);
@@ -872,7 +871,7 @@ public final class BuilderUtils {
         // from SchemaContext
         if (context.isPresent()) {
             for (Module module : context.get().getModules()) {
-                TreeMap<Date, URI> revToNs = namespaceContext.get(module.getName());
+                NavigableMap<Date, URI> revToNs = namespaceContext.get(module.getName());
                 if (revToNs == null) {
                     revToNs = new TreeMap<>();
                     revToNs.put(module.getRevision(), module.getNamespace());
@@ -892,13 +891,13 @@ public final class BuilderUtils {
                         ParseTree belongsCtx = subHeaderCtx.getChild(j);
                         if (belongsCtx instanceof Belongs_to_stmtContext) {
                             final String belongsTo = ParserListenerUtils.stringFromNode(belongsCtx);
-                            TreeMap<Date, URI> ns = namespaceContext.get(belongsTo);
+                            NavigableMap<Date, URI> ns = namespaceContext.get(belongsTo);
                             if (ns == null) {
                                 throw new YangParseException(moduleName, submodule.getStart().getLine(), String.format(
                                         "Unresolved belongs-to statement: %s", belongsTo));
                             }
                             // submodule get namespace and revision from module
-                            TreeMap<Date, URI> subNs = new TreeMap<>();
+                            NavigableMap<Date, URI> subNs = new TreeMap<>();
                             subNs.put(ns.firstKey(), ns.firstEntry().getValue());
                             namespaceContext.put(moduleName, subNs);
                         }
index 55cf82726d8d104a4d9c32facff1bcf6d77bc6ab..8f9ffa98b48a3e35ec4348d1074e34cc114f7824 100644 (file)
@@ -77,7 +77,7 @@ public final class CopyUtils {
         copy.setAddedByUses(old.isAddedByUses());
         copy.setConfiguration(old.isConfiguration());
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         return copy;
@@ -105,7 +105,7 @@ public final class CopyUtils {
             copy.addAugmentation(copyAugment(augment, copy));
         }
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         return copy;
@@ -133,7 +133,7 @@ public final class CopyUtils {
             copy.addUsesNode(copyUses(oldUses, copy));
         }
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         return copy;
@@ -174,7 +174,7 @@ public final class CopyUtils {
             copy.addAugmentation(copyAugment(augment, copy));
         }
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         return copy;
@@ -198,7 +198,7 @@ public final class CopyUtils {
         copy.setAddedByUses(old.isAddedByUses());
         copy.setConfiguration(old.isConfiguration());
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         if (old.getType() == null) {
@@ -231,7 +231,7 @@ public final class CopyUtils {
         copy.setAddedByUses(old.isAddedByUses());
         copy.setConfiguration(old.isConfiguration());
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         if (old.getType() == null) {
@@ -279,7 +279,7 @@ public final class CopyUtils {
             copy.addAugmentation(copyAugment(augment, copy));
         }
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         copy.setUserOrdered(old.isUserOrdered());
@@ -314,7 +314,7 @@ public final class CopyUtils {
             copy.addUsesNode(copyUses(oldUses, copy));
         }
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
+            copy.addUnknownNodeBuilder(copy(un, copy, updateQName));
         }
 
         return copy;
@@ -352,7 +352,7 @@ public final class CopyUtils {
             }
 
             for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-                type.addUnknownNodeBuilder((copy(un, type, updateQName)));
+                type.addUnknownNodeBuilder(copy(un, type, updateQName));
             }
 
             type.setRanges(old.getRanges());
@@ -410,7 +410,7 @@ public final class CopyUtils {
             copy.addUsesNode(copyUses(oldUses, copy));
         }
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            copy.addUnknownNodeBuilder((copy(un, copy, false)));
+            copy.addUnknownNodeBuilder(copy(un, copy, false));
         }
 
         return copy;
@@ -433,7 +433,7 @@ public final class CopyUtils {
         c.setStatus(old.getStatus());
         c.setAddedByUses(old.isAddedByUses());
         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
-            c.addUnknownNodeBuilder((copy(un, c, updateQName)));
+            c.addUnknownNodeBuilder(copy(un, c, updateQName));
         }
         c.setExtensionBuilder(old.getExtensionBuilder());
         c.setExtensionDefinition(old.getExtensionDefinition());
index e1792c899f7fc1af26caf0c5f4559a3864cd94f3..eb06329eaab9ddd3ab3bbc1c62bf695d284e7ad1 100644 (file)
@@ -12,8 +12,8 @@ import java.net.URI;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.Map;
+import java.util.NavigableMap;
 import java.util.Set;
-import java.util.TreeMap;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
@@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
 public final class GroupingUtils {
     private static final Logger LOG = LoggerFactory.getLogger(GroupingUtils.class);
 
-    private static final Splitter COLON_SPLITTER = Splitter.on(':');
     private static final Splitter SLASH_SPLITTER = Splitter.on('/');
 
     private GroupingUtils() {
@@ -49,7 +48,7 @@ public final class GroupingUtils {
      *             if no grouping found
      */
     public static GroupingBuilder getTargetGroupingFromModules(final UsesNodeBuilder usesBuilder,
-            final Map<URI, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+            final Map<URI, NavigableMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         final int line = usesBuilder.getLine();
 
         SchemaPath groupingPath = usesBuilder.getTargetGroupingPath();
index 7cac743689c5b8f8e51e66525fbe1ac593a06d56..120ebad9575f78081406eaa581fc3b203931042b 100644 (file)
@@ -61,6 +61,8 @@ import org.opendaylight.yangtools.yang.parser.util.YangParseException;
  */
 public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder implements DocumentedNodeBuilder {
 
+    private static final String GROUPING_STR = "Grouping";
+    private static final String TYPEDEF_STR = "typedef";
     private ModuleImpl instance;
     private final String name;
     private final String sourcePath;
@@ -443,8 +445,8 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
 
     public ExtensionBuilder addExtension(final QName qname, final int line, final SchemaPath path) {
         checkNotSealed();
-        Builder parent = getActualNode();
-        if (!(parent.equals(this))) {
+        Builder parentBuilder = getActualNode();
+        if (!(parentBuilder.equals(this))) {
             throw new YangParseException(name, line, "extension can be defined only in module or submodule");
         }
 
@@ -455,7 +457,7 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
             }
         }
         final ExtensionBuilder builder = new ExtensionBuilderImpl(name, line, qname, path);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
         addedExtensions.add(builder);
         return builder;
     }
@@ -464,9 +466,9 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotSealed();
         final ContainerSchemaNodeBuilder builder = new ContainerSchemaNodeBuilder(name, line, qname, schemaPath);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
-        addChildToParent(parent, builder, qname.getLocalName());
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
+        addChildToParent(parentBuilder, builder, qname.getLocalName());
 
         return builder;
     }
@@ -475,9 +477,9 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotSealed();
         final ListSchemaNodeBuilder builder = new ListSchemaNodeBuilder(name, line, qname, schemaPath);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
-        addChildToParent(parent, builder, qname.getLocalName());
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
+        addChildToParent(parentBuilder, builder, qname.getLocalName());
         allLists.add(builder);
 
         return builder;
@@ -487,9 +489,9 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotSealed();
         final LeafSchemaNodeBuilder builder = new LeafSchemaNodeBuilder(name, line, qname, schemaPath);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
-        addChildToParent(parent, builder, qname.getLocalName());
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
+        addChildToParent(parentBuilder, builder, qname.getLocalName());
 
         return builder;
     }
@@ -498,9 +500,9 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotSealed();
         final LeafListSchemaNodeBuilder builder = new LeafListSchemaNodeBuilder(name, line, qname, schemaPath);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
-        addChildToParent(parent, builder, qname.getLocalName());
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
+        addChildToParent(parentBuilder, builder, qname.getLocalName());
 
         return builder;
     }
@@ -509,31 +511,31 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotSealed();
         final GroupingBuilder builder = new GroupingBuilderImpl(name, line, qname, path);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
 
         String groupingName = qname.getLocalName();
-        if (parent.equals(this)) {
+        if (parentBuilder.equals(this)) {
             for (GroupingBuilder addedGrouping : getGroupingBuilders()) {
                 if (addedGrouping.getQName().getLocalName().equals(groupingName)) {
-                    raiseYangParserException("", "Grouping", groupingName, line, addedGrouping.getLine());
+                    raiseYangParserException("", GROUPING_STR, groupingName, line, addedGrouping.getLine());
                 }
             }
             addGrouping(builder);
         } else {
-            if (parent instanceof DataNodeContainerBuilder) {
-                DataNodeContainerBuilder parentNode = (DataNodeContainerBuilder) parent;
+            if (parentBuilder instanceof DataNodeContainerBuilder) {
+                DataNodeContainerBuilder parentNode = (DataNodeContainerBuilder) parentBuilder;
                 for (GroupingBuilder addedGrouping : parentNode.getGroupingBuilders()) {
                     if (addedGrouping.getQName().getLocalName().equals(groupingName)) {
-                        raiseYangParserException("", "Grouping", groupingName, line, addedGrouping.getLine());
+                        raiseYangParserException("", GROUPING_STR, groupingName, line, addedGrouping.getLine());
                     }
                 }
                 parentNode.addGrouping(builder);
-            } else if (parent instanceof RpcDefinitionBuilder) {
-                RpcDefinitionBuilder parentNode = (RpcDefinitionBuilder) parent;
+            } else if (parentBuilder instanceof RpcDefinitionBuilder) {
+                RpcDefinitionBuilder parentNode = (RpcDefinitionBuilder) parentBuilder;
                 for (GroupingBuilder child : parentNode.getGroupings()) {
                     if (child.getQName().getLocalName().equals(groupingName)) {
-                        raiseYangParserException("", "Grouping", groupingName, line, child.getLine());
+                        raiseYangParserException("", GROUPING_STR, groupingName, line, child.getLine());
                     }
                 }
                 parentNode.addGrouping(builder);
@@ -552,10 +554,10 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name, line, augmentTargetStr,
                 targetPath, order);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
 
-        if (parent.equals(this)) {
+        if (parentBuilder.equals(this)) {
             // augment can be declared only under 'module' ...
             if (!(augmentTargetStr.startsWith("/"))) {
                 throw new YangParseException(
@@ -566,13 +568,13 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
             augmentBuilders.add(builder);
         } else {
             // ... or 'uses' statement
-            if (parent instanceof UsesNodeBuilder) {
+            if (parentBuilder instanceof UsesNodeBuilder) {
                 if (augmentTargetStr.startsWith("/")) {
                     throw new YangParseException(name, line,
                             "If 'augment' statement is a substatement to the 'uses' statement, it cannot contain absolute path ("
                                     + augmentTargetStr + ")");
                 }
-                ((UsesNodeBuilder) parent).addAugment(builder);
+                ((UsesNodeBuilder) parentBuilder).addAugment(builder);
             } else {
                 throw new YangParseException(name, line, "Augment can be declared only under module or uses statement.");
             }
@@ -586,18 +588,18 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotSealed();
         final UsesNodeBuilder usesBuilder = new UsesNodeBuilderImpl(name, line, grouping);
 
-        Builder parent = getActualNode();
-        usesBuilder.setParent(parent);
+        Builder parentBuilder = getActualNode();
+        usesBuilder.setParent(parentBuilder);
 
-        if (parent.equals(this)) {
+        if (parentBuilder.equals(this)) {
             addUsesNode(usesBuilder);
         } else {
-            if (!(parent instanceof DataNodeContainerBuilder)) {
+            if (!(parentBuilder instanceof DataNodeContainerBuilder)) {
                 throw new YangParseException(name, line, "Unresolved parent of uses '" + grouping + "'.");
             }
-            ((DataNodeContainerBuilder) parent).addUsesNode(usesBuilder);
+            ((DataNodeContainerBuilder) parentBuilder).addUsesNode(usesBuilder);
         }
-        if (parent instanceof AugmentationSchemaBuilder) {
+        if (parentBuilder instanceof AugmentationSchemaBuilder) {
             usesBuilder.setAugmenting(true);
         }
 
@@ -607,23 +609,23 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
 
     public void addRefine(final RefineHolderImpl refine) {
         checkNotSealed();
-        final Builder parent = getActualNode();
-        if (!(parent instanceof UsesNodeBuilder)) {
+        final Builder parentBuilder = getActualNode();
+        if (!(parentBuilder instanceof UsesNodeBuilder)) {
             throw new YangParseException(name, refine.getLine(), "refine can be defined only in uses statement");
         }
-        ((UsesNodeBuilder) parent).addRefine(refine);
-        refine.setParent(parent);
+        ((UsesNodeBuilder) parentBuilder).addRefine(refine);
+        refine.setParent(parentBuilder);
     }
 
     public RpcDefinitionBuilder addRpc(final int line, final QName qname, final SchemaPath path) {
         checkNotSealed();
-        Builder parent = getActualNode();
-        if (!(parent.equals(this))) {
+        Builder parentBuilder = getActualNode();
+        if (!(parentBuilder.equals(this))) {
             throw new YangParseException(name, line, "rpc can be defined only in module or submodule");
         }
 
         final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(name, line, qname, path);
-        rpcBuilder.setParent(parent);
+        rpcBuilder.setParent(parentBuilder);
 
         String rpcName = qname.getLocalName();
         checkNotConflictingInDataNamespace(rpcName, line);
@@ -651,11 +653,11 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
 
     public ContainerSchemaNodeBuilder addRpcInput(final int line, final QName qname, final SchemaPath schemaPath) {
         checkNotSealed();
-        final Builder parent = getActualNode();
-        if (!(parent instanceof RpcDefinitionBuilder)) {
+        final Builder parentBuilder = getActualNode();
+        if (!(parentBuilder instanceof RpcDefinitionBuilder)) {
             throw new YangParseException(name, line, "input can be defined only in rpc statement");
         }
-        final RpcDefinitionBuilder rpc = (RpcDefinitionBuilder) parent;
+        final RpcDefinitionBuilder rpc = (RpcDefinitionBuilder) parentBuilder;
 
         final ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(name, line, qname, schemaPath);
         inputBuilder.setParent(rpc);
@@ -666,11 +668,11 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
 
     public ContainerSchemaNodeBuilder addRpcOutput(final SchemaPath schemaPath, final QName qname, final int line) {
         checkNotSealed();
-        final Builder parent = getActualNode();
-        if (!(parent instanceof RpcDefinitionBuilder)) {
+        final Builder parentBuilder = getActualNode();
+        if (!(parentBuilder instanceof RpcDefinitionBuilder)) {
             throw new YangParseException(name, line, "output can be defined only in rpc statement");
         }
-        final RpcDefinitionBuilder rpc = (RpcDefinitionBuilder) parent;
+        final RpcDefinitionBuilder rpc = (RpcDefinitionBuilder) parentBuilder;
 
         final ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(name, line, qname, schemaPath);
         outputBuilder.setParent(rpc);
@@ -686,8 +688,8 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
 
     public NotificationBuilder addNotification(final int line, final QName qname, final SchemaPath path) {
         checkNotSealed();
-        final Builder parent = getActualNode();
-        if (!(parent.equals(this))) {
+        final Builder parentBuilder = getActualNode();
+        if (!(parentBuilder.equals(this))) {
             throw new YangParseException(name, line, "notification can be defined only in module or submodule");
         }
 
@@ -695,20 +697,20 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         checkNotConflictingInDataNamespace(notificationName, line);
 
         final NotificationBuilder builder = new NotificationBuilder(name, line, qname, path);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
         addedNotifications.add(builder);
 
         return builder;
     }
 
     public FeatureBuilder addFeature(final int line, final QName qname, final SchemaPath path) {
-        Builder parent = getActualNode();
-        if (!(parent.equals(this))) {
+        Builder parentBuilder = getActualNode();
+        if (!(parentBuilder.equals(this))) {
             throw new YangParseException(name, line, "feature can be defined only in module or submodule");
         }
 
         final FeatureBuilder builder = new FeatureBuilder(name, line, qname, path);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
 
         String featureName = qname.getLocalName();
         for (FeatureBuilder addedFeature : addedFeatures) {
@@ -723,26 +725,26 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     public ChoiceBuilder addChoice(final int line, final QName qname, final SchemaPath path) {
         final ChoiceBuilder builder = new ChoiceBuilder(name, line, qname, path);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
-        addChildToParent(parent, builder, qname.getLocalName());
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
+        addChildToParent(parentBuilder, builder, qname.getLocalName());
 
         return builder;
     }
 
     public ChoiceCaseBuilder addCase(final int line, final QName qname, final SchemaPath path) {
-        Builder parent = getActualNode();
-        if (parent == null || parent.equals(this)) {
+        Builder parentBuilder = getActualNode();
+        if (parentBuilder == null || parentBuilder.equals(this)) {
             throw new YangParseException(name, line, "'case' parent not found");
         }
 
         final ChoiceCaseBuilder builder = new ChoiceCaseBuilder(name, line, qname, path);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
 
-        if (parent instanceof ChoiceBuilder) {
-            ((ChoiceBuilder) parent).addCase(builder);
-        } else if (parent instanceof AugmentationSchemaBuilder) {
-            ((AugmentationSchemaBuilder) parent).addChildNode(builder);
+        if (parentBuilder instanceof ChoiceBuilder) {
+            ((ChoiceBuilder) parentBuilder).addCase(builder);
+        } else if (parentBuilder instanceof AugmentationSchemaBuilder) {
+            ((AugmentationSchemaBuilder) parentBuilder).addChildNode(builder);
         } else {
             throw new YangParseException(name, line, "Unresolved parent of 'case' " + qname.getLocalName());
         }
@@ -753,9 +755,9 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     public AnyXmlBuilder addAnyXml(final int line, final QName qname, final SchemaPath schemaPath) {
         final AnyXmlBuilder builder = new AnyXmlBuilder(name, line, qname, schemaPath);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
-        addChildToParent(parent, builder, qname.getLocalName());
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
+        addChildToParent(parentBuilder, builder, qname.getLocalName());
 
         return builder;
     }
@@ -765,7 +767,7 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         String nodeName = typedefBuilder.getQName().getLocalName();
         for (TypeDefinitionBuilder tdb : getTypeDefinitionBuilders()) {
             if (tdb.getQName().getLocalName().equals(nodeName)) {
-                raiseYangParserException("", "typedef", nodeName, typedefBuilder.getLine(), tdb.getLine());
+                raiseYangParserException("", TYPEDEF_STR, nodeName, typedefBuilder.getLine(), tdb.getLine());
             }
         }
         super.addTypedef(typedefBuilder);
@@ -774,26 +776,26 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     public TypeDefinitionBuilderImpl addTypedef(final int line, final QName qname, final SchemaPath path) {
         final TypeDefinitionBuilderImpl builder = new TypeDefinitionBuilderImpl(name, line, qname, path);
 
-        Builder parent = getActualNode();
-        builder.setParent(parent);
+        Builder parentBuilder = getActualNode();
+        builder.setParent(parentBuilder);
 
         String typedefName = qname.getLocalName();
-        if (parent.equals(this)) {
+        if (parentBuilder.equals(this)) {
             addTypedef(builder);
         } else {
-            if (parent instanceof DataNodeContainerBuilder) {
-                DataNodeContainerBuilder parentNode = (DataNodeContainerBuilder) parent;
+            if (parentBuilder instanceof DataNodeContainerBuilder) {
+                DataNodeContainerBuilder parentNode = (DataNodeContainerBuilder) parentBuilder;
                 for (TypeDefinitionBuilder child : parentNode.getTypeDefinitionBuilders()) {
                     if (child.getQName().getLocalName().equals(typedefName)) {
-                        raiseYangParserException("", "typedef", typedefName, line, child.getLine());
+                        raiseYangParserException("", TYPEDEF_STR, typedefName, line, child.getLine());
                     }
                 }
                 parentNode.addTypedef(builder);
-            } else if (parent instanceof RpcDefinitionBuilder) {
-                RpcDefinitionBuilder rpcParent = (RpcDefinitionBuilder) parent;
+            } else if (parentBuilder instanceof RpcDefinitionBuilder) {
+                RpcDefinitionBuilder rpcParent = (RpcDefinitionBuilder) parentBuilder;
                 for (TypeDefinitionBuilder tdb : rpcParent.getTypeDefinitions()) {
                     if (tdb.getQName().getLocalName().equals(builder.getQName().getLocalName())) {
-                        raiseYangParserException("", "typedef", typedefName, line, tdb.getLine());
+                        raiseYangParserException("", TYPEDEF_STR, typedefName, line, tdb.getLine());
                     }
                 }
                 rpcParent.addTypedef(builder);
@@ -806,22 +808,22 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     }
 
     public void setType(final TypeDefinition<?> type) {
-        Builder parent = getActualNode();
-        if (!(parent instanceof TypeAwareBuilder)) {
+        Builder parentBuilder = getActualNode();
+        if (!(parentBuilder instanceof TypeAwareBuilder)) {
             throw new YangParseException("Failed to set type '" + type.getQName().getLocalName()
-                    + "'. Invalid parent node: " + parent);
+                    + "'. Invalid parent node: " + parentBuilder);
         }
-        ((TypeAwareBuilder) parent).setType(type);
+        ((TypeAwareBuilder) parentBuilder).setType(type);
     }
 
     public UnionTypeBuilder addUnionType(final int line, final QNameModule module) {
-        final Builder parent = getActualNode();
-        if (parent == null) {
+        final Builder parentBuilder = getActualNode();
+        if (parentBuilder == null) {
             throw new YangParseException(name, line, "Unresolved parent of union type");
         } else {
             final UnionTypeBuilder union = new UnionTypeBuilder(name, line);
-            if (parent instanceof TypeAwareBuilder) {
-                ((TypeAwareBuilder) parent).setTypedef(union);
+            if (parentBuilder instanceof TypeAwareBuilder) {
+                ((TypeAwareBuilder) parentBuilder).setTypedef(union);
                 return union;
             } else {
                 throw new YangParseException(name, line, "Invalid parent of union type.");
@@ -832,12 +834,12 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     public void addIdentityrefType(final int line, final SchemaPath schemaPath, final String baseString) {
         final IdentityrefTypeBuilder identityref = new IdentityrefTypeBuilder(name, line, baseString, schemaPath);
 
-        final Builder parent = getActualNode();
-        if (parent == null) {
+        final Builder parentBuilder = getActualNode();
+        if (parentBuilder == null) {
             throw new YangParseException(name, line, "Unresolved parent of identityref type.");
         } else {
-            if (parent instanceof TypeAwareBuilder) {
-                final TypeAwareBuilder typeParent = (TypeAwareBuilder) parent;
+            if (parentBuilder instanceof TypeAwareBuilder) {
+                final TypeAwareBuilder typeParent = (TypeAwareBuilder) parentBuilder;
                 typeParent.setTypedef(identityref);
                 dirtyNodes.add(typeParent);
             } else {
@@ -847,20 +849,20 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     }
 
     public DeviationBuilder addDeviation(final int line, final SchemaPath targetPath) {
-        Builder parent = getActualNode();
-        if (!(parent.equals(this))) {
+        Builder parentBuilder = getActualNode();
+        if (!(parentBuilder.equals(this))) {
             throw new YangParseException(name, line, "deviation can be defined only in module or submodule");
         }
 
         final DeviationBuilder builder = new DeviationBuilder(name, line, targetPath);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
         deviationBuilders.add(builder);
         return builder;
     }
 
     public IdentitySchemaNodeBuilder addIdentity(final QName qname, final int line, final SchemaPath path) {
-        Builder parent = getActualNode();
-        if (!(parent.equals(this))) {
+        Builder parentBuilder = getActualNode();
+        if (!(parentBuilder.equals(this))) {
             throw new YangParseException(name, line, "identity can be defined only in module or submodule");
         }
         String identityName = qname.getLocalName();
@@ -871,7 +873,7 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
         }
 
         final IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(name, line, qname, path);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
         addedIdentities.add(builder);
         return builder;
     }
@@ -883,20 +885,20 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     }
 
     public UnknownSchemaNodeBuilderImpl addUnknownSchemaNode(final int line, final QName qname, final SchemaPath path) {
-        final Builder parent = getActualNode();
+        final Builder parentBuilder = getActualNode();
         final UnknownSchemaNodeBuilderImpl builder = new UnknownSchemaNodeBuilderImpl(name, line, qname, path);
-        builder.setParent(parent);
+        builder.setParent(parentBuilder);
         allUnknownNodes.add(builder);
 
-        if (parent.equals(this)) {
+        if (parentBuilder.equals(this)) {
             addedUnknownNodes.add(builder);
         } else {
-            if (parent instanceof SchemaNodeBuilder) {
-                parent.addUnknownNodeBuilder(builder);
-            } else if (parent instanceof DataNodeContainerBuilder) {
-                parent.addUnknownNodeBuilder(builder);
-            } else if (parent instanceof RefineHolderImpl) {
-                parent.addUnknownNodeBuilder(builder);
+            if (parentBuilder instanceof SchemaNodeBuilder) {
+                parentBuilder.addUnknownNodeBuilder(builder);
+            } else if (parentBuilder instanceof DataNodeContainerBuilder) {
+                parentBuilder.addUnknownNodeBuilder(builder);
+            } else if (parentBuilder instanceof RefineHolderImpl) {
+                parentBuilder.addUnknownNodeBuilder(builder);
             } else {
                 throw new YangParseException(name, line, "Unresolved parent of unknown node '" + qname.getLocalName()
                         + "'");
index 00018b8dda1128e20704ac15f5b89d9fff0859e4..f6f152fd35b2dbe441e73d9d01bed6085063b9e2 100644 (file)
@@ -8,6 +8,7 @@ import java.net.URI;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.NavigableSet;
 import java.util.Set;
 import java.util.TreeSet;
 import org.opendaylight.yangtools.concepts.Immutable;
@@ -220,7 +221,7 @@ public final class ModuleImpl extends AbstractDocumentedDataNodeContainer implem
     }
 
     private static <T extends SchemaNode> Set<T> toImmutableSortedSet(final Set<T> original) {
-        TreeSet<T> sorted = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+        NavigableSet<T> sorted = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
         sorted.addAll(original);
         return Collections.unmodifiableSet(sorted);
     }
index 25ad30e2dbb121cedc5040afbfe0c806cc11f5c5..1d035a125d64c6f6334bba179dae3a593ae21c8b 100644 (file)
@@ -32,6 +32,11 @@ public final class RpcDefinitionBuilder extends AbstractSchemaNodeBuilder {
     private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<>();
     private final Set<GroupingBuilder> addedGroupings = new HashSet<>();
 
+    RpcDefinitionBuilder(final String moduleName, final int line, final QName qname, final SchemaPath path) {
+        super(moduleName, line, qname);
+        this.schemaPath = Preconditions.checkNotNull(path, "Schema Path must not be null");
+    }
+
     public ContainerSchemaNodeBuilder getInput() {
         return inputBuilder;
     }
@@ -40,11 +45,6 @@ public final class RpcDefinitionBuilder extends AbstractSchemaNodeBuilder {
         return outputBuilder;
     }
 
-    RpcDefinitionBuilder(final String moduleName, final int line, final QName qname, final SchemaPath path) {
-        super(moduleName, line, qname);
-        this.schemaPath = Preconditions.checkNotNull(path, "Schema Path must not be null");
-    }
-
     @Override
     public RpcDefinition build() {
         if (instance != null) {
index ad1afc255bebd9177cfef8d885532124c7ab0719..a02baead8db8fb394e9d6514d84fdec4f66c3abb 100644 (file)
@@ -12,8 +12,8 @@ import static org.opendaylight.yangtools.yang.parser.builder.impl.BuilderUtils.f
 import java.net.URI;
 import java.util.Date;
 import java.util.Map;
+import java.util.NavigableMap;
 import java.util.Set;
-import java.util.TreeMap;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
@@ -49,7 +49,7 @@ public final class TypeUtils {
      *            current module
      */
     public static void resolveType(final TypeAwareBuilder nodeToResolve,
-            final Map<URI, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+            final Map<URI, NavigableMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         QName unknownTypeQName = nodeToResolve.getTypeQName();
         final ModuleBuilder dependentModuleBuilder = BuilderUtils.findModule(unknownTypeQName, modules);
         if (dependentModuleBuilder == null) {
@@ -72,7 +72,7 @@ public final class TypeUtils {
      *            current module
      */
     public static void resolveTypeUnion(final UnionTypeBuilder union,
-            final Map<URI, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+            final Map<URI, NavigableMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         // special handling for identityref types under union
         for (TypeDefinitionBuilder unionType : union.getTypedefs()) {
             if (unionType instanceof IdentityrefTypeBuilder) {
@@ -111,7 +111,7 @@ public final class TypeUtils {
      * @return TypeDefinitionBuilder of node type
      */
     private static TypeDefinitionBuilder findUnknownTypeDefinition(final TypeAwareBuilder nodeToResolve,
-            final ModuleBuilder dependentModuleBuilder, final Map<URI, TreeMap<Date, ModuleBuilder>> modules,
+            final ModuleBuilder dependentModuleBuilder, final Map<URI, NavigableMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder module) {
         final int line = nodeToResolve.getLine();
         final QName unknownTypeQName = nodeToResolve.getTypeQName();
@@ -175,7 +175,7 @@ public final class TypeUtils {
     }
 
     private static TypeConstraints findConstraintsFromTypeBuilder(final TypeAwareBuilder nodeToResolve,
-            final TypeConstraints constraints, final Map<URI, TreeMap<Date, ModuleBuilder>> modules,
+            final TypeConstraints constraints, final Map<URI, NavigableMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder builder) {
 
         // union and identityref types cannot be restricted
index 5c79161116084e13f402067b4ed17ce2dee78c20..8ee273e8172a42974d7cdf2b65fa9a1249ef3956 100644 (file)
@@ -261,7 +261,7 @@ final class BasicValidations {
         Iterable<String> keyList = ValidationUtil.listKeysFromId(key);
         Set<String> duplicates = ValidationUtil.getDuplicates(keyList);
 
-        if (duplicates.size() != 0) {
+        if (!duplicates.isEmpty()) {
             ValidationUtil.ex(ValidationUtil.f("(In (sub)module:%s) %s:%s, %s:%s contains duplicates:%s",
                     rootParentName, ValidationUtil.getSimpleStatementName(parent.getClass()),
                     ValidationUtil.getName(parent), ValidationUtil.getSimpleStatementName(ctx.getClass()), key,
index 5684c045d5a08d1412b48bfdf3db5a28f2b7e21d..fdc8369f4ada260763c4fc4f2a88f906aa1f5d79 100644 (file)
@@ -141,7 +141,7 @@ public final class YangParserImpl implements YangContextParser {
 
         // module builders sorted by dependencies
         List<ModuleBuilder> sortedBuilders = ModuleDependencySort.sort(resolved);
-        Map<URI, TreeMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sortedBuilders, null);
+        Map<URI, NavigableMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sortedBuilders, null);
         Collection<Module> unsorted = build(modules).values();
         Set<Module> result = new LinkedHashSet<>(
                 ModuleDependencySort.sort(unsorted.toArray(new Module[unsorted.size()])));
@@ -218,7 +218,7 @@ public final class YangParserImpl implements YangContextParser {
         }
 
         final List<ModuleBuilder> sorted = resolveModuleBuilders(sources, context);
-        final Map<URI, TreeMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sorted, context);
+        final Map<URI, NavigableMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sorted, context);
 
         final Set<Module> unsorted = new LinkedHashSet<>(build(modules).values());
         if (context != null) {
@@ -233,9 +233,9 @@ public final class YangParserImpl implements YangContextParser {
         return resolveSchemaContext(result);
     }
 
-    private static Map<URI, TreeMap<Date, ModuleBuilder>> resolveModulesWithImports(final List<ModuleBuilder> sorted,
+    private static Map<URI, NavigableMap<Date, ModuleBuilder>> resolveModulesWithImports(final List<ModuleBuilder> sorted,
             final SchemaContext context) {
-        final Map<URI, TreeMap<Date, ModuleBuilder>> modules = orderModules(sorted);
+        final Map<URI, NavigableMap<Date, ModuleBuilder>> modules = orderModules(sorted);
         for (ModuleBuilder module : sorted) {
             if (module != null) {
                 for (ModuleImport imp : module.getImports().values()) {
@@ -244,7 +244,7 @@ public final class YangParserImpl implements YangContextParser {
                     if (targetModule == null) {
                         Module result = findModuleFromContext(context, module, prefix, 0);
                         targetModule = new ModuleBuilder(result);
-                        TreeMap<Date, ModuleBuilder> map = modules.get(targetModule.getNamespace());
+                        NavigableMap<Date, ModuleBuilder> map = modules.get(targetModule.getNamespace());
                         if (map == null) {
                             map = new TreeMap<>();
                             map.put(targetModule.getRevision(), targetModule);
@@ -335,7 +335,7 @@ public final class YangParserImpl implements YangContextParser {
     public Collection<Module> buildModules(final Collection<ModuleBuilder> builders) {
         Collection<ModuleBuilder> unsorted = resolveSubmodules(builders);
         List<ModuleBuilder> sorted = ModuleDependencySort.sort(unsorted);
-        Map<URI, TreeMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sorted, null);
+        Map<URI, NavigableMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sorted, null);
         Map<ModuleBuilder, Module> builderToModule = build(modules);
         return builderToModule.values();
     }
@@ -354,7 +354,7 @@ public final class YangParserImpl implements YangContextParser {
         Map<ByteSource, ModuleBuilder> sourceToBuilder = resolveSources(sources, context);
         // sort and check for duplicates
         List<ModuleBuilder> sorted = ModuleDependencySort.sort(sourceToBuilder.values());
-        Map<URI, TreeMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sorted, null);
+        Map<URI, NavigableMap<Date, ModuleBuilder>> modules = resolveModulesWithImports(sorted, null);
         Map<ModuleBuilder, Module> builderToModule = build(modules);
         Map<ModuleBuilder, ByteSource> builderToSource = HashBiMap.create(sourceToBuilder).inverse();
         sorted = ModuleDependencySort.sort(builderToModule.keySet());
@@ -392,7 +392,7 @@ public final class YangParserImpl implements YangContextParser {
         // validate yang
         new YangModelBasicValidator(walker).validate(sourceToTree.values());
 
-        Map<String, TreeMap<Date, URI>> namespaceContext = BuilderUtils.createYangNamespaceContext(
+        Map<String, NavigableMap<Date, URI>> namespaceContext = BuilderUtils.createYangNamespaceContext(
                 sourceToTree.values(), Optional.fromNullable(context));
         YangParserListenerImpl yangModelParser;
         for (Map.Entry<ByteSource, ParseTree> entry : sourceToTree.entrySet()) {
@@ -416,12 +416,12 @@ public final class YangParserImpl implements YangContextParser {
 
     private Map<ByteSource, ModuleBuilder> resolveSubmodules(final Map<ByteSource, ModuleBuilder> builders) {
         Map<ByteSource, ModuleBuilder> modules = new HashMap<>();
-        Map<String, TreeMap<Date, ModuleBuilder>> submodules = new HashMap<>();
+        Map<String, NavigableMap<Date, ModuleBuilder>> submodules = new HashMap<>();
         for (Map.Entry<ByteSource, ModuleBuilder> entry : builders.entrySet()) {
             ModuleBuilder builder = entry.getValue();
             if (builder.isSubmodule()) {
                 String submoduleName = builder.getName();
-                TreeMap<Date, ModuleBuilder> map = submodules.get(submoduleName);
+                NavigableMap<Date, ModuleBuilder> map = submodules.get(submoduleName);
                 if (map == null) {
                     map = new TreeMap<>();
                     map.put(builder.getRevision(), builder);
@@ -443,11 +443,11 @@ public final class YangParserImpl implements YangContextParser {
 
     private Collection<ModuleBuilder> resolveSubmodules(final Collection<ModuleBuilder> builders) {
         Collection<ModuleBuilder> modules = new HashSet<>();
-        Map<String, TreeMap<Date, ModuleBuilder>> submodules = new HashMap<>();
+        Map<String, NavigableMap<Date, ModuleBuilder>> submodules = new HashMap<>();
         for (ModuleBuilder builder : builders) {
             if (builder.isSubmodule()) {
                 String submoduleName = builder.getName();
-                TreeMap<Date, ModuleBuilder> map = submodules.get(submoduleName);
+                NavigableMap<Date, ModuleBuilder> map = submodules.get(submoduleName);
                 if (map == null) {
                     map = new TreeMap<>();
                     map.put(builder.getRevision(), builder);
@@ -478,7 +478,7 @@ public final class YangParserImpl implements YangContextParser {
      * @return collection of module builders with resolved submodules
      */
     private void resolveSubmodules(final ModuleBuilder module,
-            final Map<String, TreeMap<Date, ModuleBuilder>> submodules) {
+            final Map<String, NavigableMap<Date, ModuleBuilder>> submodules) {
         Map<String, Date> includes = module.getIncludedModules();
         for (Map.Entry<String, Date> entry : includes.entrySet()) {
             NavigableMap<Date, ModuleBuilder> subs = submodules.get(entry.getKey());
@@ -499,7 +499,7 @@ public final class YangParserImpl implements YangContextParser {
                 }
             }
 
-            if (submodule.getIncludedModules().size() > 0) {
+            if (!submodule.getIncludedModules().isEmpty()) {
                 resolveSubmodules(submodule, submodules);
             }
             addSubmoduleToModule(submodule, module);
@@ -563,8 +563,8 @@ public final class YangParserImpl implements YangContextParser {
      *            topologically sorted modules
      * @return modules ordered by namespace and revision
      */
-    private static Map<URI, TreeMap<Date, ModuleBuilder>> orderModules(final List<ModuleBuilder> modules) {
-        final Map<URI, TreeMap<Date, ModuleBuilder>> result = new LinkedHashMap<>();
+    private static Map<URI, NavigableMap<Date, ModuleBuilder>> orderModules(final List<ModuleBuilder> modules) {
+        final Map<URI, NavigableMap<Date, ModuleBuilder>> result = new LinkedHashMap<>();
         for (final ModuleBuilder builder : modules) {
             if (builder == null) {
                 continue;
@@ -576,7 +576,7 @@ public final class YangParserImpl implements YangContextParser {
                 rev = new Date(0);
             }
 
-            TreeMap<Date, ModuleBuilder> builderByRevision = result.get(ns);
+            NavigableMap<Date, ModuleBuilder> builderByRevision = result.get(ns);
             if (builderByRevision == null) {
                 builderByRevision = new TreeMap<>();
                 builderByRevision.put(rev, builder);
@@ -606,7 +606,7 @@ public final class YangParserImpl implements YangContextParser {
 
         // if this is submodule, add parent to filtered and pick its imports
         if (main.isSubmodule()) {
-            TreeMap<Date, ModuleBuilder> dependencies = new TreeMap<>();
+            NavigableMap<Date, ModuleBuilder> dependencies = new TreeMap<>();
             for (ModuleBuilder mb : other) {
                 if (mb.getName().equals(main.getBelongsTo())) {
                     dependencies.put(mb.getRevision(), mb);
@@ -626,11 +626,9 @@ public final class YangParserImpl implements YangContextParser {
                             filterImports(builder, other, filtered);
                         }
                     } else {
-                        if (mi.getRevision().equals(builder.getRevision())) {
-                            if (!filtered.contains(builder)) {
-                                filtered.add(builder);
-                                filterImports(builder, other, filtered);
-                            }
+                        if (!filtered.contains(builder) && mi.getRevision().equals(builder.getRevision())) {
+                            filtered.add(builder);
+                            filterImports(builder, other, filtered);
                         }
                     }
                 }
@@ -705,7 +703,7 @@ public final class YangParserImpl implements YangContextParser {
      *            all loaded modules
      * @return modules mapped on their builders
      */
-    private Map<ModuleBuilder, Module> build(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+    private Map<ModuleBuilder, Module> build(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         resolveDirtyNodes(modules);
         resolveAugmentsTargetPath(modules);
         resolveUsesTargetGrouping(modules);
@@ -717,7 +715,7 @@ public final class YangParserImpl implements YangContextParser {
 
         // build
         final Map<ModuleBuilder, Module> result = new LinkedHashMap<>();
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
                 final ModuleBuilder moduleBuilder = childEntry.getValue();
                 final Module module = moduleBuilder.build();
@@ -733,8 +731,8 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveDirtyNodes(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+    private void resolveDirtyNodes(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
                 final ModuleBuilder module = childEntry.getValue();
                 resolveUnknownNodes(modules, module);
@@ -752,7 +750,7 @@ public final class YangParserImpl implements YangContextParser {
      * @param module
      *            current module
      */
-    private void resolveDirtyNodes(final Map<URI, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+    private void resolveDirtyNodes(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         final Set<TypeAwareBuilder> dirtyNodes = module.getDirtyNodes();
         if (!dirtyNodes.isEmpty()) {
             for (TypeAwareBuilder nodeToResolve : dirtyNodes) {
@@ -783,10 +781,10 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveAugmentsTargetPath(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+    private void resolveAugmentsTargetPath(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         // collect augments from all loaded modules
         final List<AugmentationSchemaBuilder> allAugments = new ArrayList<>();
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 allAugments.addAll(inner.getValue().getAllAugments());
             }
@@ -896,9 +894,9 @@ public final class YangParserImpl implements YangContextParser {
      *            all loaded modules topologically sorted (based on dependencies
      *            between each other)
      */
-    private void resolveAugments(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+    private void resolveAugments(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         List<ModuleBuilder> all = new ArrayList<>();
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 all.add(inner.getValue());
             }
@@ -934,7 +932,7 @@ public final class YangParserImpl implements YangContextParser {
      * @return true if augment process succeed
      */
     private boolean resolveUsesAugment(final AugmentationSchemaBuilder augment, final ModuleBuilder module,
-            final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+            final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         if (augment.isResolved()) {
             return true;
         }
@@ -994,7 +992,7 @@ public final class YangParserImpl implements YangContextParser {
      * @return true if augment process succeed
      */
     private boolean resolveAugment(final AugmentationSchemaBuilder augment, final ModuleBuilder module,
-            final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+            final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         if (augment.isResolved()) {
             return true;
         }
@@ -1016,8 +1014,8 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveIdentities(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+    private void resolveIdentities(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 ModuleBuilder module = inner.getValue();
                 final Set<IdentitySchemaNodeBuilder> identities = module.getAddedIdentities();
@@ -1076,9 +1074,9 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveUsesTargetGrouping(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+    private void resolveUsesTargetGrouping(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         final List<UsesNodeBuilder> allUses = new ArrayList<>();
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 allUses.addAll(inner.getValue().getAllUsesNodes());
             }
@@ -1097,9 +1095,9 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveUsesForGroupings(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+    private void resolveUsesForGroupings(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         final Set<GroupingBuilder> allGroupings = new HashSet<>();
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 ModuleBuilder module = inner.getValue();
                 allGroupings.addAll(module.getAllGroupings());
@@ -1121,8 +1119,8 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveUsesForNodes(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+    private void resolveUsesForNodes(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
                 ModuleBuilder module = inner.getValue();
                 List<UsesNodeBuilder> usesNodes = module.getAllUsesNodes();
@@ -1143,7 +1141,7 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void resolveUses(final UsesNodeBuilder usesNode, final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+    private void resolveUses(final UsesNodeBuilder usesNode, final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
         if (!usesNode.isResolved()) {
             DataNodeContainerBuilder parent = usesNode.getParent();
             ModuleBuilder module = BuilderUtils.getParentModule(parent);
@@ -1177,11 +1175,9 @@ public final class YangParserImpl implements YangContextParser {
 
         DataSchemaNodeBuilder nextNodeAfterUses = null;
         for (DataSchemaNodeBuilder childNode : childNodes) {
-            if (!(childNode.isAddedByUses()) && !(childNode.isAugmenting())) {
-                if (childNode.getLine() > usesLine) {
-                    nextNodeAfterUses = childNode;
-                    break;
-                }
+            if (!childNode.isAddedByUses() && !childNode.isAugmenting() && childNode.getLine() > usesLine) {
+                nextNodeAfterUses = childNode;
+                break;
             }
         }
 
@@ -1202,7 +1198,7 @@ public final class YangParserImpl implements YangContextParser {
      * @param module
      *            current module
      */
-    private void resolveUnknownNodes(final Map<URI, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
+    private void resolveUnknownNodes(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules, final ModuleBuilder module) {
         for (UnknownSchemaNodeBuilder usnb : module.getAllUnknownNodes()) {
             QName nodeType = usnb.getNodeType();
             String localName = usnb.getNodeType().getLocalName();
@@ -1257,8 +1253,8 @@ public final class YangParserImpl implements YangContextParser {
      * @param modules
      *            all loaded modules
      */
-    private void checkChoiceCasesForDuplicityQNames(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
-        for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+    private void checkChoiceCasesForDuplicityQNames(final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
+        for (Map.Entry<URI, NavigableMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
             for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
                 final ModuleBuilder moduleBuilder = childEntry.getValue();
                 final Module module = moduleBuilder.build();
@@ -1272,8 +1268,8 @@ public final class YangParserImpl implements YangContextParser {
     }
 
     private void findDuplicityNodesIn(final ChoiceSchemaNode choiceNode, final Module module, final ModuleBuilder moduleBuilder,
-            final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
-        final Set<QName> duplicityTestSet = new HashSet<QName>();
+            final Map<URI, NavigableMap<Date, ModuleBuilder>> modules) {
+        final Set<QName> duplicityTestSet = new HashSet<>();
 
         for (ChoiceCaseNode choiceCaseNode : choiceNode.getCases()) {
 
@@ -1294,7 +1290,7 @@ public final class YangParserImpl implements YangContextParser {
     }
 
     private List<ChoiceSchemaNode> getChoicesFrom(final Module module) {
-        final List<ChoiceSchemaNode> allChoices = new ArrayList<ChoiceSchemaNode>();
+        final List<ChoiceSchemaNode> allChoices = new ArrayList<>();
 
         for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
             findChoicesIn(dataSchemaNode, allChoices);
index 77a0a354dfa341e69805bdf0769eaa46358cb3f0..1703fabae5021894a65a851f23e8d6ac31bc6e91 100644 (file)
@@ -22,9 +22,6 @@ import static org.opendaylight.yangtools.yang.parser.impl.ParserListenerUtils.pa
 import static org.opendaylight.yangtools.yang.parser.impl.ParserListenerUtils.parseYinValue;
 import static org.opendaylight.yangtools.yang.parser.impl.ParserListenerUtils.stringFromNode;
 
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
 import java.net.URI;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -34,8 +31,10 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.NavigableMap;
 import java.util.Set;
 import java.util.TreeMap;
+
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser;
@@ -103,6 +102,9 @@ import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
 
 public final class YangParserListenerImpl extends YangParserBaseListener {
     private static final Logger LOG = LoggerFactory.getLogger(YangParserListenerImpl.class);
@@ -110,9 +112,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     private static final Splitter COLON_SPLITTER = Splitter.on(':');
     private static final String AUGMENT_STR = "augment";
 
-    private final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
+    private static final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
+    private static final String IMPORT_STR = "import";
+    private static final String UNION_STR = "union";
+    private static final String UNKNOWN_NODE_STR = "unknown-node";
     private final SchemaPathStack stack = new SchemaPathStack();
-    private final Map<String, TreeMap<Date, URI>> namespaceContext;
+    private final Map<String, NavigableMap<Date, URI>> namespaceContext;
     private final String sourcePath;
     private QName moduleQName = QName.create(null, new Date(0L), "dummy");
     private ModuleBuilder moduleBuilder;
@@ -120,7 +125,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     private int augmentOrder;
     private String yangModelPrefix;
 
-    public YangParserListenerImpl(final Map<String, TreeMap<Date, URI>> namespaceContext, final String sourcePath) {
+    public YangParserListenerImpl(final Map<String, NavigableMap<Date, URI>> namespaceContext, final String sourcePath) {
         this.namespaceContext = namespaceContext;
         this.sourcePath = sourcePath;
     }
@@ -138,15 +143,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
      * @param tree
      * @return new instance of YangParserListenerImpl
      */
-    public static YangParserListenerImpl create(final Map<String, TreeMap<Date, URI>> namespaceContext,
+    public static YangParserListenerImpl create(final Map<String, NavigableMap<Date, URI>> namespaceContext,
             final String sourcePath, final ParseTreeWalker walker, final ParseTree tree) {
         final YangParserListenerImpl ret = new YangParserListenerImpl(namespaceContext, sourcePath);
         walker.walk(ret, tree);
         return ret;
     }
 
-
-
     @Override
     public void enterModule_stmt(final YangParser.Module_stmtContext ctx) {
         moduleName = stringFromNode(ctx);
@@ -216,7 +219,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterBelongs_to_stmt(final YangParser.Belongs_to_stmtContext ctx) {
         final String belongsTo = stringFromNode(ctx);
-        TreeMap<Date, URI> context = namespaceContext.get(belongsTo);
+        NavigableMap<Date, URI> context = namespaceContext.get(belongsTo);
         final Map.Entry<Date, URI> entry = context.firstEntry();
         // TODO
         // Submodule will contain namespace and revision from module to which it
@@ -339,7 +342,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     public void enterImport_stmt(final Import_stmtContext ctx) {
         final int line = ctx.getStart().getLine();
         final String importName = stringFromNode(ctx);
-        enterLog("import", importName, line);
+        enterLog(IMPORT_STR, importName, line);
 
         String importPrefix = null;
         Date importRevision = null;
@@ -363,14 +366,14 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
 
     @Override
     public void exitImport_stmt(final Import_stmtContext ctx) {
-        exitLog("import");
+        exitLog(IMPORT_STR);
     }
 
     @Override
     public void enterInclude_stmt(YangParser.Include_stmtContext ctx) {
         final int line = ctx.getStart().getLine();
         final String includeName = stringFromNode(ctx);
-        enterLog("import", includeName, line);
+        enterLog(IMPORT_STR, includeName, line);
 
         Date includeRevision = null;
         for (int i = 0; i < ctx.getChildCount(); i++) {
@@ -387,7 +390,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         moduleBuilder.addInclude(includeName, includeRevision);
     }
 
-    @Override public void exitInclude_stmt(YangParser.Include_stmtContext ctx) {
+    @Override
+    public void exitInclude_stmt(YangParser.Include_stmtContext ctx) {
         exitLog("include");
     }
 
@@ -399,7 +403,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         stack.push();
 
         final SchemaPath targetPath = parseXPathString(augmentPath, line);
-        final AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath, augmentOrder++);
+        final AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath,
+                augmentOrder++);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
@@ -508,12 +513,11 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
             } else {
                 QName qname;
                 switch (typeName) {
-                case "union":
-                    qname = BaseTypes.UNION_QNAME;
-                    stack.addNodeToPath(qname);
+                case UNION_STR:
+                    stack.addNodeToPath(BaseTypes.UNION_QNAME);
                     final UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(line, moduleQName.getModule());
-                    final Builder parent = moduleBuilder.getActualNode();
-                    unionBuilder.setParent(parent);
+                    final Builder parentBuilder = moduleBuilder.getActualNode();
+                    unionBuilder.setParent(parentBuilder);
                     moduleBuilder.enterNode(unionBuilder);
                     break;
                 case "identityref":
@@ -534,23 +538,28 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 parent.setTypeQName(typeQName);
                 moduleBuilder.markActualNodeDirty();
             } else {
-                ParserListenerUtils.parseUnknownTypeWithBody(typeBody, parent, typeQName, moduleBuilder,
-                        moduleQName, stack.currentSchemaPath());
+                ParserListenerUtils.parseUnknownTypeWithBody(typeBody, parent, typeQName, moduleBuilder, moduleQName,
+                        stack.currentSchemaPath());
             }
             stack.addNodeToPath(QName.create(moduleQName.getModule(), typeQName.getLocalName()));
         }
     }
 
     /**
-     * Method transforms string representation of yang element (i.e. leaf name, container name etc.) into QName.
-     * The namespace of QName is assigned from parent module same as revision date of module. If String qname parameter
-     * contains ":" the string is evaluated as prefix:name of element. In this case method will look into import map
-     * and extract correct ModuleImport. If such import is not present in import map the method will throw {@link YangParseException}
-     * <br>
-     * If ModuleImport is present but the value of namespace in ModuleImport is <code>null</code> the method will throw {@link YangParseException}
+     * Method transforms string representation of yang element (i.e. leaf name,
+     * container name etc.) into QName. The namespace of QName is assigned from
+     * parent module same as revision date of module. If String qname parameter
+     * contains ":" the string is evaluated as prefix:name of element. In this
+     * case method will look into import map and extract correct ModuleImport.
+     * If such import is not present in import map the method will throw
+     * {@link YangParseException} <br>
+     * If ModuleImport is present but the value of namespace in ModuleImport is
+     * <code>null</code> the method will throw {@link YangParseException}
      *
-     * @param qnameString QName value as String
-     * @param line line in Yang model document where QName occur.
+     * @param qnameString
+     *            QName value as String
+     * @param line
+     *            line in Yang model document where QName occur.
      * @return transformed string qname parameter as QName structure.
      *
      * @throws YangParseException
@@ -570,10 +579,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 if (imp == null) {
                     LOG.debug("Error in module {} at line {}: No import found with prefix {}", moduleName, line, prefix);
                     throw new YangParseException(moduleName, line, "Error in module " + moduleName
-                        + " No import found with prefix " + prefix + " not found.");
+                            + " No import found with prefix " + prefix + " not found.");
                 }
                 Date revision = imp.getRevision();
-                TreeMap<Date, URI> namespaces = namespaceContext.get(imp.getModuleName());
+                NavigableMap<Date, URI> namespaces = namespaceContext.get(imp.getModuleName());
                 if (namespaces == null) {
                     throw new YangParseException(moduleName, line, String.format("Imported module %s not found",
                             imp.getModuleName()));
@@ -583,9 +592,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                     revision = namespaces.lastEntry().getKey();
                     namespace = namespaces.lastEntry().getValue();
                 } else {
-                    // FIXME: this lookup does not look right, as we will end up with
-                    //        a qname which does not have a namespace. At any rate we
-                    //        should arrive at a QNameModule!
+                    // FIXME: this lookup does not look right, as we will end up
+                    // with
+                    // a qname which does not have a namespace. At any rate we
+                    // should arrive at a QNameModule!
                     namespace = namespaces.get(revision);
                 }
 
@@ -599,7 +609,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void exitType_stmt(final YangParser.Type_stmtContext ctx) {
         final String typeName = stringFromNode(ctx);
-        if ("union".equals(typeName)) {
+        if (UNION_STR.equals(typeName)) {
             moduleBuilder.exitNode();
         }
         exitLog("type", stack.removeNodeFromPath());
@@ -718,7 +728,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         stack.push();
 
         final SchemaPath targetPath = parseXPathString(augmentPath, line);
-        final AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath, augmentOrder++);
+        final AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath,
+                augmentOrder++);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
             final ParseTree child = ctx.getChild(i);
@@ -816,10 +827,9 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
             } else if (childNode instanceof Key_stmtContext) {
                 final Set<String> key = createListKey((Key_stmtContext) childNode);
                 builder.setKeys(key);
-            } else if (childNode instanceof YangParser.Identifier_stmtContext) {
-                if (childNode.getChild(0).toString().equals("union")) {
-                    throw new YangParseException(moduleName, line, "Union statement is not allowed inside a list statement");
-                }
+            } else if (childNode instanceof YangParser.Identifier_stmtContext
+                    && UNION_STR.equals(childNode.getChild(0).toString())) {
+                throw new YangParseException(moduleName, line, "Union statement is not allowed inside a list statement");
             }
         }
     }
@@ -938,16 +948,18 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     @Override
     public void exitIdentifier_stmt(final YangParser.Identifier_stmtContext ctx) {
         moduleBuilder.exitNode();
-        exitLog("unknown-node", stack.removeNodeFromPath());
+        exitLog(UNKNOWN_NODE_STR, stack.removeNodeFromPath());
     }
 
-    @Override public void enterUnknown_statement(final YangParser.Unknown_statementContext ctx) {
+    @Override
+    public void enterUnknown_statement(final YangParser.Unknown_statementContext ctx) {
         handleUnknownNode(ctx.getStart().getLine(), ctx);
     }
 
-    @Override public void exitUnknown_statement(final YangParser.Unknown_statementContext ctx) {
+    @Override
+    public void exitUnknown_statement(final YangParser.Unknown_statementContext ctx) {
         moduleBuilder.exitNode();
-        exitLog("unknown-node", stack.removeNodeFromPath());
+        exitLog(UNKNOWN_NODE_STR, stack.removeNodeFromPath());
     }
 
     @Override
@@ -1146,16 +1158,19 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
 
     private void handleUnknownNode(final int line, final ParseTree ctx) {
         final String nodeParameter = stringFromNode(ctx);
-        enterLog("unknown-node", nodeParameter, line);
+        enterLog(UNKNOWN_NODE_STR, nodeParameter, line);
 
         final String nodeTypeStr = ctx.getChild(0).getText();
         final QName nodeType = parseQName(nodeTypeStr, line);
 
         QName qname = null;
         try {
-            //FIXME: rewrite whole method to handle unknown nodes properly.
-            // This should be bugfix for bug https://bugs.opendaylight.org/show_bug.cgi?id=1539
-            // After this fix bug https://bugs.opendaylight.org/show_bug.cgi?id=1538 MUST be fixed since
+            // FIXME: rewrite whole method to handle unknown nodes properly.
+            // This should be bugfix for bug
+            // https://bugs.opendaylight.org/show_bug.cgi?id=1539
+            // After this fix bug
+            // https://bugs.opendaylight.org/show_bug.cgi?id=1538 MUST be fixed
+            // since
             // they are dependent!!!
             if (Strings.isNullOrEmpty(nodeParameter)) {
                 qname = nodeType;
index 252a782e1567eea80aad6ed7365df494decb9bd4..91c5c18028ffd58f9d232006868055c6b96d8ab1 100644 (file)
@@ -95,7 +95,7 @@ public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<In
         return stream;
     }
 
-    private final class SourceContext extends AbstractObjectRegistration<URL> //
+    private final class SourceContext extends AbstractObjectRegistration<URL>
             implements Identifiable<SourceIdentifier> {
 
         final SourceIdentifier identifier;
@@ -146,7 +146,7 @@ public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<In
         YangSourceContext yangSourceContext = YangSourceContext.createFrom(sourcesMap, this);
         LOG.debug("Trying to create schema context from {}", sourcesMap.keySet());
 
-        if (yangSourceContext.getMissingDependencies().size() != 0) {
+        if (!yangSourceContext.getMissingDependencies().isEmpty()) {
             LOG.debug("Omitting {} because of unresolved dependencies", yangSourceContext.getMissingDependencies().keySet());
             LOG.debug("Missing model sources for {}", yangSourceContext.getMissingSources());
         }
index bbe69e0410b701c924ef3972b81ca1400fb9df64..fcb2c1835f83f996caafea819f825f84c6eaa3d2 100644 (file)
@@ -62,9 +62,9 @@ public abstract class YangModelDependencyInfo {
         this.revision = formattedRevision == null ? null : QName.parseRevision(formattedRevision);
         this.moduleImports = imports;
         this.submoduleIncludes = includes;
-        this.dependencies = ImmutableSet.<ModuleImport> builder() //
-                .addAll(moduleImports) //
-                .addAll(submoduleIncludes) //
+        this.dependencies = ImmutableSet.<ModuleImport> builder()
+                .addAll(moduleImports)
+                .addAll(submoduleIncludes)
                 .build();
     }
 
@@ -214,8 +214,8 @@ public abstract class YangModelDependencyInfo {
         return builder.build();
     }
 
-    public static String getLatestRevision(final Revision_stmtsContext revision_stmts) {
-        List<Revision_stmtContext> revisions = revision_stmts.getRuleContexts(Revision_stmtContext.class);
+    public static String getLatestRevision(final Revision_stmtsContext revisionStmts) {
+        List<Revision_stmtContext> revisions = revisionStmts.getRuleContexts(Revision_stmtContext.class);
         String latestRevision = null;
         for (Revision_stmtContext revisionStmt : revisions) {
             String currentRevision = getArgumentString(revisionStmt);
@@ -248,11 +248,11 @@ public abstract class YangModelDependencyInfo {
         return builder.build();
     }
 
-    private static Date getRevision(final Revision_date_stmtContext revision_date_stmt) {
-        if (revision_date_stmt == null) {
+    private static Date getRevision(final Revision_date_stmtContext revisionDateStmt) {
+        if (revisionDateStmt == null) {
             return null;
         }
-        String formatedDate = getArgumentString(revision_date_stmt);
+        String formatedDate = getArgumentString(revisionDateStmt);
         return QName.parseRevision(formatedDate);
     }
 
@@ -285,6 +285,12 @@ public abstract class YangModelDependencyInfo {
 
         private final String belongsTo;
 
+        private SubmoduleDependencyInfo(final String name, final String latestRevision, final String belongsTo,
+                                        final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
+            super(name, latestRevision, imports, includes);
+            this.belongsTo = belongsTo;
+        }
+
         /**
          * Returns name of parent module.
          *
@@ -293,12 +299,6 @@ public abstract class YangModelDependencyInfo {
             return belongsTo;
         }
 
-        private SubmoduleDependencyInfo(final String name, final String latestRevision, final String belongsTo,
-                final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
-            super(name, latestRevision, imports, includes);
-            this.belongsTo = belongsTo;
-        }
-
         @Override
         public String toString() {
             return "Submodule [name=" + getName() + ", revision=" + getRevision() + ", dependencies="
index ebe602d5a72c42a06fec63899b8d63a0d8b9d2ce..f8fc1770b827327621ddd370451dd71bac370204 100644 (file)
@@ -7,22 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.parser.repo;
 
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.net.URI;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,9 +15,11 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.NavigableMap;
 import java.util.Set;
-import java.util.TreeMap;
+
 import javax.annotation.Nullable;
+
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
 import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
@@ -53,6 +39,23 @@ import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.AsyncFunction;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
 final class SharedSchemaContextFactory implements SchemaContextFactory {
     private static final ExceptionMapper<SchemaResolutionException> MAPPER = ReflectiveExceptionMapper.create("resolve sources", SchemaResolutionException.class);
     private static final Logger LOG = LoggerFactory.getLogger(SharedSchemaContextFactory.class);
@@ -87,7 +90,7 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
 
             final Map<SourceIdentifier, ParserRuleContext> asts =
                     Maps.transformValues(srcs, ASTSchemaSource.GET_AST);
-            final Map<String, TreeMap<Date, URI>> namespaceContext = BuilderUtils.createYangNamespaceContext(
+            final Map<String, NavigableMap<Date, URI>> namespaceContext = BuilderUtils.createYangNamespaceContext(
                     asts.values(), Optional.<SchemaContext>absent());
 
             final ParseTreeWalker walker = new ParseTreeWalker();
index b0c23ea3c5ea83c4dd1463285279089da4df460d..583c0d821e67b6689934c4174ee4d44d4d8e3b27 100644 (file)
@@ -81,7 +81,7 @@ public abstract class AbstractStatementSupport<A, D extends DeclaredStatement<A>
      *
      */
     @Override
-    public void onLinkageDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException, SourceException {
+    public void onLinkageDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException {
         // NOOP for most implementations
     }
 
@@ -95,8 +95,7 @@ public abstract class AbstractStatementSupport<A, D extends DeclaredStatement<A>
      *
      */
     @Override
-    public void onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException,
-            SourceException {
+    public void onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException {
         // NOOP for most implementations
     }
 
@@ -110,7 +109,7 @@ public abstract class AbstractStatementSupport<A, D extends DeclaredStatement<A>
      *
      */
     @Override
-    public void onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException, SourceException {
+    public void onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException {
         // NOOP for most implementations
     }
 
index 129110d8537491c41716a7db9f59d40bcdcb7042..6522af9227cb35e465ba6b5b315a962ab68f8c38 100644 (file)
@@ -46,8 +46,6 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
 
         @Nullable  <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(Class<N> type, K key);
 
-        //<K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(Class<N> type);
-
         @Nullable  <K, V, N extends IdentifierNamespace<K, V>> void addToLocalStorage(Class<N> type, K key, V value);
 
     }
@@ -103,8 +101,6 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
 
     public abstract V getFrom(NamespaceStorageNode storage, K key);
 
-    //public abstract Map<K, V> getAllFrom(NamespaceStorageNode storage);
-
     public abstract void addTo(NamespaceStorageNode storage,K key,V value);
 
     @Override
@@ -116,10 +112,6 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
         return storage.getFromLocalStorage(getIdentifier(), key);
     }
 
-//    protected final Map<K, V> getAllFromLocalStorage(NamespaceStorageNode storage) {
-//        return storage.getAllFromLocalStorage(getIdentifier());
-//    }
-
     protected final void addToStorage(NamespaceStorageNode storage,K key,V value) {
         storage.addToLocalStorage(getIdentifier(),key,value);
     }
@@ -142,15 +134,6 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
             return getFromLocalStorage(current,key);
         }
 
-//        @Override
-//        public Map<K, V> getAllFrom(final NamespaceStorageNode storage) {
-//            NamespaceStorageNode current = storage;
-//            while(current.getStorageNodeType() != storageType) {
-//                current = current.getParentNamespaceStorage();
-//            }
-//            return getAllFromLocalStorage(current);
-//        }
-
         @Override
         public void addTo(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value) {
             NamespaceStorageNode current = storage;
index e270f806a91f93812d13dab32d8cd4c36c10732a..f240105a0998758a117321d47eadbd0b913bee9b 100644 (file)
@@ -69,8 +69,7 @@ public interface StatementSupport<A, D extends DeclaredStatement<A>, E extends E
      * @param stmt
      *            Context of added statement.
      */
-     void onLinkageDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException,
-            SourceException;
+     void onLinkageDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException;
 
     /**
      *
@@ -89,8 +88,7 @@ public interface StatementSupport<A, D extends DeclaredStatement<A>, E extends E
      *            Context of added statement. Argument and statement parent is
      *            accessible.
      */
-     void onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException,
-            SourceException;
+     void onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException;
 
     /**
      *
@@ -110,7 +108,6 @@ public interface StatementSupport<A, D extends DeclaredStatement<A>, E extends E
      *            Context of added statement. Argument and statement parent is
      *            accessible.
      */
-     void onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException,
-            SourceException;
+     void onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException;
 
 }
\ No newline at end of file
index 01435600334c555d263c69ded77d1dff597b2452..f137faf6677280f75afacad1e806728e9fc935cd 100644 (file)
@@ -23,18 +23,18 @@ public final class StatementSupportBundle implements Immutable,NamespaceBehaviou
     private final ImmutableMap<QName, StatementSupport<?,?,?>> definitions;
     private final ImmutableMap<Class<?>, NamespaceBehaviour<?, ?, ?>> namespaceDefinitions;
 
-    public ImmutableMap<QName, StatementSupport<?, ?, ?>> getDefinitions() {
-        return definitions;
-    }
-
     private StatementSupportBundle(StatementSupportBundle parent,
-            ImmutableMap<QName, StatementSupport<?, ?, ?>> statements,
-            ImmutableMap<Class<?>, NamespaceBehaviour<?, ?, ?>> namespaces) {
+                                   ImmutableMap<QName, StatementSupport<?, ?, ?>> statements,
+                                   ImmutableMap<Class<?>, NamespaceBehaviour<?, ?, ?>> namespaces) {
         this.parent = parent;
         this.definitions = statements;
         this.namespaceDefinitions = namespaces;
     }
 
+    public ImmutableMap<QName, StatementSupport<?, ?, ?>> getDefinitions() {
+        return definitions;
+    }
+
     public static Builder builder() {
         return new Builder(EMPTY);
     }
@@ -54,9 +54,7 @@ public final class StatementSupportBundle implements Immutable,NamespaceBehaviou
              * Safe cast, previous checkState checks equivalence of key from
              * which type argument are derived
              */
-            @SuppressWarnings("unchecked")
-            NamespaceBehaviour<K, V, N> casted = (NamespaceBehaviour<K, V, N>) potential;
-            return casted;
+            return (NamespaceBehaviour<K, V, N>) potential;
         }
         if (parent != null) {
             return parent.getNamespaceBehaviour(namespace);
index 1f86de80d777717099c5e2c4b287ed09cace70b8..eefd87f9a98e1533e428656baaef2a3f13134857 100644 (file)
@@ -81,8 +81,9 @@ public final class StmtContextUtils {
     public static final StmtContext<?, ?, ?> findFirstDeclaredSubstatement(
             StmtContext<?, ?, ?> stmtContext, int startIndex, Class<? extends DeclaredStatement<?>>... types) {
 
-        if (startIndex >= types.length)
+        if (startIndex >= types.length) {
             return null;
+        }
 
         Collection<? extends StmtContext<?, ?, ?>> declaredSubstatements = stmtContext
                 .declaredSubstatements();
index cb0dd2c3437cf505d86b9ad120de14603bd7be09..ad6d70a823c9060d454394b2460d8cc43ce4f2b3 100644 (file)
@@ -103,9 +103,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
              * Safe cast, previous checkState checks equivalence of key from
              * which type argument are derived
              */
-            @SuppressWarnings("unchecked")
-            NamespaceBehaviourWithListeners<K, V, N> casted = (NamespaceBehaviourWithListeners<K, V, N>) potential;
-            return casted;
+            return (NamespaceBehaviourWithListeners<K, V, N>) potential;
         }
         throw new NamespaceNotAvailableException("Namespace " + type + "is not available in phase " + currentPhase);
     }
@@ -185,7 +183,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
 
     private  void completePhaseActions() throws ReactorException {
         Preconditions.checkState(currentPhase != null);
-        ArrayList<SourceSpecificContext> sourcesToProgress = Lists.newArrayList(sources);
+        List<SourceSpecificContext> sourcesToProgress = Lists.newArrayList(sources);
         try {
             boolean progressing = true;
             while(progressing) {
index 638952cf3dc44241d0479ede263f6dc16569e693..225ce471106174bf30983c23c8f57e702bc9d684 100644 (file)
@@ -65,7 +65,8 @@ class ModifierImpl implements ModelActionBuilder {
 
     private void tryToResolve() throws InferenceException {
         if(action == null) {
-            return; // Action was not yet defined
+            // Action was not yet defined
+            return;
         }
         if(removeSatisfied()) {
             applyAction();
@@ -77,7 +78,8 @@ class ModifierImpl implements ModelActionBuilder {
         boolean allSatisfied = true;
         while(prereq.hasNext()) {
             if(prereq.next().isDone()) {
-                prereq.remove(); // We are removing current prerequisite from list.
+                // We are removing current prerequisite from list.
+                prereq.remove();
             } else {
                 allSatisfied  = false;
             }
index 2fe7f01138a3bdc72e3f7b136faea0a3bf55d8fe..695251f369a89f78a36f2a961306f368ae4e2733 100644 (file)
@@ -99,9 +99,7 @@ class RootStatementContext<A, D extends DeclaredStatement<A>, E extends Effectiv
     public StatementContextBase<A, D, E> createCopy(QNameModule newQNameModule, StatementContextBase<?, ?, ?> newParent)
             throws SourceException {
 
-        StatementContextBase<A, D, E> copy = new RootStatementContext<A, D, E>(
-                this, newQNameModule);
-        return copy;
+        return new RootStatementContext<>(this, newQNameModule);
     }
 
     @Override
index 94f29a3cca5af98f830cc9697f2af775d6a662cd..43692ff0dae32f1bee0b7469e0c2ae761d854cae 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Collections;
 import java.util.EventListener;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.Map;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
@@ -101,7 +102,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
     private final StatementIdentifier identifier;
     private final StatementSourceReference statementDeclSource;
 
-    private LinkedHashMap<StatementIdentifier, StatementContextBase<?, ?, ?> > substatements = new LinkedHashMap<>();
+    private Map<StatementIdentifier, StatementContextBase<?, ?, ?> > substatements = new LinkedHashMap<>();
 
     private Collection<StatementContextBase<?, ?, ?>> declared = new ArrayList<>();
     private Collection<StatementContextBase<?, ?, ?>> effective = new ArrayList<>();
index 2e78e75ed28b8b5188df2364c3e8c392ec918496..7fd1442691ffb4ee9b412c664381372a495bc5d4 100644 (file)
@@ -13,7 +13,6 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceNotAvailableException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementFactory;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
@@ -36,7 +35,7 @@ public class StatementDefinitionContext<A,D extends DeclaredStatement<A>,E exten
     }
 
 
-    public void checkNamespaceAllowed(Class<? extends IdentifierNamespace<?,?>> namespace) throws NamespaceNotAvailableException {
+    public void checkNamespaceAllowed(Class<? extends IdentifierNamespace<?,?>> namespace) {
         // Noop
     }
 
index 29cac6ead5da3f4ab38db09a453b014ec8c5d547..808518d9d84b4b58c5c858c0c4aaaea36364f86c 100644 (file)
@@ -107,8 +107,7 @@ class SubstatementContext<A,D extends DeclaredStatement<A>, E extends EffectiveS
 
     @Override
     public StatementContextBase<A, D, E>  createCopy(QNameModule newQNameModule, StatementContextBase<?, ?, ?> newParent) throws SourceException {
-        StatementContextBase<A,D,E> copy = new SubstatementContext<A,D,E>(this,newQNameModule, newParent);
-        return copy;
+        return new SubstatementContext<>(this,newQNameModule, newParent);
     }
 
     @Override
index d4d59d630deea46085e2783e945f73dc3a2b26ee..373ec1f40e78b894f4b0e12620c864e6c57c94d1 100644 (file)
@@ -32,12 +32,12 @@ import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 
 public final class AugmentUtils {
 
-    private AugmentUtils() {
-    }
-
     private static final String REGEX_PATH_REL1 = "\\.\\.?\\s*/(.+)";
     private static final String REGEX_PATH_REL2 = "//.*";
 
+    private AugmentUtils() {
+    }
+
     public static Iterable<QName> parseAugmentPath(StmtContext<?, ?, ?> ctx, String path) {
 
         if (path.matches(REGEX_PATH_REL1) || path.matches(REGEX_PATH_REL2)) {
@@ -111,19 +111,17 @@ public final class AugmentUtils {
         noCopyDefSet.add(Rfc6020Mapping.USES);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        return (!noCopyDefSet.contains(def));
+        return !noCopyDefSet.contains(def);
     }
 
     public static boolean isReusedByAugment(StmtContext<?, ?, ?> stmtContext) {
 
-        HashSet<StatementDefinition> reusedDefSet = new HashSet<>();
+        Set<StatementDefinition> reusedDefSet = new HashSet<>();
         reusedDefSet.add(Rfc6020Mapping.TYPEDEF);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        if (reusedDefSet.contains(def))
-            return true;
-        else
-            return false;
+
+        return reusedDefSet.contains(def);
     }
 
     public static StatementContextBase<?, ?, ?> getAugmentTargetCtx(
index 316013160333f79d9b925299ca0ed70ec0513cf4..2aca8a1c806ef0e68bfc7ba4232554fef6bd5cb1 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.CaseEffectiveStatementImpl;
+import java.util.Collection;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PresenceEffectiveStatementImpl;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -24,9 +26,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.util.Collection;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.CaseEffectiveStatementImpl;
 
 public class CaseStatementImpl extends AbstractDeclaredStatement<QName> implements CaseStatement {
 
index 4f2a7ce735e2f3b6db6649d5f23005a0a09acf82..30d6ef0769c46e933d3bf28edf829299c98469eb 100644 (file)
@@ -7,25 +7,24 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.GroupingEffectiveStatementImpl;
-
-import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import java.util.Collection;
+
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.GroupingEffectiveStatementImpl;
 
 public class GroupingStatementImpl extends AbstractDeclaredStatement<QName>
         implements GroupingStatement {
index 131ac39f848f2fd3ff0c3f5256c481d93c7306d5..c1194deec5e3749eeebd0627a2a5f811252e681b 100644 (file)
@@ -87,8 +87,7 @@ public final class GroupingUtils {
 
                 if (targetQNameModule.equals(sourceQNameModule)) {
                     return null;
-                }
-                else {
+                } else {
                     return targetQNameModule;
                 }
             } else {
@@ -109,7 +108,7 @@ public final class GroupingUtils {
         noCopyDefSet.add(Rfc6020Mapping.USES);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        return (!noCopyDefSet.contains(def));
+        return !noCopyDefSet.contains(def);
     }
 
     public static boolean isReusedByUses(StmtContext<?, ?, ?> stmtContext) {
@@ -118,7 +117,7 @@ public final class GroupingUtils {
         reusedDefSet.add(Rfc6020Mapping.TYPEDEF);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        return (reusedDefSet.contains(def));
+        return reusedDefSet.contains(def);
     }
 
     public static void resolveUsesNode(
@@ -134,7 +133,9 @@ public final class GroupingUtils {
             if (StmtContextUtils.producesDeclared(subStmtCtx, RefineStatement.class)) {
                 // :TODO resolve and perform refine statement
             }
-
+            if (StmtContextUtils.producesDeclared(subStmtCtx, AugmentStatement.class)) {
+                // :TODO find target node and perform augmentation
+            }
             // :TODO resolve other uses substatements
         }
     }
index e2c6b531db1e8eae0f93b09d5327f92f82466c0d..963737a7decdb5f6320b5b228d9b9c4d4e27b251 100644 (file)
@@ -9,32 +9,32 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
 
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl;
-
-import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
-import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
-import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
-import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
-import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
-import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
-import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Date;
+
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleIdentifierImpl;
 import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl;
+
+import com.google.common.base.Optional;
 
 public class ModuleStatementSupport extends
         AbstractStatementSupport<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> {
index 02e94621919299b71a9cbfec5d9330c854fa086c..16dc0071c15b21bfeef6fb12cbd999e3268cab55 100644 (file)
@@ -26,7 +26,7 @@ public class PrefixStatementImpl extends AbstractDeclaredStatement<String> imple
 
         @Override
         public String parseArgumentValue(StmtContext<?, ?,?> ctx, String value) {
-            return (value);
+            return value;
         }
 
         @Override
index 7349082ec503e8610f5e2bb226838306bba575c2..ff306a55e47c750e957a674a03a80e17a7057f54 100644 (file)
@@ -7,29 +7,29 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.findFirstDeclaredSubstatement;
+import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
 
-import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
-import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Date;
+
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleIdentifierImpl;
+import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+import com.google.common.base.Optional;
 
 public class SubmoduleStatementImpl extends
         AbstractRootStatement<SubmoduleStatement> implements SubmoduleStatement {
index 8a0a8290d8ccd02fba1b9906b24e31a70dc35d36..102ad007ff87b58aed7776614bef055331327802 100644 (file)
@@ -10,15 +10,10 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.FULL_DECLARATION;
 
 import java.util.Collection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
@@ -38,6 +33,8 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UsesEffectiveStatementImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implements UsesStatement {
index 980abfef6081e677c3a4a3a59a946a5fc58c2d59..99ca6c126c5243d4303cb9fc60cb4f11d45f8624 100644 (file)
@@ -52,9 +52,6 @@ import org.slf4j.LoggerFactory;
 
 public final class Utils {
 
-    private Utils() {
-    }
-
     private static final Logger LOG = LoggerFactory.getLogger(Utils.class);
     private static final CharMatcher DOUBLE_QUOTE_MATCHER = CharMatcher.is('"');
     private static final CharMatcher SINGLE_QUOTE_MATCHER = CharMatcher.is('\'');
@@ -63,6 +60,9 @@ public final class Utils {
 
     private static final String REGEX_PATH_ABS = "/[^/].*";
 
+    private Utils() {
+    }
+
     public static List<String> splitPathToNodeNames(String path) {
 
         Splitter keySplitter = Splitter.on(SEPARATOR_NODENAME).omitEmptyStrings().trimResults();
@@ -141,7 +141,7 @@ public final class Utils {
     public static String stringFromStringContext(final YangStatementParser.ArgumentContext context) {
         StringBuilder sb = new StringBuilder();
         List<TerminalNode> strings = context.STRING();
-        if (strings.size() == 0) {
+        if (strings.isEmpty()) {
             strings = Arrays.asList(context.IDENTIFIER());
         }
         for (TerminalNode stringNode : strings) {
@@ -163,7 +163,7 @@ public final class Utils {
 
     public static QName qNameFromArgument(StmtContext<?, ?, ?> ctx, String value) {
 
-        String prefix = null;
+        String prefix;
         QNameModule qNameModule = null;
         try {
             qNameModule = QNameModule.create(new URI(""), new Date(0));
index 484cd548c8a3d7e9c033edfb22419629108bbf6b..9bd91b6619ad892749081772ef61149a3f8d4b4f 100644 (file)
@@ -17,6 +17,8 @@ import java.util.Map;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+import java.util.Map;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
index e84af21131271e4eab3ed1a32204323320f29748..a4a94111a430e92c5985a70f9e54a325e432a0ec 100644 (file)
@@ -19,6 +19,7 @@ import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.NavigableSet;
 import java.util.Set;
 import java.util.TreeSet;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -40,9 +41,9 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
 public abstract class AbstractEffectiveSchemaContext implements SchemaContext {
 
-    protected static final Supplier<TreeSet<Module>> MODULE_SET_SUPPLIER = new Supplier<TreeSet<Module>>() {
+    protected static final Supplier<NavigableSet<Module>> MODULE_SET_SUPPLIER = new Supplier<NavigableSet<Module>>() {
         @Override
-        public TreeSet<Module> get() {
+        public NavigableSet<Module> get() {
             return new TreeSet<>(REVISION_COMPARATOR);
         }
     };
index ff417e0e1d8e6c1c47b7721a0cc524c148a66f52..85a5e63d3e4c30b37cd02f436689336efbab79f8 100644 (file)
@@ -49,16 +49,16 @@ public class AnyXmlEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
     }
 
     @Override
index 0d3f3741f768db64de227e2e8b2dc5b924086a69..39e51d1f9793ed834da551205d402d3b6d0bd66c 100644 (file)
@@ -60,16 +60,16 @@ public class AugmentEffectiveStatementImpl
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
     }
 
     public void setCopyOf(final AugmentationSchema build) {
index e406e610973aa71086d8a89897fcbe111db02a16..e748a3e9ee4288d9e72159592357dd43e860a979 100644 (file)
@@ -55,22 +55,22 @@ public class CaseEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
     }
 
     @Override
index 00262b5070e97c8cae5224eb957aa2d76aff6ed7..d74600e37d7b383f565af34968bc225e2f29182e 100644 (file)
@@ -58,28 +58,28 @@ public class ChoiceEffectiveStatementImpl extends AbstractEffectiveDocumentedNod
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-        HashSet<ChoiceCaseNode> cases = new HashSet<ChoiceCaseNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
+        Set<ChoiceCaseNode> casesInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
             if (effectiveStatement instanceof ChoiceCaseNode) {
                 ChoiceCaseNode choiceCaseNode = (ChoiceCaseNode) effectiveStatement;
-                cases.add(choiceCaseNode);
+                casesInit.add(choiceCaseNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
-        this.cases = ImmutableSet.copyOf(cases);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
+        this.cases = ImmutableSet.copyOf(casesInit);
     }
 
     @Override
index d7a70c4a66d020d82a79d0c09c33221200b010d6..b9501f7c1e7d77e63ef84d9cc1bc4d626d2ea33c 100644 (file)
@@ -60,22 +60,22 @@ public class ContainerEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
     }
 
     @Override
index cc837626ed4a1159844ebf7de4eaa7391ff06b51..4cedda12fa6c55db907185ad5b05d864776a86d3 100644 (file)
@@ -42,21 +42,21 @@ public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext {
         this.rootEffectiveStatements = ImmutableList
                 .copyOf(rootEffectiveStatements);
 
-        HashSet<Module> modules = new HashSet<Module>();
+        Set<Module> modulesInit = new HashSet<>();
         for (EffectiveStatement<?, ?> rootEffectiveStatement : rootEffectiveStatements) {
             if (rootEffectiveStatement instanceof Module) {
                 Module module = (Module) rootEffectiveStatement;
-                modules.add(module);
+                modulesInit.add(module);
             }
         }
-        this.modules = ImmutableSet.copyOf(modules);
+        this.modules = ImmutableSet.copyOf(modulesInit);
 
         final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
                 new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
         final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
                 new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
 
-        for (Module m : modules) {
+        for (Module m : modulesInit) {
             nameMap.put(m.getName(), m);
             nsMap.put(m.getNamespace(), m);
         }
index 804be7bd029e5078ad33799a20a0793911852900..fd269a1f163d67f89a47795369571e65b4231bd0 100644 (file)
@@ -51,11 +51,11 @@ abstract public class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
         Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements = ctx
                 .effectiveSubstatements();
 
-        Collection<StatementContextBase<?, ?, ?>> substatements = new LinkedList<StatementContextBase<?, ?, ?>>();
-        substatements.addAll(declaredSubstatements);
-        substatements.addAll(effectiveSubstatements);
+        Collection<StatementContextBase<?, ?, ?>> substatementsInit = new LinkedList<>();
+        substatementsInit.addAll(declaredSubstatements);
+        substatementsInit.addAll(effectiveSubstatements);
 
-        this.substatements = FluentIterable.from(substatements)
+        this.substatements = FluentIterable.from(substatementsInit)
                 .transform(StmtContextUtils.buildEffective()).toList();
     }
 
@@ -127,7 +127,7 @@ abstract public class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
             result = Collection.class.cast(Collections2.filter(substatements,
                     Predicates.instanceOf(type)));
         } catch (NoSuchElementException e) {
-            result = Collections.EMPTY_LIST;
+            result = Collections.emptyList();
         }
         return result;
     }
@@ -152,7 +152,7 @@ abstract public class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
             result = Collection.class.cast(Collections2.filter(substatements,
                     Predicates.instanceOf(type)));
         } catch (NoSuchElementException e) {
-            result = Collections.EMPTY_LIST;
+            result = Collections.emptyList();
         }
         return result;
     }
index df925dd16be2925411d66cb98f08d3495158b9d8..f9f1d8066557af3a21c814b67d07819e0b93f688 100644 (file)
@@ -55,7 +55,7 @@ public class ExtensionEffectiveStatementImpl extends
         if (yinElement != null) {
             this.yin = yinElement.argument();
         } else {
-            yin = false;
+            this.yin = false;
         }
 
     }
@@ -63,16 +63,16 @@ public class ExtensionEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
     }
 
     @Override
index 38c982ff61cdb7034a5f937fb78f5a623ba8c0bc..8ee820a7ba2eafa961d54f59b9fc9997fad14bc0 100644 (file)
@@ -49,16 +49,16 @@ public class IdentityEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
     }
 
     @Override
index 54e2f10b247a8c95fc7c76db355c98358d692015..e0ded9ec84b9068079599de01bac77927d4aec3b 100644 (file)
@@ -59,22 +59,22 @@ public class InputEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
     }
 
     @Override
index 45ecda59e1a1b81932f556c631f359fe7bcc3c29..3d59091cc528622e678dafe9b867c64fcd6fd6cc 100644 (file)
@@ -55,16 +55,16 @@ public class LeafEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
     }
 
     @Override
index 768a99e084d42920f9e11d598fee936fea499b30..77487441e4167aa4ddc4c638922362d7f6c3f529 100644 (file)
@@ -51,16 +51,16 @@ public class LeafListEffectiveStatementImpl extends AbstractEffectiveDocumentedN
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
     }
 
     @Override
index 30ba7d425bfefd941e7b0eacc05ed9b536446be1..f9629a114cff9d68e18df5d5f6b83b541dad12ee 100644 (file)
@@ -54,38 +54,38 @@ public class ListEffectiveStatementImpl extends
      *
      */
     private void initKeyDefinition() {
-        List<QName> keyDefinition = new LinkedList<QName>();
+        List<QName> keyDefinitionInit = new LinkedList<QName>();
         KeyEffectiveStatementImpl key = firstEffective(KeyEffectiveStatementImpl.class);
 
         if (key != null) {
             Collection<SchemaNodeIdentifier> keyParts = key.argument();
             for (SchemaNodeIdentifier keyPart : keyParts) {
-                keyDefinition.add(keyPart.getLastComponent());
+                keyDefinitionInit.add(keyPart.getLastComponent());
             }
         }
 
-        this.keyDefinition = ImmutableList.copyOf(keyDefinition);
+        this.keyDefinition = ImmutableList.copyOf(keyDefinitionInit);
     }
 
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<UnknownSchemaNode>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<AugmentationSchema>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
     }
 
     @Override
index 1e6d51cf8b27912fdf920afea11c4f1b00c1b696..390769b3561df5251e74cbe9771b80b1618fd64e 100644 (file)
@@ -73,22 +73,22 @@ public class ModuleEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
 
         // :TODO other substatement collections ...
     }
index 4afe4f4dcf554b800fc0095fd66695cb84d181ef..b53772ae92ae421fe1297951e6f15f72ba8cad4c 100644 (file)
@@ -46,22 +46,22 @@ public class NotificationEffectiveStatementImpl
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
     }
 
     @Override
index e35efd9948d1ac9740eb90285df46ac458909acc..c6d21e86a7bc6f5a796beedfa687d6b2bc829aaa 100644 (file)
@@ -59,22 +59,22 @@ public class OutputEffectiveStatementImpl extends
     private void initSubstatementCollections() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<AugmentationSchema> augmentationsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof AugmentationSchema) {
                 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
-                augmentations.add(augmentationSchema);
+                augmentationsInit.add(augmentationSchema);
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.augmentations = ImmutableSet.copyOf(augmentations);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.augmentations = ImmutableSet.copyOf(augmentationsInit);
     }
 
     @Override
index a0d1ad12293e1e51f739fff4e227abfaea8fc64e..1fcecde23e0ab67808ff54699d8608183a6a82c1 100644 (file)
@@ -49,22 +49,22 @@ public class RpcEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<Q
     private void initSubstatements() {
         Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
 
-        LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
-        HashSet<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();
-        HashSet<TypeDefinition<?>> typeDefinitions = new HashSet<TypeDefinition<?>>();
+        List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
+        Set<GroupingDefinition> groupingsInit = new HashSet<>();
+        Set<TypeDefinition<?>> typeDefinitionsInit = new HashSet<>();
 
         for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
             if (effectiveStatement instanceof UnknownSchemaNode) {
                 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
-                unknownNodes.add(unknownNode);
+                unknownNodesInit.add(unknownNode);
             }
             if (effectiveStatement instanceof GroupingDefinition) {
                 GroupingDefinition groupingDefinition = (GroupingDefinition) effectiveStatement;
-                groupings.add(groupingDefinition);
+                groupingsInit.add(groupingDefinition);
             }
             if (effectiveStatement instanceof TypeDefinition) {
                 TypeDefinition<?> typeDefinition = (TypeDefinition<?>) effectiveStatement;
-                typeDefinitions.add(typeDefinition);
+                typeDefinitionsInit.add(typeDefinition);
             }
             if (this.input == null && effectiveStatement instanceof InputEffectiveStatementImpl) {
                 this.input = (InputEffectiveStatementImpl) effectiveStatement;
@@ -74,9 +74,9 @@ public class RpcEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<Q
             }
         }
 
-        this.unknownNodes = ImmutableList.copyOf(unknownNodes);
-        this.groupings = ImmutableSet.copyOf(groupings);
-        this.typeDefinitions = ImmutableSet.copyOf(typeDefinitions);
+        this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
+        this.groupings = ImmutableSet.copyOf(groupingsInit);
+        this.typeDefinitions = ImmutableSet.copyOf(typeDefinitionsInit);
     }
 
     @Override
index 105e2978910d18a52b1cb11d62d05ec4242c37b4..7d3ba2aee42f7ebc65deb6c2f4360b1670c7c252 100644 (file)
@@ -26,7 +26,7 @@ public final class TopologicalSort {
 
     /**
      * Topological sort of dependent nodes in acyclic graphs.
-     * 
+     *
      * @return Sorted {@link List} of {@link Node}s. Order: Nodes with no
      *         dependencies starting.
      * @throws IllegalStateException
@@ -61,7 +61,7 @@ public final class TopologicalSort {
     private static Set<Node> getDependentNodes(Set<Node> nodes) {
         Set<Node> dependentNodes = Sets.newHashSet();
         for (Node n : nodes) {
-            if (n.getOutEdges().size() == 0) {
+            if (n.getOutEdges().isEmpty()) {
                 dependentNodes.add(n);
             }
         }
@@ -108,6 +108,11 @@ public final class TopologicalSort {
         private final Set<Edge> inEdges;
         private final Set<Edge> outEdges;
 
+        public NodeImpl() {
+            inEdges = Sets.newHashSet();
+            outEdges = Sets.newHashSet();
+        }
+
         @Override
         public Set<Edge> getInEdges() {
             return inEdges;
@@ -123,11 +128,6 @@ public final class TopologicalSort {
             outEdges.add(e);
             to.getInEdges().add(e);
         }
-
-        public NodeImpl() {
-            inEdges = Sets.newHashSet();
-            outEdges = Sets.newHashSet();
-        }
     }
 
     /**
@@ -137,6 +137,11 @@ public final class TopologicalSort {
         private final Node from;
         private final Node to;
 
+        public EdgeImpl(Node from, Node to) {
+            this.from = from;
+            this.to = to;
+        }
+
         @Override
         public Node getFrom() {
             return from;
@@ -147,12 +152,6 @@ public final class TopologicalSort {
             return to;
         }
 
-        public EdgeImpl(Node from, Node to) {
-            this.from = from;
-            this.to = to;
-
-        }
-
         @Override
         public int hashCode() {
             final int prime = 31;
index 2ea109939976ce34986a85f2f24d07c9359b8767..74d38ae920e482d89e4bf488a0b4a392ecbb9906 100644 (file)
@@ -6,22 +6,45 @@
  */
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
-import com.google.common.base.Optional;
 import java.net.URI;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.util.Uint16;
-import org.opendaylight.yangtools.yang.parser.builder.api.*;
+import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
+import org.opendaylight.yangtools.yang.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 
+import com.google.common.base.Optional;
+
 /**
  * Test suite for increasing of test coverage of BuilderUtils implementation.
  *
@@ -67,7 +90,7 @@ public class BuilderUtilsTest {
 
     @Test
     public void testFindModuleFromBuildersWithNullPrefix() throws Exception {
-        final Map<String, TreeMap<Date, ModuleBuilder>> testModules = initModuleBuildersForTest();
+        final Map<String, NavigableMap<Date, ModuleBuilder>> testModules = initModuleBuildersForTest();
 
         ModuleBuilder result = BuilderUtils.findModuleFromBuilders(testModules, masterModule, null, 12);
         assertEquals(masterModule, result);
@@ -79,8 +102,8 @@ public class BuilderUtilsTest {
         assertEquals(dependentModule, result);
     }
 
-    private Map<String, TreeMap<Date, ModuleBuilder>> initModuleBuildersForTest() throws Exception {
-        final Map<String, TreeMap<Date, ModuleBuilder>> modules = new HashMap<>();
+    private Map<String, NavigableMap<Date, ModuleBuilder>> initModuleBuildersForTest() throws Exception {
+        final Map<String, NavigableMap<Date, ModuleBuilder>> modules = new HashMap<>();
         final String module3Name = "Module3";
 
         ModuleBuilder module3 = new ModuleBuilder(module3Name, "test/module/path/module3.yang");
@@ -92,13 +115,13 @@ public class BuilderUtilsTest {
 
         dependentModule.addModuleImport(module3.getModuleName(), module3.getRevision(), "ter");
 
-        final TreeMap<Date, ModuleBuilder> module1Map = new TreeMap<>();
+        final NavigableMap<Date, ModuleBuilder> module1Map = new TreeMap<>();
         module1Map.put(masterModule.getRevision(), masterModule);
 
-        final TreeMap<Date, ModuleBuilder> module2Map = new TreeMap<>();
+        final NavigableMap<Date, ModuleBuilder> module2Map = new TreeMap<>();
         module2Map.put(dependentModule.getRevision(), dependentModule);
 
-        final TreeMap<Date, ModuleBuilder> module3Map = new TreeMap<>();
+        final NavigableMap<Date, ModuleBuilder> module3Map = new TreeMap<>();
         module3Map.put(module3.getRevision(), module3);
 
         modules.put(masterModule.getName(), module1Map);
@@ -110,7 +133,7 @@ public class BuilderUtilsTest {
 
     @Test(expected = YangParseException.class)
     public void testFindModuleFromBuildersWithNoImportedModule() throws Exception {
-        final Map<String, TreeMap<Date, ModuleBuilder>> testModules = initModuleBuildersForTest();
+        final Map<String, NavigableMap<Date, ModuleBuilder>> testModules = initModuleBuildersForTest();
 
         BuilderUtils.findModuleFromBuilders(testModules, masterModule, "eth", 12);
     }
@@ -379,8 +402,8 @@ public class BuilderUtilsTest {
 
     @Test
     public void testFindModule() {
-        final Map<URI, TreeMap<Date, ModuleBuilder>> modules = new HashMap<>(1);
-        final TreeMap<Date, ModuleBuilder> masterModuleMap = new TreeMap<>();
+        final Map<URI, NavigableMap<Date, ModuleBuilder>> modules = new HashMap<>(1);
+        final NavigableMap<Date, ModuleBuilder> masterModuleMap = new TreeMap<>();
         masterModuleMap.put(masterModule.getRevision(), masterModule);
         modules.put(masterModule.getNamespace(), masterModuleMap);