org.joinedworkz.common.helper.CommentHelper.xtend Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-base Show documentation
Show all versions of common-base Show documentation
DSL based modeling framework - facilities common base
package org.joinedworkz.common.helper
import javax.inject.Inject
import javax.inject.Singleton
import org.joinedworkz.core.model.CmnElement
import org.joinedworkz.core.model.CmnNamedObject
@Singleton
class CommentHelper {
@Inject
extension StringHelper
def CharSequence singleLineComment(String text) {
genComment(text, null, null, "// ")
}
def CharSequence multiLineComment(String text) {
genComment(text, "/*", " */", " * ")
}
def CharSequence javaDocComment(CmnElement element) {
if (element instanceof CmnNamedObject) {
javaDocComment(element.description)
}
}
def CharSequence javaDocComment(String text) {
genComment(text, "/**", " */", " * ")
}
protected def CharSequence genComment(String text, String before, String after, String prefix) {
if (text !== null) {
val buffer = new StringBuilder()
if (before !== null) {
buffer.append(before)
addLineBreak(buffer)
}
insertLinesOfString(buffer, text, " * ", false)
if (after !== null) {
addLineBreak(buffer)
buffer.append(after)
}
return buffer
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy