Interface Flag.Builder
- All Superinterfaces:
AbstractBuilder<Flag>,Builder<Flag,,Flag.Builder> ResettableBuilder<Flag,Flag.Builder>
- Enclosing interface:
Flag
Flags.-
Method Summary
Modifier and TypeMethodDescriptionSpecifies an alias for this flag.Specify multiple aliases at once for this flag.default Flag.BuilderSpecify multiple aliases at once for this flag.build()Validates this builder and builds thisFlag.setParameter(@Nullable Parameter parameter) Sets aParameterthat may be executed after the flag.setPermission(@Nullable String permission) Specifies the permission required to use this flag.setRequirement(@Nullable Predicate<CommandCause> requirement) Specifies the requirement to use this flag.
-
Method Details
-
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
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
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
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
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
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
Validates this builder and builds thisFlag.- Specified by:
buildin interfaceAbstractBuilder<Flag>- Returns:
- A
Flag - Throws:
IllegalStateException- if no key or no alias is specified
-