Interface Flag.Builder
-
- All Superinterfaces:
Buildable.Builder<Flag>
,Builder<Flag,Flag.Builder>
,ResettableBuilder<Flag,Flag.Builder>
- Enclosing interface:
- Flag
public static interface Flag.Builder extends Builder<Flag,Flag.Builder>
A builder for creatingFlag
s.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Flag.Builder
alias(String alias)
Specifies an alias for this flag.Flag.Builder
aliases(Iterable<String> aliases)
Specify multiple aliases at once for this flag.default Flag.Builder
aliases(String... aliases)
Specify multiple aliases at once for this flag.Flag
build()
Validates this builder and builds thisFlag
.Flag.Builder
setParameter(@Nullable Parameter parameter)
Sets aParameter
that may be executed after the flag.Flag.Builder
setPermission(@Nullable String permission)
Specifies the permission required to use this flag.Flag.Builder
setRequirement(@Nullable Predicate<CommandCause> requirement)
Specifies the requirement to use this flag.
-
-
-
Method Detail
-
alias
Flag.Builder alias(String alias)
Specifies an alias for this flag. The alias must not start with a dash, this will be handled by the builder.If the alias is a single character, a single dash will be prefixed to the alias (e.g. an alias of
a
will become-a
upon invocation. Otherwise, two dashes will be prefixed to the alias (e.g.all
will become--all
.- Parameters:
alias
- The alias that this flag will have- Returns:
- This builder, for chaining
-
aliases
default Flag.Builder aliases(String... aliases)
Specify multiple aliases at once for this flag.The requirements for each alias are described in
alias(String)
- Parameters:
aliases
- The aliases to add- Returns:
- This builder, for chaining
-
aliases
Flag.Builder aliases(Iterable<String> aliases)
Specify multiple aliases at once for this flag.The requirements for each alias are described in
alias(String)
- Parameters:
aliases
- The aliases to add- Returns:
- This builder, for chaining
-
setPermission
Flag.Builder setPermission(@Nullable String permission)
Specifies the permission required to use this flag. A null permission indicates that anyone will be able to use the flag.This will overwrite anything provided in
setRequirement(Predicate)
- Parameters:
permission
- The permission to check for- Returns:
- This builder, for chaining
-
setRequirement
Flag.Builder setRequirement(@Nullable Predicate<CommandCause> requirement)
Specifies the requirement to use this flag. A null requirement indicates that anyone will be able to use the flag.This will overwrite anything provided in
setPermission(String)
- Parameters:
requirement
- APredicate
that checks whether aCommandCause
meets the requirement for invocation.- Returns:
- This builder, for chaining
-
setParameter
Flag.Builder setParameter(@Nullable Parameter parameter)
Sets aParameter
that may be executed after the flag.This will allow you to set a parameter that is conditional on this flag being specified. It is always required directly after the flag, separated by a space. Thus, setting this on a flag will result in the usage of form:
--flag <parameter>
The
Parameter
may be optional and may have its own requirements like any standard parameter. It is important to note, however, that as a flag may be invoked more than once, aCommandContext
may also have more than one entry under the givenParameter.Key
.- Parameters:
parameter
- The parameter to parse after this flag- Returns:
- This builder, for chaining
-
build
Flag build() throws IllegalStateException
Validates this builder and builds thisFlag
.- Specified by:
build
in interfaceBuildable.Builder<Flag>
- Returns:
- A
Flag
- Throws:
IllegalStateException
- if no key or no alias is specified
-
-