Package cloud.commandframework.arguments
Class CommandArgument.Builder<C,T>
java.lang.Object
cloud.commandframework.arguments.CommandArgument.Builder<C,T>
- Type Parameters:
C- Command sender typeT- Argument value type
- Direct Known Subclasses:
BooleanArgument.Builder,ByteArgument.Builder,CharArgument.Builder,CommandArgument.TypedBuilder,DoubleArgument.Builder,EnumArgument.Builder,FloatArgument.Builder,IntegerArgument.Builder,LongArgument.Builder,ShortArgument.Builder,StringArgument.Builder,UUIDArgument.Builder
- Enclosing class:
- CommandArgument<C,
T>
Mutable builder for
CommandArgument instances-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> Indicates that the argument is optional.@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> asOptionalWithDefault(@NonNull String defaultValue) Indicates that the argument is optional.@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> Indicates that the argument is required.@NonNull CommandArgument<@NonNull C,@NonNull T> build()Construct a command argument from the builder settingsprotected final @NonNull ArgumentDescriptionprotected final @NonNull Stringprotected final @NonNull StringgetName()protected final @NonNull ArgumentParser<@NonNull C,@NonNull T> protected final @NonNull BiFunction<@NonNull CommandContext<C>,@NonNull String, @NonNull List<String>> protected final @NonNull io.leangen.geantyref.TypeToken<T>protected final boolean@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> manager(@NonNull CommandManager<C> manager) Set the command manager.@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> withDefaultDescription(@NonNull ArgumentDescription defaultDescription) Set the default description to be used for this argument.@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> withParser(@NonNull ArgumentParser<@NonNull C, @NonNull T> parser) Set the argument parser@NonNull CommandArgument.Builder<@NonNull C,@NonNull T> withSuggestionsProvider(@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider) Set the suggestions provider
-
Constructor Details
-
Builder
-
Builder
-
-
Method Details
-
manager
public @NonNull CommandArgument.Builder<@NonNull C,@NonNull T> manager(@NonNull CommandManager<C> manager) Set the command manager. Will be used to create a default parser if none was provided- Parameters:
manager- Command manager- Returns:
- Builder instance
-
asRequired
Indicates that the argument is required. All arguments prior to any other required argument must also be required, such that the predicate (∀ c_i ∈ required)({c_0, ..., c_i-1} ⊂ required) holds true, where {c_0, ..., c_n-1} is the set of command arguments.- Returns:
- Builder instance
-
asOptional
Indicates that the argument is optional. All arguments prior to any other required argument must also be required, such that the predicate (∀ c_i ∈ required)({c_0, ..., c_i-1} ⊂ required) holds true, where {c_0, ..., c_n-1} is the set of command arguments.- Returns:
- Builder instance
-
asOptionalWithDefault
public @NonNull CommandArgument.Builder<@NonNull C,@NonNull T> asOptionalWithDefault(@NonNull String defaultValue) Indicates that the argument is optional. All arguments prior to any other required argument must also be required, such that the predicate (∀ c_i ∈ required)({c_0, ..., c_i-1} ⊂ required) holds true, where {c_0, ..., c_n-1} is the set of command arguments.- Parameters:
defaultValue- Default value that will be used if none was supplied- Returns:
- Builder instance
-
withParser
public @NonNull CommandArgument.Builder<@NonNull C,@NonNull T> withParser(@NonNull ArgumentParser<@NonNull C, @NonNull T> parser) Set the argument parser- Parameters:
parser- Argument parser- Returns:
- Builder instance
-
withSuggestionsProvider
public @NonNull CommandArgument.Builder<@NonNull C,@NonNull T> withSuggestionsProvider(@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider) Set the suggestions provider- Parameters:
suggestionsProvider- Suggestions provider- Returns:
- Builder instance
-
withDefaultDescription
@API(status=STABLE, since="1.4.0") public @NonNull CommandArgument.Builder<@NonNull C,@NonNull T> withDefaultDescription(@NonNull ArgumentDescription defaultDescription) Set the default description to be used for this argument.The default description is used when no other description is provided for a certain argument.
- Parameters:
defaultDescription- The default description- Returns:
- Builder instance
- Since:
- 1.4.0
-
build
Construct a command argument from the builder settings- Returns:
- Constructed argument
-
getName
-
isRequired
protected final boolean isRequired() -
getParser
-
getDefaultValue
-
getSuggestionsProvider
protected final @NonNull BiFunction<@NonNull CommandContext<C>,@NonNull String, getSuggestionsProvider()@NonNull List<String>> -
getDefaultDescription
-
getValueType
-