Class LordOfTheStrings.InvocationBuilder
java.lang.Object
org.springframework.data.javapoet.LordOfTheStrings.InvocationBuilder
- Enclosing class:
- LordOfTheStrings
Builder to create method invocation code supporting argument concatenation.
-
Method Summary
Modifier and TypeMethodDescriptionAdd a single argument as literal to the method call.Add a formatted argument to the method call.argument
(org.springframework.javapoet.CodeBlock argument) Add aCodeBlock
as an argument to the method call.Add multiple arguments to the method call creating a literal for each argument.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.org.springframework.javapoet.CodeBlock
Build theCodeBlock
representing the method call and assign it to the given variable, for example:org.springframework.javapoet.CodeBlock
build()
Build theCodeBlock
representing the method call.
-
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
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 aCodeBlock
as an argument to the method call.- Parameters:
argument
- theCodeBlock
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
Build theCodeBlock
representing the method call. The resulting CodeBlock can be used inline or as astatement
.- Returns:
- the constructed
CodeBlock
.
-
assignTo
@CheckReturnValue public org.springframework.javapoet.CodeBlock assignTo(String format, @Nullable Object... args) Build theCodeBlock
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 asstatement
.- Parameters:
format
- the format string for the assignment.args
- the arguments for the format string.- Returns:
- the constructed
CodeBlock
.
-