+ private boolean isNullOrEmpty(final Collection<?> list) {
+ return (list == null || list.isEmpty() ? true : false);
+ }
+
+ private String createDescription(final Set<? extends SchemaNode> schemaNodes, final String moduleName, final String moduleSourcePath) {
+ final StringBuilder sb = new StringBuilder();
+
+ if (!isNullOrEmpty(schemaNodes)) {
+ final SchemaNode node = schemaNodes.iterator().next();
+
+ if (node instanceof RpcDefinition) {
+ sb.append("Interface for implementing the following YANG RPCs defined in module <b>" + moduleName + "</b>");
+ } else if (node instanceof NotificationDefinition) {
+ sb.append("Interface for receiving the following YANG notifications defined in module <b>" + moduleName + "</b>");
+ }
+ }
+ sb.append(NEW_LINE);
+ sb.append("<br />(Source path: <i>");
+ sb.append(moduleSourcePath);
+ sb.append("</i>):");
+ sb.append(NEW_LINE);
+
+ if (verboseClassComments) {
+ sb.append("<pre>");
+ sb.append(NEW_LINE);
+ sb.append(YangTemplate.generateYangSnipet(schemaNodes));
+ sb.append("</pre>");
+ sb.append(NEW_LINE);
+ }
+
+ return sb.toString();
+ }
+
+ private String createDescription(final SchemaNode schemaNode, final String fullyQualifiedName) {
+ final StringBuilder sb = new StringBuilder();
+ final String formattedDescription = YangTemplate.formatToParagraph(schemaNode.getDescription(), 0);
+
+ if (!isNullOrEmpty(formattedDescription)) {
+ sb.append(formattedDescription);
+ sb.append(NEW_LINE);
+ }
+
+ if (verboseClassComments) {
+ final Module module = findParentModule(schemaContext, schemaNode);
+ final StringBuilder linkToBuilderClass = new StringBuilder();
+ final StringBuilder linkToKeyClass = new StringBuilder();
+ final String[] namespace = Iterables.toArray(BSDOT_SPLITTER.split(fullyQualifiedName), String.class);
+ String className = namespace[namespace.length - 1];
+
+ if (hasBuilderClass(schemaNode)) {
+ linkToBuilderClass.append(className);
+ linkToBuilderClass.append("Builder");
+
+ if (schemaNode instanceof ListSchemaNode) {
+ linkToKeyClass.append(className);
+ linkToKeyClass.append("Key");
+ }
+ }
+
+ sb.append("<p>");
+ sb.append("This class represents the following YANG schema fragment defined in module <b>");
+ sb.append(module.getName());
+ sb.append("</b>");
+ sb.append(NEW_LINE);
+ sb.append("<br />(Source path: <i>");
+ sb.append(module.getModuleSourcePath());
+ sb.append("</i>):");
+ sb.append(NEW_LINE);
+ sb.append("<pre>");
+ sb.append(NEW_LINE);
+ sb.append(YangTemplate.generateYangSnipet(schemaNode));
+ sb.append("</pre>");
+ sb.append(NEW_LINE);
+ sb.append("The schema path to identify an instance is");
+ sb.append(NEW_LINE);
+ sb.append("<i>");
+ sb.append(YangTemplate.formatSchemaPath(module.getName(), schemaNode.getPath().getPathFromRoot()));
+ sb.append("</i>");
+ sb.append(NEW_LINE);
+
+ if (hasBuilderClass(schemaNode)) {
+ sb.append(NEW_LINE);
+ sb.append("<p>To create instances of this class use " + "{@link " + linkToBuilderClass + "}.");
+ sb.append(NEW_LINE);
+ sb.append("@see ");
+ sb.append(linkToBuilderClass);
+ if (schemaNode instanceof ListSchemaNode) {
+ sb.append("@see ");
+ sb.append(linkToKeyClass);
+ }
+ sb.append(NEW_LINE);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ private boolean hasBuilderClass(final SchemaNode schemaNode) {
+ if (schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode ||
+ schemaNode instanceof RpcDefinition || schemaNode instanceof NotificationDefinition) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isNullOrEmpty(final String string) {
+ return (string == null || string.isEmpty() ? true : false);
+ }
+
+ private String createDescription(final Module module) {
+ final StringBuilder sb = new StringBuilder();
+ final String formattedDescription = YangTemplate.formatToParagraph(module.getDescription(), 0);
+
+ if (!isNullOrEmpty(formattedDescription)) {
+ sb.append(formattedDescription);
+ sb.append(NEW_LINE);
+ }
+
+ if (verboseClassComments) {
+ sb.append("<p>");
+ sb.append("This class represents the following YANG schema fragment defined in module <b>");
+ sb.append(module.getName());
+ sb.append("</b>");
+ sb.append(NEW_LINE);
+ sb.append("<br />Source path: <i>");
+ sb.append(module.getModuleSourcePath());
+ sb.append("</i>):");
+ sb.append(NEW_LINE);
+ sb.append("<pre>");
+ sb.append(NEW_LINE);
+ sb.append(YangTemplate.generateYangSnipet(module));
+ sb.append("</pre>");
+ }
+
+ return sb.toString();
+ }
+