Class Suggestion

java.lang.Object
dev.polv.taleapi.command.suggestion.Suggestion
All Implemented Interfaces:
Comparable<Suggestion>

public final class Suggestion extends Object implements Comparable<Suggestion>
A single suggestion for command autocompletion.

Each suggestion has text to insert and an optional tooltip for display.

  • Constructor Details

    • Suggestion

      public Suggestion(StringRange range, String text)
      Creates a suggestion without a tooltip.
      Parameters:
      range - the range in the input to replace
      text - the text to suggest
    • Suggestion

      public Suggestion(StringRange range, String text, String tooltip)
      Creates a suggestion with a tooltip.
      Parameters:
      range - the range in the input to replace
      text - the text to suggest
      tooltip - the tooltip to display (may be null)
  • Method Details

    • getRange

      public StringRange getRange()
      Returns the range in the input string that this suggestion would replace.
      Returns:
      the replacement range
    • getText

      public String getText()
      Returns the suggested text.
      Returns:
      the suggestion text
    • getTooltip

      public String getTooltip()
      Returns the tooltip, if any.
      Returns:
      the tooltip, or null if none
    • apply

      public String apply(String input)
      Applies this suggestion to the given input string.
      Parameters:
      input - the original input
      Returns:
      the input with this suggestion applied
    • compareTo

      public int compareTo(Suggestion other)
      Specified by:
      compareTo in interface Comparable<Suggestion>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object