Interface ContentBuilder<T extends ContentBuilder<T>>
- Type Parameters:
T- type of the component, to support fluent API
- All Known Implementing Classes:
Constructor.Builder, EnumConstant.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 TAdd a new line (empty).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
-
content
-
addContentLine
-
addContentLine
-
addContentLiteral
-
addContent
-
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().Simple type names use generated content similar to:
TypeName.create("some.type.Name"). Type names with direct or inherited type-use annotations use generated builder content to preserve annotations on the root type, type arguments, wildcard bounds, and array component types.- 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
-