- def private static void appendSnippet(StringBuilder sb, GeneratedType type) {
- val optDef = type.yangSourceDefinition
- if (optDef.present) {
- val def = optDef.get
- sb.append(NEW_LINE)
-
- if (def instanceof Single) {
- val node = def.node
- sb.append("<p>\n")
- .append("This class represents the following YANG schema fragment defined in module <b>")
- .append(def.module.argument).append("</b>\n")
- .append("<pre>\n")
- appendYangSnippet(sb, def.module, (node as EffectiveStatement<?, ?>).declared)
- sb.append("</pre>")
-
- if (node instanceof SchemaNode) {
- sb.append("The schema path to identify an instance is\n")
- .append("<i>")
- .append(formatSchemaPath(def.module.argument, node.path.pathFromRoot))
- .append("</i>\n")
-
- if (hasBuilderClass(node)) {
- val builderName = type.name + "Builder";
-
- 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) {
- val keyDef = node.keyDefinition
- if (keyDef !== null && !keyDef.empty) {
- sb.append("@see ").append(type.name).append("Key")
- }
- sb.append('\n');
- }
- }
- }
- } else if (def instanceof Multiple) {
- sb.append("<pre>\n")
- for (SchemaNode node : def.nodes) {
- appendYangSnippet(sb, def.module, (node as EffectiveStatement<?, ?>).declared)
- }
- sb.append("</pre>\n")
- }
- }
- }
-
- def private static void appendYangSnippet(StringBuilder sb, ModuleEffectiveStatement module,
- DeclaredStatement<?> stmt) {
- for (String str : YANG_FORMATTER.toYangTextSnippet(module, stmt)) {
- sb.append(encodeAngleBrackets(encodeJavadocSymbols(str)))
- }
- }
-
- def private static boolean hasBuilderClass(SchemaNode schemaNode) {
- return schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode
- || schemaNode instanceof RpcDefinition || schemaNode instanceof NotificationDefinition;
- }