org.joinedworkz.common.helper.CommentHelper 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.eclipse.xtext.xbase.lib.Extension;
import org.joinedworkz.core.model.CmnElement;
import org.joinedworkz.core.model.CmnNamedObject;
@Singleton
@SuppressWarnings("all")
public class CommentHelper {
@Inject
@Extension
private StringHelper _stringHelper;
public CharSequence singleLineComment(final String text) {
return this.genComment(text, null, null, "// ");
}
public CharSequence multiLineComment(final String text) {
return this.genComment(text, "/*", " */", " * ");
}
public CharSequence javaDocComment(final CmnElement element) {
CharSequence _xifexpression = null;
if ((element instanceof CmnNamedObject)) {
_xifexpression = this.javaDocComment(((CmnNamedObject)element).getDescription());
}
return _xifexpression;
}
public CharSequence javaDocComment(final String text) {
return this.genComment(text, "/**", " */", " * ");
}
protected CharSequence genComment(final String text, final String before, final String after, final String prefix) {
if ((text != null)) {
final StringBuilder buffer = new StringBuilder();
if ((before != null)) {
buffer.append(before);
this._stringHelper.addLineBreak(buffer);
}
this._stringHelper.insertLinesOfString(buffer, text, " * ", false);
if ((after != null)) {
this._stringHelper.addLineBreak(buffer);
buffer.append(after);
}
return buffer;
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy