Source { public static String formatAligned(String fmt, Object... lines) { final String FORMAT_ELEMENT_SYMBOL = "##"; final int hashStartIndex = fmt.indexOf(FORMAT_ELEMENT_SYMBOL); final int hashEndIndex = hashStartIndex + FORMAT_ELEMENT_SYMBOL.length(); final String linePrefix = getWhitespaceLinePrefix(fmt, hashStartIndex); final String fmtPrefix = fmt.substring(0, hashStartIndex); final String fmtSuffix = fmt.substring(hashEndIndex); String[] strings = new String[lines.length]; for(int i = 0; i < lines.length; i++) { strings[i] = lines[i].toString(); } return fmtPrefix + String.join("\n" + linePrefix, strings) + fmtSuffix; }  static String tab(int depth, String line); static String cat(String... lines); static String cat(int depth, String... lines); static List<String> lines(String... lines); static List<String> lines(int depth, String... lines); static String formatAligned(String fmt, Object... lines); static String formatAligned(String fmt, List<String> items); static List<String> formatAlignedFirst(List<String> fmts, Object... items); static List<String> formatAlignedFirst(List<String> fmts, List<String> items); static String format(String fmt, Object... items); static List<String> formatAll(List<String> fmts, Object... items); static String dropPackageName(String qualifiedClassName); static String buildExecutableDecl(ExecutableElement exec); static String buildModifiersList(ExecutableElement exec); static String buildParametersList(ExecutableElement exec); static String buildVariableDecl(VariableElement var); static String buildParameterNamesList(ExecutableElement exec); static String buildWithoutTypeArgs(DeclaredType t); static List<String> buildImportDecls(Iterable<String> imports); static List<String> buildCollectedImportDecls(TypeElement t, String... extraImports); static List<String> buildCollectedImportDecls(TypeElement t,
                                                         Iterable<String> extraImports);  }
@Test public void formatAlignedBasic() { final String EXPECTED = " line1\n" + " line2\n" + " line3"; String fmt = " ##"; String actual = Source.formatAligned(fmt, "line1", "line2", "line3"); assertEquals(EXPECTED, actual); }