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<ModuleBuilder> sorted = ModuleDependencySort.sort(builders);
-
+
for (ModuleBuilder builder : sorted) {
final String builderName = builder.getName();
Date builderRevision = builder.getRevision();
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