private CodeBlock loopMethodBody(
        String openSymbol,
        String closeSymbol,
        CodeBlock loopDeclaration,
        CodeBlock... appendedValues) {
      ImmutableList<CodeBlock> allAppendedValues =
          ImmutableList.<CodeBlock>builder()
              .add(CodeBlock.of("$S", "\n"))
              .add(CodeBlock.of("$N(indentLevel + 1)", INDENT_METHOD_NAME))
              .add(appendedValues)
              .add(CodeBlock.of("$S", ","))
              .build();
      return CodeBlock.builder()
          .addStatement("$1T builder = new $1T().append($2S)", StringBuilder.class, openSymbol)
          .addStatement("boolean hasElements = false")
          .beginControlFlow("$L", loopDeclaration)
          .addStatement(
              "builder$L",
              allAppendedValues.stream()
                  .map(value -> CodeBlock.of(".append($L)", value))
                  .collect(CodeBlock.joining("")))
          .addStatement("hasElements = true")
          .endControlFlow()
          .beginControlFlow("if (hasElements)")
          .addStatement("builder.append($S).append($N(indentLevel))", "\n", INDENT_METHOD_NAME)
          .endControlFlow()
          .addStatement("return builder.append($S).toString()", closeSymbol)
          .build();
    }
Parameter object to simplify the branches of {@link #format(CodeBlock, CodeBlock,
TypeMirror)} that call a delegate method.
value/src/main/java/com/google/auto/value/extension/toprettystring/processor/ToPrettyStringExtension.java