use of org.opendaylight.yangtools.yang.model.api.DocumentedNode in project mdsal by opendaylight.
the class JavaFileTemplate method appendSnippet.
static void appendSnippet(final StringBuilder sb, final GeneratedType type) {
type.getYangSourceDefinition().ifPresent(def -> {
sb.append('\n');
if (def instanceof Single) {
final DocumentedNode node = ((Single) def).getNode();
sb.append("<p>\n").append("This class represents the following YANG schema fragment defined in module <b>").append(def.getModule().argument().getLocalName()).append("</b>\n").append("<pre>\n");
appendYangSnippet(sb, def.getModule(), ((EffectiveStatement<?, ?>) node).getDeclared());
sb.append("</pre>");
if (node instanceof SchemaNode) {
final SchemaNode schema = (SchemaNode) node;
if (hasBuilderClass(schema)) {
final String builderName = type.getName() + BindingMapping.BUILDER_SUFFIX;
sb.append("\n<p>To create instances of this class use {@link ").append(builderName).append("}.\n").append("@see ").append(builderName).append('\n');
if (node instanceof ListSchemaNode) {
final var keyDef = ((ListSchemaNode) node).getKeyDefinition();
if (!keyDef.isEmpty()) {
sb.append("@see ").append(type.getName()).append(BindingMapping.KEY_SUFFIX);
}
sb.append('\n');
}
}
}
} else if (def instanceof Multiple) {
sb.append("<pre>\n");
for (SchemaNode node : ((Multiple) def).getNodes()) {
appendYangSnippet(sb, def.getModule(), ((EffectiveStatement<?, ?>) node).getDeclared());
}
sb.append("</pre>\n");
}
});
}
Aggregations