Class LordOfTheStrings.CodeBlockBuilder

java.lang.Object
org.springframework.data.javapoet.LordOfTheStrings.CodeBlockBuilder
Enclosing class:
LordOfTheStrings

public static class LordOfTheStrings.CodeBlockBuilder extends Object
An extended variant of CodeBlock.Builder that supports building statements in a fluent way and extended for functional statement creation.

This builder provides additional methods for creating and managing code blocks, including support for control flow, named arguments, and conditional statements. It is designed to enhance the readability and flexibility of code block construction.

Use this builder to create complex code structures in a fluent and intuitive manner.

See Also:
  • CodeBlock.Builder
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Determine whether this builder is empty.
      Returns:
      true if the builder is empty; false otherwise.
      See Also:
      • CodeBlock.Builder.isEmpty()
    • add

      @Contract("_, _ -> this") public LordOfTheStrings.CodeBlockBuilder add(String format, @Nullable Object... args)
      Add a formatted statement to the code block.
      Parameters:
      format - the format string.
      args - the arguments for the format string.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.add(String, Object...)
    • addStatement

      @Contract("_ -> this") public LordOfTheStrings.CodeBlockBuilder addStatement(org.springframework.javapoet.CodeBlock codeBlock)
      Add a CodeBlock as a statement to the code block.
      Parameters:
      codeBlock - the CodeBlock to add.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.addStatement(CodeBlock)
    • addStatement

      @Contract("null -> fail; _ -> this") public LordOfTheStrings.CodeBlockBuilder addStatement(Consumer<LordOfTheStrings.StatementBuilder> consumer)
      Add a statement to the code block using a Consumer to configure it.
      Parameters:
      consumer - the Consumer to configure the statement.
      Returns:
      this builder.
    • add

      @Contract("_ -> this") public LordOfTheStrings.CodeBlockBuilder add(org.springframework.javapoet.CodeBlock codeBlock)
      Add a CodeBlock to the code block.
      Parameters:
      codeBlock - the CodeBlock to add.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.addStatement(CodeBlock)
    • addStatement

      @Contract("_, _ -> this") public LordOfTheStrings.CodeBlockBuilder addStatement(String format, @Nullable Object... args)
      Add a formatted statement to the code block.
      Parameters:
      format - the format string.
      args - the arguments for the format string.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.addStatement(String, Object...)
    • addNamed

      @Contract("_, _ -> this") public LordOfTheStrings.CodeBlockBuilder addNamed(String format, Map<String,?> arguments)
      Add named arguments to the code block.
      Parameters:
      format - the format string.
      arguments - the named arguments.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.addNamed(String, Map)
    • beginControlFlow

      @Contract("_, _ -> this") public LordOfTheStrings.CodeBlockBuilder beginControlFlow(String controlFlow, @Nullable Object... args)
      Begin a control flow block with the specified format and arguments.
      Parameters:
      controlFlow - the control flow format string.
      args - the arguments for the control flow format string.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.beginControlFlow(String, Object...)
    • endControlFlow

      @Contract("_, _ -> this") public LordOfTheStrings.CodeBlockBuilder endControlFlow(String controlFlow, @Nullable Object... args)
      End the current control flow block with the specified format and arguments.
      Parameters:
      controlFlow - the control flow format string.
      args - the arguments for the control flow format string.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.endControlFlow(String, Object...)
    • endControlFlow

      @Contract("-> this") public LordOfTheStrings.CodeBlockBuilder endControlFlow()
      End the current control flow block.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.endControlFlow()
    • nextControlFlow

      @Contract("_, _ -> this") public LordOfTheStrings.CodeBlockBuilder nextControlFlow(String controlFlow, @Nullable Object... args)
      Begin the next control flow block with the specified format and arguments.
      Parameters:
      controlFlow - the control flow format string.
      args - the arguments for the control flow format string.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.nextControlFlow(String, Object...)
    • indent

      @Contract("-> this") public LordOfTheStrings.CodeBlockBuilder indent()
      Indent the current code block.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.indent()
    • unindent

      @Contract("-> this") public LordOfTheStrings.CodeBlockBuilder unindent()
      Unindent the current code block.
      Returns:
      this builder.
      See Also:
      • CodeBlock.Builder.unindent()
    • build

      @CheckReturnValue public org.springframework.javapoet.CodeBlock build()
      Build the CodeBlock from the current state of the builder.
      Returns:
      the constructed CodeBlock.
    • clear

      @Contract("-> this") public LordOfTheStrings.CodeBlockBuilder clear()
      Clear the current state of the builder.
      Returns:
      this builder.