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 T
addContent
(TypeName typeName) Add type name to content, correctly handling imports.default T
addContent
(Class<?> type) Obtained type is enclosed betweenClassModel.TYPE_TOKEN
tokens.addContent
(String line) Add text line to the content.default T
addContentCreate
(Annotation annotation) Add content that creates a newAnnotation
in the generated code that is the same as the annotation provided.default T
addContentCreate
(TypedElementInfo element) Add content that creates a newTypedElementInfo
in the generated code that is the same as the element provided.default T
addContentCreate
(TypeName typeName) Add content that creates a newTypeName
in the generated code that is the same as the type name provided.default T
addContentLine
(String line) Add text line to the content.addTypeToContent
(String typeName) Obtained fully qualified type name is enclosed betweenClassModel.TYPE_TOKEN
tokens.Clears created content.default T
Set 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
-
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_TOKEN
tokens. 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 newTypeName
in 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 newAnnotation
in 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 newTypedElementInfo
in 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_TOKEN
tokens. 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
-