import org.opendaylight.controller.yang.parser.builder.impl.UnionTypeBuilder;
import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.util.ModuleDependencySort;
-import org.opendaylight.controller.yang.parser.util.ModuleDependencySort.ModuleSimple;
import org.opendaylight.controller.yang.parser.util.ParserUtils;
import org.opendaylight.controller.yang.parser.util.RefineHolder;
import org.opendaylight.controller.yang.parser.util.TypeConstraints;
private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(
final List<InputStream> yangFileStreams) {
+ //Linked Hash Map MUST be used because Linked Hash Map preserves ORDER of items stored in map.
final Map<String, TreeMap<Date, ModuleBuilder>> modules = new LinkedHashMap<String, TreeMap<Date, ModuleBuilder>>();
final ParseTreeWalker walker = new ParseTreeWalker();
final List<ParseTree> trees = parseStreams(yangFileStreams);
}
// module dependency graph sorted
- List<ModuleSimple> sorted = new ModuleDependencySort(builders).sort();
-
- // TODO FIX THIS ASAP!
- // FIXME this is just temp workaround the ModuleDependencySort MUST
- // RETURN ordered List
- // of SORTED and DEPENDECNY RESOLVED MODULE BUILDERS!!!!!!
- final List<ModuleBuilder> orderedBuilders = new ArrayList<ModuleBuilder>();
- for (final ModuleSimple ms : sorted) {
- for (int i = 0; i < builders.length; ++i) {
- if (ms.getName().equals(builders[i].getName())
- && ms.getRevision().equals(builders[i].getRevision())) {
- orderedBuilders.add(builders[i]);
- }
- }
- }
- // FIXME END OF WORKAROUND
-
- for (ModuleBuilder builder : orderedBuilders) {
+ List<ModuleBuilder> sorted = ModuleDependencySort.sort(builders);
+
+ for (ModuleBuilder builder : sorted) {
final String builderName = builder.getName();
Date builderRevision = builder.getRevision();
if (builderRevision == null) {
resolveAugments(modules);
// build
+ // Linked Hash Set MUST be used otherwise the Set will not maintain order!
+ // http://docs.oracle.com/javase/6/docs/api/java/util/LinkedHashSet.html
final Set<Module> result = new LinkedHashSet<Module>();
for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules
.entrySet()) {
/**
* Search for dirty nodes (node which contains UnknownType) and resolve
* unknown types.
- *
+ *
* @param modules
* all available modules
* @param module
/**
* Go through all typedef statements from given module and search for one
* with given name
- *
+ *
* @param typedefs
* typedef statements to search
* @param name
/**
* Pull restriction from referenced type and add them to given constraints
- *
+ *
* @param referencedType
* @param constraints
*/
/**
* Go through all augmentation definitions and resolve them. This method
* also finds referenced node and add child nodes to it.
- *
+ *
* @param modules
* all available modules
*/
}
/**
- *
+ *
* @param modules
* all available modules
* @param module
/**
* Go through identity statements defined in current module and resolve
* their 'base' statement if present.
- *
+ *
* @param modules
* all modules
* @param module
/**
* Go through uses statements defined in current module and resolve their
* refine statements.
- *
+ *
* @param modules
* all modules
* @param module
/**
* Find original builder of refine node and return copy of this builder.
- *
+ *
* @param groupingPath
* path to grouping which contains node to refine
* @param refine
/**
* Find builder of refine node.
- *
+ *
* @param groupingPath
* path to grouping which contains node to refine
* @param refineNodeName
/**
* Find dependent module based on given prefix
- *
+ *
* @param modules
* all available modules
* @param module