Class Suggestion
java.lang.Object
dev.polv.taleapi.command.suggestion.Suggestion
- All Implemented Interfaces:
Comparable<Suggestion>
A single suggestion for command autocompletion.
Each suggestion has text to insert and an optional tooltip for display.
-
Constructor Summary
ConstructorsConstructorDescriptionSuggestion(StringRange range, String text) Creates a suggestion without a tooltip.Suggestion(StringRange range, String text, String tooltip) Creates a suggestion with a tooltip. -
Method Summary
Modifier and TypeMethodDescriptionApplies this suggestion to the given input string.intcompareTo(Suggestion other) booleangetRange()Returns the range in the input string that this suggestion would replace.getText()Returns the suggested text.Returns the tooltip, if any.inthashCode()toString()
-
Constructor Details
-
Suggestion
Creates a suggestion without a tooltip.- Parameters:
range- the range in the input to replacetext- the text to suggest
-
Suggestion
Creates a suggestion with a tooltip.- Parameters:
range- the range in the input to replacetext- the text to suggesttooltip- the tooltip to display (may be null)
-
-
Method Details
-
getRange
Returns the range in the input string that this suggestion would replace.- Returns:
- the replacement range
-
getText
Returns the suggested text.- Returns:
- the suggestion text
-
getTooltip
Returns the tooltip, if any.- Returns:
- the tooltip, or null if none
-
apply
Applies this suggestion to the given input string.- Parameters:
input- the original input- Returns:
- the input with this suggestion applied
-
compareTo
- Specified by:
compareToin interfaceComparable<Suggestion>
-
equals
-
hashCode
public int hashCode() -
toString
-