package pingis.utils;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.comments.LineComment;

public class CodeStubBuilder {
  private CompilationUnit compilationUnit;
  private ClassOrInterfaceDeclaration clazz;
  private String className;

  public CodeStubBuilder(String className) {
    compilationUnit = new CompilationUnit();
    this.className = className;

    clazz = compilationUnit.addClass(className);
  }

  public CodeStubBuilder withImport(String name) {
    compilationUnit.addImport(name);

    return this;
  }

  public CodeStubBuilder withBodyComment(String comment) {
    // Hack to add some nice whitespace between // and the comment text
    if (!comment.startsWith(" ")) {
      comment = " " + comment;
    }

    LineComment commentNode = new LineComment(comment);
    clazz.addOrphanComment(commentNode);

    return this;
  }

  public String build() {
    return compilationUnit.toString();
  }
}

@@ -224,21 +224,23 @@
 r %7B%0A  pr
-ivate
+otected
  Compila
@@ -269,21 +269,23 @@
 it;%0A  pr
-ivate
+otected
  ClassOr
@@ -320,13 +320,15 @@
   pr
-ivate
+otected
  Str

Make CodeStubBuilder fields protected.