Package org.openrewrite.java
Class JavaTemplate.Builder
java.lang.Object
org.openrewrite.java.JavaTemplate.Builder
- Enclosing class:
JavaTemplate
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIn context-free templates involving generic types, the type often cannot be inferred automatically.build()A template snippet is context-sensitive when it refers to the class, variables, methods, or other symbols visible from its insertion scope.doAfterVariableSubstitution(Consumer<String> afterVariableSubstitution) doBeforeParseTemplate(Consumer<String> beforeParseTemplate) genericTypes(String... genericTypes) javaParser(org.openrewrite.java.JavaParser.Builder<?, ?> parser) staticImports(String... fullyQualifiedMemberTypeNames)
-
Constructor Details
-
Builder
-
-
Method Details
-
contextSensitive
A template snippet is context-sensitive when it refers to the class, variables, methods, or other symbols visible from its insertion scope. When a template is completely self-contained, it is not context-sensitive. Context-free template snippets can be cached, since it does not matter where the resulting LST elements will be inserted. Since the LST elements in a context-sensitive snippet vary depending on where they are inserted the resulting LST elements cannot be reused between different insertion points and are not cached.An example of a context-free snippet might be something like this, to be used as a local variable declaration:
int i = 1;An example of a context-sensitive snippet is:
int i = a; This cannot be made sense of without the surrounding scope which includes the declaration of "a". -
bindType
In context-free templates involving generic types, the type often cannot be inferred automatically.Common examples include:
new ArrayList<>()Collections.emptyList()String::valueOf
-
imports
-
staticImports
-
genericTypes
-
javaParser
-
doAfterVariableSubstitution
-
doBeforeParseTemplate
-
build
-