Class CodeSnippet
java.lang.Object
org.springframework.javapoet.support.CodeSnippet
A code snippet using tabs indentation that is fully processed by JavaPoet so
that imports are resolved.
- Since:
- 6.0
- Author:
- Stephane Nicoll
-
Method Summary
Modifier and TypeMethodDescriptionReturn the rendered code snippet.boolean
Specify if an import statement for the specified type is present.boolean
Specify if an import statement for the specified class name is present.static CodeSnippet
of
(org.springframework.javapoet.CodeBlock code) Create aCodeSnippet
using the specified code.static String
Process the specified code and return a fully-processed code snippet as a String.static String
process
(org.springframework.javapoet.CodeBlock code) Process the specifiedcode
and return a fully-processed code snippet as a String.removeIndent
(int indent) Return a newCodeSnippet
where the specified number of indentations have been removed.
-
Method Details
-
getSnippet
Return the rendered code snippet.- Returns:
- a code snippet where imports have been resolved
-
hasImport
Specify if an import statement for the specified type is present.- Parameters:
type
- the type to check- Returns:
- true if this type has an import statement, false otherwise
-
hasImport
Specify if an import statement for the specified class name is present.- Parameters:
className
- the name of the class to check- Returns:
- true if this type has an import statement, false otherwise
-
removeIndent
Return a newCodeSnippet
where the specified number of indentations have been removed.- Parameters:
indent
- the number of indent to remove- Returns:
- a CodeSnippet instance with the number of indentations removed
-
of
Create aCodeSnippet
using the specified code.- Parameters:
code
- the code snippet- Returns:
- a
CodeSnippet
instance
-
process
Process the specified code and return a fully-processed code snippet as a String.- Parameters:
code
- a consumer to use to generate the code snippet- Returns:
- a resolved code snippet
-
process
Process the specifiedcode
and return a fully-processed code snippet as a String.- Parameters:
code
- the code snippet- Returns:
- a resolved code snippet
-