Interface StringVisitable

All Known Subinterfaces:
MutableText, Text
All Known Implementing Classes:
BaseText, KeybindText, LiteralText, NbtText, NbtText.BlockNbtText, NbtText.EntityNbtText, NbtText.StorageNbtText, ScoreText, SelectorText, TextHandler.StyledString, TranslatableText

public interface StringVisitable
An object that can supply strings to a visitor, with or without a style context.
  • Field Details

    • TERMINATE_VISIT

      static final Optional<Unit> TERMINATE_VISIT
      Convenience object indicating the termination of a string visit.
    • EMPTY

      static final StringVisitable EMPTY
      An empty visitable that does not call the visitors.
  • Method Details

    • visit

      <T> Optional<T> visit​(StringVisitable.Visitor<T> visitor)
      Supplies this visitable's literal content to the visitor.
      Parameters:
      visitor - the visitor
      Returns:
      Optional.empty() if the visit finished, or a terminating result from the visitor
    • visit

      @Environment(CLIENT) <T> Optional<T> visit​(StringVisitable.StyledVisitor<T> styledVisitor, Style style)
      Supplies this visitable's literal content and contextual style to the visitor.
      Parameters:
      styledVisitor - the visitor
      style - the contextual style
      Returns:
      Optional.empty() if the visit finished, or a terminating result from the visitor
    • plain

      static StringVisitable plain​(String string)
      Creates a visitable from a plain string.
      Parameters:
      string - the plain string
    • styled

      @Environment(CLIENT) static StringVisitable styled​(String string, Style style)
      Creates a visitable from a plain string and a root style.
      Parameters:
      string - the plain string
      style - the root style
    • concat

      @Environment(CLIENT) static StringVisitable concat​(StringVisitable[] visitables)
      Concats multiple string visitables by the order they appear in the array.
      Parameters:
      visitables - an array or varargs of visitables
    • concat

      @Environment(CLIENT) static StringVisitable concat​(List<StringVisitable> visitables)
      Concats multiple string visitables by the order they appear in the list.
      Parameters:
      visitables - a list of visitables
    • getString

      default String getString()