'''
input {
- «IF input instanceof DataSchemaNode && !input.childNodes.nullOrEmpty»
+ «IF !input.childNodes.nullOrEmpty»
«writeDataSchemaNodes(input.childNodes)»
«ENDIF»
}
'''
output {
- «IF output instanceof DataSchemaNode && !output.childNodes.nullOrEmpty»
+ «IF !output.childNodes.nullOrEmpty»
«writeDataSchemaNodes(output.childNodes)»
«ENDIF»
}
return description;
}
+ def protected String formatDataForJavaDoc(GeneratedType type, String additionalComment) {
+ val StringBuilder typeDescription = new StringBuilder();
+ if (!type.description.nullOrEmpty) {
+ typeDescription.append(type.description)
+ typeDescription.append(NEW_LINE)
+ typeDescription.append(NEW_LINE)
+ typeDescription.append(NEW_LINE)
+ typeDescription.append(additionalComment)
+ } else {
+ typeDescription.append(additionalComment)
+ }
+
+ return '''
+ «typeDescription.toString»
+ '''.toString
+ }
+
def asLink(String text) {
val StringBuilder sb = new StringBuilder()
var tempText = text
}
def override body() '''
- «wrapToDocumentation(formatDataForJavaDoc(type))»
+ «wrapToDocumentation(formatDataForJavaDoc(type, getClarification()))»
public class «type.name» {
«generateMethods»
}
}
+ def private String getClarification() {
+ return
+ '''
+ The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+
+ The reason behind putting it under src/main/java is:
+ This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ loss of user code.
+ '''
+ }
+
}
assertTrue(unionExt2.exists());
assertTrue(unionExt3.exists());
assertTrue(unionExt4.exists());
- assertFilesCount(parent, 31);
+ assertFilesCount(parent, 33);
// Test if sources are compilable
testCompilation(sourcesOutputDir, compiledOutputDir);
typedef h {
type uint64;
}
+ container cont1 {
+ leaf leaf1 {
+ type union-ext1;
+ }
+ }
}
'''
}
- private def printAugmentedNode(DataSchemaNode child) {
+ private def CharSequence printAugmentedNode(DataSchemaNode child) {
if(child instanceof ChoiceCaseNode)
return ''
«ENDFOR»
</ul>
<ul>
- «FOR typeDef : dataNode.typeDefinitions»
+ «val Set<TypeDefinition<?>> typeDefinitions = dataNode.typeDefinitions»
+ «FOR typeDef : typeDefinitions»
«typeDef.restrictions»
«ENDFOR»
</ul>