Class SuggestionsBuilder

java.lang.Object
dev.polv.taleapi.command.suggestion.SuggestionsBuilder

public final class SuggestionsBuilder extends Object
Builder for creating Suggestions.

Used by argument types to provide autocompletion suggestions.

  • Constructor Details

    • SuggestionsBuilder

      public SuggestionsBuilder(String input, int start)
      Creates a new suggestions builder.
      Parameters:
      input - the full input string
      start - the position where suggestions start
  • Method Details

    • getInput

      public String getInput()
      Returns the full input string.
      Returns:
      the input
    • getStart

      public int getStart()
      Returns the position where suggestions start.
      Returns:
      the start position
    • getRemaining

      public String getRemaining()
      Returns the remaining portion of the input after the start position.
      Returns:
      the remaining input
    • getRemainingLowerCase

      public String getRemainingLowerCase()
      Returns the remaining portion in lowercase.
      Returns:
      the lowercase remaining input
    • suggest

      public SuggestionsBuilder suggest(String text)
      Adds a suggestion.
      Parameters:
      text - the suggestion text
      Returns:
      this builder
    • suggest

      public SuggestionsBuilder suggest(String text, String tooltip)
      Adds a suggestion with a tooltip.
      Parameters:
      text - the suggestion text
      tooltip - the tooltip
      Returns:
      this builder
    • suggest

      public SuggestionsBuilder suggest(int value)
      Adds an integer suggestion.
      Parameters:
      value - the integer value
      Returns:
      this builder
    • suggest

      public SuggestionsBuilder suggest(int value, String tooltip)
      Adds an integer suggestion with a tooltip.
      Parameters:
      value - the integer value
      tooltip - the tooltip
      Returns:
      this builder
    • suggest

      public SuggestionsBuilder suggest(Iterable<String> texts)
      Adds multiple suggestions.
      Parameters:
      texts - the suggestion texts
      Returns:
      this builder
    • build

      public Suggestions build()
      Builds the suggestions.
      Returns:
      the built suggestions
    • buildFuture

      public CompletableFuture<Suggestions> buildFuture()
      Builds the suggestions as a completed future.
      Returns:
      a future containing the suggestions
    • restart

      public SuggestionsBuilder restart(int start)
      Creates a new builder restarting at the given position.
      Parameters:
      start - the new start position
      Returns:
      a new builder
    • createOffset

      public SuggestionsBuilder createOffset(int start)
      Creates a new builder with the same input but cleared suggestions.
      Parameters:
      start - the new start position for suggestions
      Returns:
      a new builder