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 aCodeBlockas 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.CodeBlockBuild theCodeBlockrepresenting the method call and assign it to the given variable, for example:org.springframework.javapoet.CodeBlockbuild()Build theCodeBlockrepresenting 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:
thisbuilder.
-
arguments
Add multiple arguments to the method call creating a literal for each argument.- Parameters:
arguments- the collection of arguments to add.- Returns:
thisbuilder.
-
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:
thisbuilder.
-
argument
@Contract("null -> fail; _ -> this") public LordOfTheStrings.InvocationBuilder argument(org.springframework.javapoet.CodeBlock argument) Add aCodeBlockas an argument to the method call.- Parameters:
argument- theCodeBlockto add.- Returns:
thisbuilder.
-
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:
thisbuilder.
-
build
Build theCodeBlockrepresenting 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 theCodeBlockrepresenting 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.
-