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 Details

    • content

      default T content(String content)
      Set new content. This method replaces previously created content in this builder.
      Parameters:
      content - content to be set
      Returns:
      updated builder instance
    • content

      T content(List<String> content)
      Set new content. This method replaces previously created content in this builder.
      Parameters:
      content - content to be set
      Returns:
      updated builder instance
    • addContentLine

      default T addContentLine(String line)
      Add text line to the content. New line character is added after this line.
      Parameters:
      line - line to add
      Returns:
      updated builder instance
    • addContent

      T addContent(String line)
      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

      default T addContent(TypeName typeName)
      Add type name to content, correctly handling imports. In case the type should not contain any type parameters, use TypeName.genericTypeName().
      Parameters:
      typeName - type name to add
      Returns:
      updated component builder
    • addContent

      default T addContent(Class<?> type)
      Obtained type is enclosed between ClassModel.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

      default T addContentCreate(TypeName typeName)
      Add content that creates a new TypeName 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), use TypeName.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

      default T addContentCreate(Annotation annotation)
      Add content that creates a new Annotation in the generated code that is the same as the annotation provided.
      Parameters:
      annotation - annotation to code generate
      Returns:
      updated builder instance
    • addContentCreate

      default T addContentCreate(TypedElementInfo element)
      Add content that creates a new TypedElementInfo in the generated code that is the same as the element provided.
      Parameters:
      element - element to code generate
      Returns:
      updated builder instance
    • addTypeToContent

      T addTypeToContent(String typeName)
      Obtained fully qualified type name is enclosed between ClassModel.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

      T padContent(int repetition)
      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