Class OverwriteTextBuilder

java.lang.Object
org.refcodes.textual.OverwriteTextBuilder
All Implemented Interfaces:
Text<OverwriteTextBuilder>, TextAccessor, TextAccessor.TextBuilder<Text<OverwriteTextBuilder>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider

public class OverwriteTextBuilder extends Object
Overwrites a text with another one to the the right or to the left.
  • Constructor Details

    • OverwriteTextBuilder

      public OverwriteTextBuilder()
  • Method Details

    • getOverwritingText

      public String getOverwritingText()
      Retrieves the overwriting text from the overwriting text property.
      Returns:
      The overwriting text stored by the overwriting text property.
    • setOverwritingText

      public void setOverwritingText(String aOverwritingText)
      Sets the overwriting text for the overwriting text property.
      Parameters:
      aOverwritingText - The overwriting text to be stored by the overwriting text property.
    • getOverwriteTextMode

      public OverwriteTextMode getOverwriteTextMode()
      Retrieves the overwrite text mode from the overwrite text mode property.
      Returns:
      The overwrite text mode stored by the overwrite text mode property.
    • setTextOverwriteMode

      public void setTextOverwriteMode(OverwriteTextMode aTextOverwriteMode)
      Sets the overwrite text mode for the overwrite text mode property.
      Parameters:
      aTextOverwriteMode - The overwrite text mode to be stored by the overwrite text mode property.
    • toStrings

      public String[] toStrings()
      The Strings being build by the builder upon the settings of the attributes.
      Returns:
      The according resulting String array
    • toStrings

      public String[] toStrings(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toStrings(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toStrings() (do not change the text property) as this would not be thread safe!
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String array
    • withOverwritingText

      public OverwriteTextBuilder withOverwritingText(String aOverwritingText)
      Sets the overwriting text for the overwriting text property.
      Parameters:
      aOverwritingText - The overwriting text to be stored by the overwriting text property.
      Returns:
      The builder for applying multiple build operations.
    • withOverwriteTextMode

      public OverwriteTextBuilder withOverwriteTextMode(OverwriteTextMode aOverwriteTextMode)
      Sets the overwrite text mode for the overwrite text mode property.
      Parameters:
      aOverwriteTextMode - The overwrite text mode to be stored by the overwrite text mode property.
      Returns:
      The builder for applying multiple build operations.
    • asOverwriteText

      public static String asOverwriteText(String aText, String aWriteOverText, OverwriteTextMode aOverwriteTextMode)
      To overwrite.
      Parameters:
      aText - the text
      aWriteOverText - the write over text
      aOverwriteTextMode - the overwrite text mode
      Returns:
      the string
    • asOverwriteLeft

      public static String asOverwriteLeft(String aText, String aWriteOverText)
      Overwrites a text starting at the left hand side with the given "overwriting" text.
      Parameters:
      aText - The text to be overwritten.
      aWriteOverText - The text used for overwriting.
      Returns:
      A String overwritten on the left hand side with the given "overwriting" text.
    • asOverwriteRight

      public static String asOverwriteRight(String aText, String aWriteOverText)
      Overwrites a text starting at the right hand side with the given "overwriting" text.
      Parameters:
      aText - The text to be overwritten.
      aWriteOverText - The text used for overwriting.
      Returns:
      A String overwritten on the right hand side with the given "overwriting" text.
    • getText

      public String[] getText()
      Retrieves the text from the text property.
      Specified by:
      getText in interface TextAccessor
      Returns:
      The text stored by the text property.
    • setText

      public void setText(String... aText)
      Sets the text for the text property.
      Specified by:
      setText in interface TextAccessor.TextMutator
      Parameters:
      aText - The text to be stored by the text property.
    • withText

      public OverwriteTextBuilder withText(String... aText)
      With text.
      Specified by:
      withText in interface Text<B extends Text<B>>
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • withText

      public OverwriteTextBuilder withText(Collection<String> aText)
      With text.
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • toString

      public String toString()
      The String being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).
      Specified by:
      toString in interface TextAccessor.TextProvider
      Overrides:
      toString in class Object
      Returns:
      The according resulting String
    • toString

      public String toString(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toString(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toString() (do not change the text property) as this would not be thread safe!
      Specified by:
      toString in interface Text<B extends Text<B>>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String