+ private def CharSequence classBody(Module m) '''
+ private «MODULE_INFO_CLASS_NAME»() {
+ «IF m.imports.size != 0»
+ «Set.importedName»<«YangModuleInfo.importedName»> set = new «HashSet.importedName»<>();
+ «FOR imp : m.imports»
+ «val name = imp.moduleName»
+ «val rev = imp.revision»
+ «IF rev == null»
+ «val Set<Module> modules = ctx.modules»
+ «val TreeMap<Date, Module> sorted = new TreeMap()»
+ «FOR module : modules»
+ «IF module.name.equals(name)»
+ «sorted.put(module.revision, module)»
+ «ENDIF»
+ «ENDFOR»
+ set.add(«BindingGeneratorUtil.moduleNamespaceToPackageName(sorted.lastEntry().value)».«MODULE_INFO_CLASS_NAME».getInstance());
+ «ELSE»
+ set.add(«BindingGeneratorUtil.moduleNamespaceToPackageName(ctx.findModuleByName(name, rev))».«MODULE_INFO_CLASS_NAME».getInstance());
+ «ENDIF»
+ «ENDFOR»
+ importedModules = «ImmutableSet.importedName».copyOf(set);
+ «ELSE»
+ importedModules = «Collections.importedName».emptySet();
+ «ENDIF»
+ «InputStream.importedName» stream = «MODULE_INFO_CLASS_NAME».class.getResourceAsStream("«sourcePath»");
+ if (stream == null) {
+ throw new IllegalStateException("Resource «sourcePath» is missing");
+ }
+ try {
+ stream.close();
+ } catch («IOException.importedName» e) {
+ // Resource leak, but there is nothing we can do
+ }