Class RadioGroup.Builder
java.lang.Object
net.dv8tion.jda.api.components.radiogroup.RadioGroup.Builder
- Enclosing interface:
RadioGroup
-
Method Summary
Modifier and TypeMethodDescriptionAdds an option to this radio group.Adds an option to this radio group.Adds an option to this radio group.addOptions(Collection<? extends RadioGroupOption> options) Adds the provided options to this radio group.addOptions(RadioGroupOption... options) Adds the provided options to this radio group.build()Builds a newRadioGroupfrom the current configuration.The custom ID of this radio group.Returns a modifiable list of radio group options.intThe unique ID of this radio group, or-1if it isn't set.booleanWhether this radio group requires an option to be selected.setCustomId(String customId) Sets the custom ID of this radio group.setRequired(boolean required) Sets whether this radio group must have an option selected.setSelectedOption(RadioGroupOption option) Configures one of the currently applied options to be selected by default.setSelectedValue(String value) Configures one of the currently applied options to be selected by default.setUniqueId(int uniqueId) Sets the unique ID of this radio group.
-
Method Details
-
getUniqueId
public int getUniqueId()The unique ID of this radio group, or-1if it isn't set.- Returns:
- The unique ID, or
-1
-
getCustomId
-
isRequired
public boolean isRequired()Whether this radio group requires an option to be selected.- Returns:
trueif an option must be selected by the user
-
setUniqueId
Sets the unique ID of this radio group.
This is used to identify components in the tree.- Parameters:
uniqueId- The new unique ID, must be positive- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the ID is negative or zero
-
setCustomId
Sets the custom ID of this radio group.
This is typically used to carry data between the modal creator and the modal handler.- Parameters:
customId- The new custom ID- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the ID isnull, blank, or longer than 100 characters
-
addOptions
Adds the provided options to this radio group.- Parameters:
options- The options to add- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the array or an element isnull
-
addOptions
@Nonnull public RadioGroup.Builder addOptions(@Nonnull Collection<? extends RadioGroupOption> options) Adds the provided options to this radio group.- Parameters:
options- The options to add- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the collection or an element isnull
-
addOption
Adds an option to this radio group.- Parameters:
label- The label to be displayed next to the radio button, up to 100 charactersvalue- The value associated to the option, this is what your bot will receive, up to 100 characters- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the label or value isnullor blank, or one of them is longer than allowed
-
addOption
@Nonnull public RadioGroup.Builder addOption(@Nonnull String label, @Nonnull String value, @Nullable String description) Adds an option to this radio group.- Parameters:
label- The label to be displayed next to the radio button, up to 100 charactersvalue- The value associated to the option, this is what your bot will receive, up to 100 charactersdescription- The description of this radio button, up to 100 characters- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the label or value isnullor blank, or the description is blank, or one of them is longer than allowed
-
addOption
@Nonnull public RadioGroup.Builder addOption(@Nonnull String label, @Nonnull String value, @Nullable String description, boolean isDefault) Adds an option to this radio group.- Parameters:
label- The label to be displayed next to the radio button, up to 100 charactersvalue- The value associated to the option, this is what your bot will receive, up to 100 charactersdescription- The description of this radio button, up to 100 charactersisDefault- Whether this option will be selected by default- Returns:
- This instance for chaining convenience
- Throws:
IllegalArgumentException- If the label or value isnullor blank, or the description is blank, or one of them is longer than allowed
-
getOptions
Returns a modifiable list of radio group options.- Returns:
- The modifiable list of options
-
setRequired
Sets whether this radio group must have an option selected.Radio groups are required by default.
- Parameters:
required-trueif a value must be selected before submitting- Returns:
- This instance for chaining convenience
-
setSelectedValue
Configures one of the currently applied options to be selected by default.- Parameters:
value- The option value to select,nullto remove the default- Returns:
- This instance for chaining convenience
-
setSelectedOption
Configures one of the currently applied options to be selected by default.- Parameters:
option- The option to select,nullto remove the default- Returns:
- This instance for chaining convenience
-
build
Builds a newRadioGroupfrom the current configuration.- Returns:
- The new
RadioGroup - Throws:
IllegalStateException-- If less than 2 options have been set
- If there is more than 10 options
- If there is more than one option selected by default
-