Package io.helidon.codegen.classmodel
Interface ContentBuilder<T extends ContentBuilder<T>>
- Type Parameters:
T- type of the component, to support fluent API
- All Known Implementing Classes:
Constructor.Builder,Executable.Builder,Field.Builder,Method.Builder
public interface ContentBuilder<T extends ContentBuilder<T>>
A component capable of holding content.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault TaddContent(TypeName typeName) Add type name to content, correctly handling imports.default TaddContent(Class<?> type) Obtained type is enclosed betweenClassModel.TYPE_TOKENtokens.addContent(String line) Add text line to the content.default TaddContentCreate(Annotation annotation) Add content that creates a newAnnotationin the generated code that is the same as the annotation provided.default TaddContentCreate(ResolvedType type) Add content that creates a newResolvedTypein the generated code that is the same as the type name provided.default TaddContentCreate(TypedElementInfo element) Add content that creates a newTypedElementInfoin the generated code that is the same as the element provided.default TaddContentCreate(TypeName typeName) Add content that creates a newTypeNamein the generated code that is the same as the type name provided.default TaddContentLine(String line) Add text line to the content.default TaddContentLiteral(String literal) Adds the provided literal as content, enclosed in double quotes.addTypeToContent(String typeName) Obtained fully qualified type name is enclosed betweenClassModel.TYPE_TOKENtokens.Clears created content.default TSet new content.Set new content.Method for manual padding decrement.Method for manual padding increment.Adds single padding.padContent(int repetition) Adds padding with number of repetitions.
-
Method Details
-
content
Set new content. This method replaces previously created content in this builder.- Parameters:
content- content to be set- Returns:
- updated builder instance
-
content
Set new content. This method replaces previously created content in this builder.- Parameters:
content- content to be set- Returns:
- updated builder instance
-
addContentLine
Add text line to the content. New line character is added after this line.- Parameters:
line- line to add- Returns:
- updated builder instance
-
addContentLiteral
Adds the provided literal as content, enclosed in double quotes.- Parameters:
literal- the literal string to be added as content- Returns:
- updated builder instance
-
addContent
Add text line to the content. New line character is not added after this line, so all newly added text will be appended to the same line.- Parameters:
line- line to add- Returns:
- updated builder instance
-
addContent
Add type name to content, correctly handling imports. In case the type should not contain any type parameters, useTypeName.genericTypeName().- Parameters:
typeName- type name to add- Returns:
- updated component builder
-
addContent
Obtained type is enclosed betweenClassModel.TYPE_TOKENtokens. Class names in such a format are later recognized as class names for import handling.- Parameters:
type- type to import- Returns:
- updated builder instance
-
addContentCreate
Add content that creates a newTypeNamein the generated code that is the same as the type name provided.To create a type name without type arguments (such as when used with
.class), useTypeName.genericTypeName().The generated content will be similar to:
TypeName.create("some.type.Name")- Parameters:
typeName- type name to code generate- Returns:
- updated builder instance
-
addContentCreate
Add content that creates a newResolvedTypein the generated code that is the same as the type name provided.To create a type name without type arguments (such as when used with
.class), useTypeName.genericTypeName().The generated content will be similar to:
TypeName.create("some.type.Name")- Parameters:
type- type name to code generate- Returns:
- updated builder instance
-
addContentCreate
Add content that creates a newAnnotationin the generated code that is the same as the annotation provided.- Parameters:
annotation- annotation to code generate- Returns:
- updated builder instance
-
addContentCreate
Add content that creates a newTypedElementInfoin the generated code that is the same as the element provided.- Parameters:
element- element to code generate- Returns:
- updated builder instance
-
addTypeToContent
Obtained fully qualified type name is enclosed betweenClassModel.TYPE_TOKENtokens. Class names in such a format are later recognized as class names for import handling.- Parameters:
typeName- fully qualified class name to import- Returns:
- updated builder instance
-
padContent
T padContent()Adds single padding. This extra padding is added only once. If more permanent padding increment is needed use {increaseContentPadding()}.- Returns:
- updated builder instance
-
padContent
Adds padding with number of repetitions. This extra padding is added only once. If more permanent padding increment is needed use {increaseContentPadding()}.- Parameters:
repetition- number of padding repetitions- Returns:
- updated builder instance
-
increaseContentPadding
T increaseContentPadding()Method for manual padding increment. This method will affect padding of the later added content.- Returns:
- updated builder instance
-
decreaseContentPadding
T decreaseContentPadding()Method for manual padding decrement. This method will affect padding of the later added content.- Returns:
- updated builder instance
-
clearContent
T clearContent()Clears created content.- Returns:
- updated builder instance
-