Class CodeBlock.Builder

java.lang.Object
io.spring.initializr.generator.language.CodeBlock.Builder
Enclosing class:
CodeBlock

public static final class CodeBlock.Builder extends Object
  • Method Details

    • add

      public CodeBlock.Builder add(CodeBlock codeBlock)
      Add the specified CodeBlock, without any extra line or statement separator.
      Parameters:
      codeBlock - the code to add
      Returns:
      this for method chaining
    • add

      public CodeBlock.Builder add(String format, Object... args)
      Add more code using the specified code and optional arguments.
      Parameters:
      format - the code
      args - the arguments, if any
      Returns:
      this for method chaining
    • addStatement

      public CodeBlock.Builder addStatement(CodeBlock codeBlock)
      Add the specified CodeBlock as a statement.
      Parameters:
      codeBlock - the code to add
      Returns:
      this for method chaining
    • addStatement

      public CodeBlock.Builder addStatement(String format, Object... args)
      Add more code using the specified code and optional arguments and indicate that this statement is finished.
      Parameters:
      format - the code
      args - the arguments, if any
      Returns:
      this for method chaining
    • build

      public CodeBlock build()
      Build a CodeBlock with the current state of this builder.
      Returns:
      a CodeBlock