Interface TextBuilder<T extends TextBuilder>

All Known Implementing Classes:
AbstractTextBuilder, ColoredHtmlTextBuilder, ColoredRichTextBuilder, HtmlTextBuilder, PlainOrFullHtmlTextBuilder, PlainOrLightHtmlTextBuilder, PlainTextBuilder, RawTextBuilder, RichTextBuilder

@OpenApiAll public interface TextBuilder<T extends TextBuilder>
An utility used for building plain or rich texts with possibly colored fragments.
  • Method Details

    • append

      default T append(TextBuilder builder)
      Append text from given builder
      Parameters:
      builder - builder
      Returns:
      this builder
    • prepend

      default T prepend(TextBuilder builder)
      Add text to the beginning from the given builder.
      Parameters:
      builder - builder
      Returns:
      this builder
    • prependWithNoWrap

      default T prependWithNoWrap(CharSequence text)
      Add text to the beginning. Added text will not be wrapped if builder supports that.
      Parameters:
      text - text to prepend
      Returns:
      this builder
    • appendWithNoWrap

      default T appendWithNoWrap(CharSequence text)
      Append text from the given builder. Added text will not be wrapped if builder supports that.
      Parameters:
      text - text to prepend
      Returns:
      this builder
    • setText

      default T setText(TextBuilder builder)
      Replaces current text with the one from the given builder
      Parameters:
      builder - builder
      Returns:
      this builder
    • append

      T append(CharSequence text)
      Append given text
      Parameters:
      text - text to append
      Returns:
      this builder
    • appendWithSpace

      default T appendWithSpace(CharSequence text)
      Append given text. Prepend space before given text if build has text added already.
      Parameters:
      text - text to append
      Returns:
      this builder
    • appendWithSpace

      default T appendWithSpace(TextBuilder builder)
      Append given text. Prepend space before given text if build has text added already.
      Parameters:
      builder - text to append
      Returns:
      this builder
    • prepend

      T prepend(CharSequence text)
      Add given text to the beginning.
      Parameters:
      text - text to append
      Returns:
      this builder
    • setColor

      default T setColor(@CheckForNull Color color)
      Set color of the text which will be added later. Not every implementation supports that, so color can be ignored.
      Parameters:
      color - color to set. Null is used to reset previously set color
      Returns:
      this builder
    • toString

      String toString()
      Overrides:
      toString in class Object
      Returns:
      result string
    • toPlainText

      String toPlainText()
      Returns:
      result string as plain text
    • isPlainTextEmpty

      default boolean isPlainTextEmpty()
      Returns:
      true if text converted to a plain is empty in this builder
    • setText

      void setText(CharSequence text)
      Replace current text with the given one
      Parameters:
      text - text
    • compress

      default void compress(int textLength)
      Compress current text to the given length. This function is not supported in every implementation, so it can be ignored.
      Parameters:
      textLength - text length
    • isTextAdded

      boolean isTextAdded()
      Returns:
      true if at least one text fragment was added (even if fragment is empty)
    • isColorSupported

      default boolean isColorSupported()
      Returns:
      true if builder supports color