com.teamscale.test_impacted.commons.IndentingWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of impacted-test-engine Show documentation
Show all versions of impacted-test-engine Show documentation
A JUnit 5 engine that handles retrieving impacted tests from Teamscale and organizes their execution
package com.teamscale.test_impacted.commons;
/** Utility class for writing lines with tab indentation. */
public class IndentingWriter {
private StringBuilder builder = new StringBuilder();
private int indent = 0;
/** Indents all {@link #writeLine(String)} calls in the indented writes by one more tab. */
public void indent(Runnable indentedWrites) {
indent++;
indentedWrites.run();
indent--;
}
/** Writes a new line. */
public void writeLine(String line) {
for (int i = 0; i < indent; i++) {
builder.append("\t");
}
builder.append(line).append("\n");
}
@Override
public String toString() {
return builder.toString();
}
}