Class LordOfTheStrings.ReturnBuilderSupport

java.lang.Object
org.springframework.data.javapoet.LordOfTheStrings.ReturnBuilderSupport
Direct Known Subclasses:
LordOfTheStrings.TypedReturnBuilder
Enclosing class:
LordOfTheStrings

public abstract static class LordOfTheStrings.ReturnBuilderSupport extends Object
Builder for constructing return statements based on the target return type. The resulting CodeBlock must be added as a CodeBlock.Builder.addStatement(CodeBlock).
Since:
4.0
Author:
Mark Paluch
  • Method Details

    • when

      @Contract("_, _, _ -> this") public LordOfTheStrings.ReturnBuilderSupport when(boolean condition, String format, @Nullable Object... args)
      Add a return statement if the given condition is true.
      Parameters:
      condition - the condition to evaluate.
      format - the code format string.
      args - the format arguments.
      Returns:
      this builder.
    • otherwise

      @Contract("_, _ -> this") public LordOfTheStrings.ReturnBuilderSupport otherwise(String format, @Nullable Object... args)
      Add a fallback return statement if no previous return statement was added.
      Parameters:
      format - the code format string.
      args - the format arguments.
      Returns:
      this builder.
    • build

      @CheckReturnValue public org.springframework.javapoet.CodeBlock build()
      Build the code block representing the return statement.
      Returns:
      the resulting CodeBlock