final String propertyName = "value";
final GeneratedTOBuilder genTOBuilder = typedefToTransferObject(basePackageName, typedef);
-
final GeneratedPropertyBuilder genPropBuilder = genTOBuilder.addProperty(propertyName);
-
genPropBuilder.setReturnType(javaType);
genTOBuilder.addEqualsIdentity(genPropBuilder);
genTOBuilder.addHashIdentity(genPropBuilder);
}
generatedTOBuilders.add(unionGenTOBuilder);
unionGenTOBuilder.setIsUnion(true);
-
final List<String> regularExpressions = new ArrayList<String>();
for (final TypeDefinition<?> unionType : unionTypes) {
final String unionTypeName = unionType.getQName().getLocalName();
if ((packageName != null) && (typedef != null) && (typeDefTOName != null)) {
final String genTOName = parseToClassName(typeDefTOName);
final GeneratedTOBuilder newType = new GeneratedTOBuilderImpl(packageName, genTOName);
-
+ newType.addComment(typedef.getDescription());
return newType;
}
return null;
import java.util.Map
import org.opendaylight.yangtools.sal.binding.model.api.Type
import org.opendaylight.yangtools.binding.generator.util.Types
+import com.google.common.base.Splitter
abstract class BaseTemplate {
protected val GeneratedType type;
protected val Map<String,String> importMap;
-
+ static val paragraphSplitter = Splitter.on("\n\n").omitEmptyStrings();
new(GeneratedType _type) {
if (_type== null) {
throw new IllegalArgumentException("Generated type reference cannot be NULL!")
def final protected asArguments(Iterable<GeneratedProperty> parameters)
'''«IF !parameters.empty»«FOR parameter : parameters SEPARATOR ", "»«parameter.fieldName»«ENDFOR»«ENDIF»'''
+
+ /**
+ * Template method which generates JAVA comments.
+ *
+ * @param string with the comment for whole JAVA class
+ * @return string with comment in JAVA format
+ */
+ def protected CharSequence asJavadoc(String comment) {
+ if (comment==null) return '';
+ val paragraphs = paragraphSplitter.split(comment)
+
+ return '''
+ /**
+ «FOR p : paragraphs SEPARATOR "<p>"»
+ «p»
+ «ENDFOR»
+ **/
+ '''
+ }
}
\ No newline at end of file
* @return string with class source code in JAVA format\r
*/\r
def protected generateBody(boolean isInnerClass) '''\r
- «type.comment.generateComment»\r
+ «type.comment.asJavadoc»\r
«generateClassDeclaration(isInnerClass)» {\r
«innerClassesDeclarations»\r
«enumDeclarations»\r
}\r
'''\r
\r
- /**\r
- * Template method which generates JAVA comments.\r
- * \r
- * @param string with the comment for whole JAVA class\r
- * @return string with comment in JAVA format\r
- */\r
- def protected generateComment(String comment) '''\r
- «IF comment != null && !comment.empty»\r
- /**\r
- «comment»\r
- **/\r
- «ENDIF»\r
- '''\r
+\r
\r
/**\r
* Template method which generates JAVA class declaration.\r
ENDIF»class «type.name»«\r
IF (genTO.superType != null)»«\r
" extends "»«genTO.superType.importedName»«\r
- ENDIF»«\r
- IF (!type.implements.empty)»«\r
+ ENDIF»\r
+ «IF (!type.implements.empty)»«\r
" implements "»«\r
FOR type : type.implements SEPARATOR ", "»«\r
type.importedName»«\r