Class EnumTypeParser<S>
java.lang.Object
dev.ua.theroer.magicutils.commands.parsers.EnumTypeParser<S>
- Type Parameters:
S- sender type
- All Implemented Interfaces:
TypeParser<S,Enum<?>>
Generic enum parser to avoid registering a parser per enum type.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this parser can handle the given type.booleancanParseSuggestion(@NotNull String source) Checks if this parser can handle a special suggestion source.getSuggestions(S sender) Gets suggestions for this type.getSuggestions(S sender, @Nullable CommandArgument argument) Gets suggestions for this type with access to the argument metadata.Enum<?> Parses the given value to the target type.parseSuggestion(@NotNull String source, S sender) Parses a special suggestion source and returns suggestions.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TypeParser
getPriority, getSuggestions, getSuggestionsFiltered, isEqual, isSender, parseDetailed
-
Constructor Details
-
EnumTypeParser
public EnumTypeParser()Default constructor.
-
-
Method Details
-
canParse
Description copied from interface:TypeParserChecks if this parser can handle the given type.- Specified by:
canParsein interfaceTypeParser<S,Enum<?>> - Parameters:
type- the class type to check- Returns:
- true if this parser can handle the type
-
parse
public Enum<?> parse(@Nullable @Nullable String value, @NotNull @NotNull Class<Enum<?>> targetType, @NotNull S sender) Description copied from interface:TypeParserParses the given value to the target type.- Specified by:
parsein interfaceTypeParser<S,Enum<?>> - Parameters:
value- the string value to parsetargetType- the target class typesender- the command sender (for context like @sender)- Returns:
- the parsed object or null if parsing failed
-
getSuggestions
Description copied from interface:TypeParserGets suggestions for this type.- Specified by:
getSuggestionsin interfaceTypeParser<S,Enum<?>> - Parameters:
sender- the command sender for context- Returns:
- list of all possible suggestions
-
getSuggestions
Description copied from interface:TypeParserGets suggestions for this type with access to the argument metadata.- Specified by:
getSuggestionsin interfaceTypeParser<S,Enum<?>> - Parameters:
sender- the command sender for contextargument- the command argument (may be null)- Returns:
- list of suggestions
-
canParseSuggestion
Description copied from interface:TypeParserChecks if this parser can handle a special suggestion source. This allows parsers to handle special syntax like @players, @worlds, etc.- Specified by:
canParseSuggestionin interfaceTypeParser<S,Enum<?>> - Parameters:
source- the suggestion source to check- Returns:
- true if this parser can handle the source
-
parseSuggestion
Description copied from interface:TypeParserParses a special suggestion source and returns suggestions.- Specified by:
parseSuggestionin interfaceTypeParser<S,Enum<?>> - Parameters:
source- the suggestion sourcesender- the command sender for context- Returns:
- list of suggestions from the source
-