Class LordOfTheStrings.InvocationBuilder

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

public static class LordOfTheStrings.InvocationBuilder extends Object
Builder to create method invocation code supporting argument concatenation.
  • Method Details

    • argument

      @Contract("null ->fail; _ -> this") public LordOfTheStrings.InvocationBuilder argument(String argument)
      Add a single argument as literal to the method call.
      Parameters:
      argument - the argument to add.
      Returns:
      this builder.
    • arguments

      @Contract("_ -> this") public LordOfTheStrings.InvocationBuilder arguments(Iterable<?> arguments)
      Add multiple arguments to the method call creating a literal for each argument.
      Parameters:
      arguments - the collection of arguments to add.
      Returns:
      this builder.
    • arguments

      @Contract("_, _ -> this") public <T> LordOfTheStrings.InvocationBuilder arguments(Iterable<? extends T> arguments, Function<? super T,org.springframework.javapoet.CodeBlock> consumer)
      Add multiple arguments to the method call, applying a builder customizer for each argument.
      Type Parameters:
      T - the type of the arguments.
      Parameters:
      arguments - the iterable of arguments to add.
      consumer - the consumer to apply to each argument.
      Returns:
      this builder.
    • argument

      @Contract("null -> fail; _ -> this") public LordOfTheStrings.InvocationBuilder argument(org.springframework.javapoet.CodeBlock argument)
      Add a CodeBlock as an argument to the method call.
      Parameters:
      argument - the CodeBlock to add.
      Returns:
      this builder.
    • argument

      @Contract("null, _ -> fail; _, _ -> this") public LordOfTheStrings.InvocationBuilder argument(String format, @Nullable Object... args)
      Add a formatted argument to the method call.
      Parameters:
      format - the format string.
      args - the arguments for the format string.
      Returns:
      this builder.
    • build

      @CheckReturnValue public org.springframework.javapoet.CodeBlock build()
      Build the CodeBlock representing the method call. The resulting CodeBlock can be used inline or as a statement.
      Returns:
      the constructed CodeBlock.
    • assignTo

      @CheckReturnValue public org.springframework.javapoet.CodeBlock assignTo(String format, @Nullable Object... args)
      Build the CodeBlock representing the method call and assign it to the given variable, for example:
       CodeBlock.Builder builder = …;
       InvocationBuilder invoke = LordOfTheStrings.invoke("getJdbcOperations().update($L)", …);
       builder.addStatement(invoke.assignTo("int $L", result));
       
      The resulting CodeBlock should be used as statement.
      Parameters:
      format - the format string for the assignment.
      args - the arguments for the format string.
      Returns:
      the constructed CodeBlock.