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 creatingFlags.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Flag.Builderalias(String alias)Specifies an alias for this flag.Flag.Builderaliases(Iterable<String> aliases)Specify multiple aliases at once for this flag.default Flag.Builderaliases(String... aliases)Specify multiple aliases at once for this flag.Flagbuild()Validates this builder and builds thisFlag.Flag.BuildersetParameter(@Nullable Parameter parameter)Sets aParameterthat may be executed after the flag.Flag.BuildersetPermission(@Nullable String permission)Specifies the permission required to use this flag.Flag.BuildersetRequirement(@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
awill become-aupon invocation. Otherwise, two dashes will be prefixed to the alias (e.g.allwill 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- APredicatethat checks whether aCommandCausemeets the requirement for invocation.- Returns:
- This builder, for chaining
-
setParameter
Flag.Builder setParameter(@Nullable Parameter parameter)
Sets aParameterthat 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
Parametermay 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, aCommandContextmay 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:
buildin interfaceBuildable.Builder<Flag>- Returns:
- A
Flag - Throws:
IllegalStateException- if no key or no alias is specified
-
-