Class CommandComponent.Builder<C,T>
- Enclosing class:
CommandComponent<C>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a command component using this builder.commandManager(@Nullable CommandManager<C> commandManager) Sets the command manager, which will be used to create a parser if none is provided.Returns the current default value, if it has been set.defaultValue(@Nullable DefaultValue<? super C, T> defaultValue) Sets thedefaultValue.Returns the current description.description(@NonNull Description description) Sets thedescription.name()Returns the current name, if it has been set.Sets thenameof the component.optional()Setsrequiredtofalse.optional(@Nullable DefaultValue<? super C, T> defaultValue) Setsrequiredtotrueand updates thedefaultValue.parser()Returns the current parser, if it has been set.parser(@NonNull ArgumentParser<? super C, T> parser) Sets theparser.parser(@NonNull ParserDescriptor<? super C, T> parserDescriptor) Sets theparserandvalueType.preprocessor(@NonNull ComponentPreprocessor<? super C> preprocessor) Adds thepreprocessor.preprocessors(@NonNull Collection<ComponentPreprocessor<C>> preprocessors) Adds thepreprocessors.required()Setsrequiredtotrue.required(boolean required) Sets whether the component is required.Returns the current suggestion provider, if it has been set.suggestionProvider(@Nullable SuggestionProvider<? super C> suggestionProvider) Sets thesuggestionProvider.Sets thevalueType.Sets thevalueType.
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
commandManager
public @NonNull CommandComponent.Builder<C,T> commandManager(@Nullable CommandManager<C> commandManager) Sets the command manager, which will be used to create a parser if none is provided.If the command manager is
nulland noparser(ArgumentParser)is specified then the command component is invalid.- Parameters:
commandManager- the command manager- Returns:
this
-
key
- Parameters:
cloudKey- the key- Returns:
this
-
name
Returns the current name, if it has been set.- Returns:
- current name
-
name
Sets thenameof the component.The name is used to extract the parsed values from the
CommandContext.- Parameters:
name- the name- Returns:
this
-
valueType
Sets thevalueType.This is always required and the component will be invalid is the value type is
nullwhen the component is built.If no
parseris specified then the default parser will be retrieved from thecommand manager.- Parameters:
valueType- the value type- Returns:
this
-
valueType
Sets thevalueType.This is always required and the component will be invalid is the value type is
nullwhen the component is built.If no
parseris specified then the default parser will be retrieved from thecommand manager.- Parameters:
valueType- the value type- Returns:
this
-
parser
Returns the current parser, if it has been set.- Returns:
- current parser
-
parser
public @NonNull CommandComponent.Builder<C,T> parser(@NonNull ParserDescriptor<? super C, T> parserDescriptor) Sets theparserandvalueType.- Parameters:
parserDescriptor- descriptor of the parser- Returns:
this
-
defaultValue
Returns the current default value, if it has been set.- Returns:
- current default value
-
defaultValue
public @NonNull CommandComponent.Builder<C,T> defaultValue(@Nullable DefaultValue<? super C, T> defaultValue) Sets thedefaultValue.This should not be set if
requiredistrue.- Parameters:
defaultValue- the default value- Returns:
this
-
required
Sets whether the component is required.Defaults to
true.- Parameters:
required- whether component is required- Returns:
this
-
required
Setsrequiredtotrue.- Returns:
this
-
optional
Setsrequiredtofalse.- Returns:
this
-
optional
public @NonNull CommandComponent.Builder<C,T> optional(@Nullable DefaultValue<? super C, T> defaultValue) Setsrequiredtotrueand updates thedefaultValue.- Parameters:
defaultValue- the default value- Returns:
this
-
description
Returns the current description.- Returns:
- current description
-
description
Sets thedescription.Defaults to
Description.empty().- Parameters:
description- the description- Returns:
this
-
suggestionProvider
Returns the current suggestion provider, if it has been set.- Returns:
- current suggestion provider
-
suggestionProvider
public @NonNull CommandComponent.Builder<C,T> suggestionProvider(@Nullable SuggestionProvider<? super C> suggestionProvider) Sets thesuggestionProvider.Defaults to
parser.- Parameters:
suggestionProvider- the suggestion provider- Returns:
this
-
preprocessor
public @NonNull CommandComponent.Builder<C,T> preprocessor(@NonNull ComponentPreprocessor<? super C> preprocessor) Adds thepreprocessor.- Parameters:
preprocessor- the preprocessor- Returns:
this
-
preprocessors
public @NonNull CommandComponent.Builder<C,T> preprocessors(@NonNull Collection<ComponentPreprocessor<C>> preprocessors) Adds thepreprocessors.- Parameters:
preprocessors- the preprocessors- Returns:
this
-
parser
Sets theparser. If no parser is set and themanagerhas been set then the default parser for thevalueTypewill be used instead.If both
parserandmanagerare null it will not be possible to parse the component.- Parameters:
parser- the parser- Returns:
this
-
build
Builds a command component using this builder.Each invocation produces a unique component.
- Returns:
- the built component
-