import java.util.Map
import java.util.Optional
import java.util.Set
+import org.gaul.modernizer_maven_annotations.SuppressModernizer
import org.opendaylight.yangtools.yang.common.QName
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates
-import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
+import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget
import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.sonatype.plexus.build.incremental.BuildContext
-import org.sonatype.plexus.build.incremental.DefaultBuildContext
+@SuppressModernizer
class GeneratorImpl {
- File path
static val Logger LOG = LoggerFactory.getLogger(GeneratorImpl)
- static val BuildContext CTX = new DefaultBuildContext();
- var Module currentModule;
+
val Map<String, String> imports = new HashMap();
+ var Module currentModule;
var SchemaContext ctx;
+ var File path
StringBuilder augmentChildNodesAsString
DataSchemaNode lastNodeInTargetPath = null
- def generate(SchemaContext context, File targetPath, Set<Module> modulesToGen) throws IOException {
+ def generate(BuildContext buildContext, SchemaContext context, File targetPath, Set<Module> modulesToGen)
+ throws IOException {
path = targetPath;
path.mkdirs();
val it = new HashSet;
for (module : modulesToGen) {
- add(generateDocumentation(module, context));
+ add(generateDocumentation(buildContext, module, context));
}
return it;
}
- def generateDocumentation(Module module, SchemaContext ctx) {
+ def generateDocumentation(BuildContext buildContext, Module module, SchemaContext ctx) {
val destination = new File(path, '''«module.name».html''')
this.ctx = ctx;
module.imports.forEach[importModule | this.imports.put(importModule.prefix, importModule.moduleName)]
try {
- val fw = new OutputStreamWriter(CTX.newFileOutputStream(destination), StandardCharsets.UTF_8)
+ val fw = new OutputStreamWriter(buildContext.newFileOutputStream(destination), StandardCharsets.UTF_8)
val bw = new BufferedWriter(fw)
currentModule = module;
bw.append(generate(module, ctx));
}
}
}
- if(! nodes.empty) {
+ if (!nodes.empty) {
lastNodeInTargetPath = nodes.get(nodes.size() - 1)
}
«IF child instanceof ContainerSchemaNode»
«printContainerNode(child)»
«ENDIF»
- «IF child instanceof AnyXmlSchemaNode»
+ «IF child instanceof AnyxmlSchemaNode»
«printAnyXmlNode(child)»
«ENDIF»
«IF child instanceof LeafSchemaNode»
'''
}
- private def printAnyXmlNode(AnyXmlSchemaNode anyXmlNode) {
+ private def printAnyXmlNode(AnyxmlSchemaNode anyXmlNode) {
return
'''
<«anyXmlNode.QName.localName»>. . .</«anyXmlNode.QName.localName»>
«printInfo(node, "container")»
</ul>
'''
- } else if(node instanceof AnyXmlSchemaNode) {
+ } else if(node instanceof AnyxmlSchemaNode) {
return '''
«printInfo(node, "anyxml")»
</ul>
}
def CharSequence printChildren(Iterable<DataSchemaNode> nodes, int level, YangInstanceIdentifier path) {
- val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)
+ val anyxmlNodes = nodes.filter(AnyxmlSchemaNode)
val leafNodes = nodes.filter(LeafSchemaNode)
val leafListNodes = nodes.filter(LeafListSchemaNode)
val choices = nodes.filter(ChoiceSchemaNode)
'''
}
- def CharSequence printShortInfo(AnyXmlSchemaNode node, int level, YangInstanceIdentifier path) {
+ def CharSequence printShortInfo(AnyxmlSchemaNode node, int level, YangInstanceIdentifier path) {
return '''
<li>«strong((node.QName.localName))» (anyxml)
<ul>
}
}
- return identifier.node(new NodeIdentifierWithPredicates(node.QName, keyValues));
+ return identifier.node(NodeIdentifierWithPredicates.of(node.QName, keyValues));
}
append(arg.nodeType.localName);
previous = true;
if(arg instanceof NodeIdentifierWithPredicates) {
- for(qname : arg.getKeyValues.keySet) {
+ for(qname : arg.keySet) {
append("/{");
append(qname.localName)
append('}')