X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fimpl%2FYangParserImpl.java;h=5684c045d5a08d1412b48bfdf3db5a28f2b7e21d;hb=42e93bc057034b3c4d0dd9ac82c827de9613af68;hp=9f59cfd19a7b156619e3bf808cdda35237b7afc3;hpb=f304e6b160927b49fbdcdf55fde55fb23c437896;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java index 9f59cfd19a..5684c045d5 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java @@ -15,7 +15,6 @@ import static org.opendaylight.yangtools.yang.parser.builder.impl.BuilderUtils.f import static org.opendaylight.yangtools.yang.parser.builder.impl.BuilderUtils.processAugmentation; import static org.opendaylight.yangtools.yang.parser.builder.impl.TypeUtils.resolveType; import static org.opendaylight.yangtools.yang.parser.builder.impl.TypeUtils.resolveTypeUnion; - import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.HashBiMap; @@ -34,6 +33,7 @@ import java.util.LinkedHashMap; 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 javax.annotation.concurrent.Immutable; @@ -47,7 +47,7 @@ import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceNode; +import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition; @@ -58,7 +58,6 @@ import org.opendaylight.yangtools.yang.model.api.ModuleImport; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser; import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder; @@ -142,7 +141,7 @@ public final class YangParserImpl implements YangContextParser { // module builders sorted by dependencies List sortedBuilders = ModuleDependencySort.sort(resolved); - LinkedHashMap> modules = resolveModulesWithImports(sortedBuilders, null); + Map> modules = resolveModulesWithImports(sortedBuilders, null); Collection unsorted = build(modules).values(); Set result = new LinkedHashSet<>( ModuleDependencySort.sort(unsorted.toArray(new Module[unsorted.size()]))); @@ -234,9 +233,9 @@ public final class YangParserImpl implements YangContextParser { return resolveSchemaContext(result); } - private static LinkedHashMap> resolveModulesWithImports(final List sorted, + private static Map> resolveModulesWithImports(final List sorted, final SchemaContext context) { - final LinkedHashMap> modules = orderModules(sorted); + final Map> modules = orderModules(sorted); for (ModuleBuilder module : sorted) { if (module != null) { for (ModuleImport imp : module.getImports().values()) { @@ -482,7 +481,7 @@ public final class YangParserImpl implements YangContextParser { final Map> submodules) { Map includes = module.getIncludedModules(); for (Map.Entry entry : includes.entrySet()) { - TreeMap subs = submodules.get(entry.getKey()); + NavigableMap subs = submodules.get(entry.getKey()); if (subs == null) { throw new YangParseException("Failed to find references submodule " + entry.getKey() + " in module " + module.getName()); @@ -564,8 +563,8 @@ public final class YangParserImpl implements YangContextParser { * topologically sorted modules * @return modules ordered by namespace and revision */ - private static LinkedHashMap> orderModules(final List modules) { - final LinkedHashMap> result = new LinkedHashMap<>(); + private static Map> orderModules(final List modules) { + final Map> result = new LinkedHashMap<>(); for (final ModuleBuilder builder : modules) { if (builder == null) { continue; @@ -1263,16 +1262,16 @@ public final class YangParserImpl implements YangContextParser { for (Map.Entry childEntry : entry.getValue().entrySet()) { final ModuleBuilder moduleBuilder = childEntry.getValue(); final Module module = moduleBuilder.build(); - final List allChoicesFromModule = getChoicesFrom(module); + final List allChoicesFromModule = getChoicesFrom(module); - for (ChoiceNode choiceNode : allChoicesFromModule) { + for (ChoiceSchemaNode choiceNode : allChoicesFromModule) { findDuplicityNodesIn(choiceNode, module, moduleBuilder, modules); } } } } - private void findDuplicityNodesIn(final ChoiceNode choiceNode, final Module module, final ModuleBuilder moduleBuilder, + private void findDuplicityNodesIn(final ChoiceSchemaNode choiceNode, final Module module, final ModuleBuilder moduleBuilder, final Map> modules) { final Set duplicityTestSet = new HashSet(); @@ -1294,8 +1293,8 @@ public final class YangParserImpl implements YangContextParser { } } - private List getChoicesFrom(final Module module) { - final List allChoices = new ArrayList(); + private List getChoicesFrom(final Module module) { + final List allChoices = new ArrayList(); for (DataSchemaNode dataSchemaNode : module.getChildNodes()) { findChoicesIn(dataSchemaNode, allChoices); @@ -1303,7 +1302,7 @@ public final class YangParserImpl implements YangContextParser { return allChoices; } - private void findChoicesIn(final SchemaNode schemaNode, final Collection choiceNodes) { + private void findChoicesIn(final SchemaNode schemaNode, final Collection choiceNodes) { if (schemaNode instanceof ContainerSchemaNode) { final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) schemaNode; for (DataSchemaNode dataSchemaNode : contSchemaNode.getChildNodes()) { @@ -1314,8 +1313,8 @@ public final class YangParserImpl implements YangContextParser { for (DataSchemaNode dataSchemaNode : listSchemaNode.getChildNodes()) { findChoicesIn(dataSchemaNode, choiceNodes); } - } else if (schemaNode instanceof ChoiceNode) { - choiceNodes.add((ChoiceNode) schemaNode); + } else if (schemaNode instanceof ChoiceSchemaNode) { + choiceNodes.add((ChoiceSchemaNode) schemaNode); } }