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.booleanSpecify if an import statement for the specified type is present.booleanSpecify if an import statement for the specified class name is present.static CodeSnippetof(org.springframework.javapoet.CodeBlock code) Create aCodeSnippetusing the specified code.static StringProcess the specified code and return a fully-processed code snippet as a String.static Stringprocess(org.springframework.javapoet.CodeBlock code) Process the specifiedcodeand return a fully-processed code snippet as a String.removeIndent(int indent) Return a newCodeSnippetwhere 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 newCodeSnippetwhere 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 aCodeSnippetusing the specified code.- Parameters:
code- the code snippet- Returns:
- a
CodeSnippetinstance
-
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 specifiedcodeand return a fully-processed code snippet as a String.- Parameters:
code- the code snippet- Returns:
- a resolved code snippet
-