Record Class TextComponent

java.lang.Object
java.lang.Record
nl.pim16aap2.animatedarchitecture.core.text.TextComponent
Record Components:
decorators - A list of decorators that may be used to add additional decorations to text components. Note that such decorations are entirely optional. The renderer used for rendering the text is free to determine which decorates are supported.

public record TextComponent(List<ITextDecorator> decorators) extends Record
Represents a component in a piece of text that has zero or more ITextDecorator to add features such as colors or clickable links, etc.
  • Field Details

    • EMPTY

      public static final TextComponent EMPTY
      Text component that does not contain any decorators.
  • Constructor Details

    • TextComponent

      public TextComponent(List<ITextDecorator> decorators)
      Creates an instance of a TextComponent record class.
      Parameters:
      decorators - the value for the decorators record component
    • TextComponent

      public TextComponent(ITextDecorator... decorators)
    • TextComponent

      public TextComponent()
  • Method Details

    • withDecorators

      public TextComponent withDecorators(List<ITextDecorator> append)
      Creates a new text component with additional decorators.
      Parameters:
      append - The decorators to append.
      Returns:
      The new text component.
    • withDecorators

      public TextComponent withDecorators(ITextDecorator... append)
      Creates a new text component with additional decorators.
      Parameters:
      append - The decorators to append.
      Returns:
      The new text component.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • decorators

      public List<ITextDecorator> decorators()
      Returns the value of the decorators record component.
      Returns:
      the value of the decorators record component