Class RadioGroup.Builder

java.lang.Object
net.dv8tion.jda.api.components.radiogroup.RadioGroup.Builder
Enclosing interface:
RadioGroup

public static class RadioGroup.Builder extends Object
Builder of RadioGroup
See Also:
  • Method Details

    • getUniqueId

      public int getUniqueId()
      The unique ID of this radio group, or -1 if it isn't set.
      Returns:
      The unique ID, or -1
    • getCustomId

      @Nonnull public String getCustomId()
      The custom ID of this radio group.
      Returns:
      The custom ID
    • isRequired

      public boolean isRequired()
      Whether this radio group requires an option to be selected.
      Returns:
      true if an option must be selected by the user
    • setUniqueId

      @Nonnull public RadioGroup.Builder setUniqueId(int uniqueId)
      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

      @Nonnull public RadioGroup.Builder setCustomId(@Nonnull String customId)
      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 is null, blank, or longer than 100 characters
    • addOptions

      @Nonnull public RadioGroup.Builder addOptions(@Nonnull 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 array or an element is null
    • 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 is null
    • addOption

      @Nonnull public RadioGroup.Builder addOption(@Nonnull String label, @Nonnull String value)
      Adds an option to this radio group.
      Parameters:
      label - The label to be displayed next to the radio button, up to 100 characters
      value - 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 is null or 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 characters
      value - The value associated to the option, this is what your bot will receive, up to 100 characters
      description - The description of this radio button, up to 100 characters
      Returns:
      This instance for chaining convenience
      Throws:
      IllegalArgumentException - If the label or value is null or 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 characters
      value - The value associated to the option, this is what your bot will receive, up to 100 characters
      description - The description of this radio button, up to 100 characters
      isDefault - Whether this option will be selected by default
      Returns:
      This instance for chaining convenience
      Throws:
      IllegalArgumentException - If the label or value is null or blank, or the description is blank, or one of them is longer than allowed
    • getOptions

      @Nonnull public List<RadioGroupOption> getOptions()
      Returns a modifiable list of radio group options.
      Returns:
      The modifiable list of options
    • setRequired

      @Nonnull public RadioGroup.Builder setRequired(boolean required)
      Sets whether this radio group must have an option selected.

      Radio groups are required by default.

      Parameters:
      required - true if a value must be selected before submitting
      Returns:
      This instance for chaining convenience
    • setSelectedValue

      @Nonnull public RadioGroup.Builder setSelectedValue(@Nullable String value)
      Configures one of the currently applied options to be selected by default.
      Parameters:
      value - The option value to select, null to remove the default
      Returns:
      This instance for chaining convenience
    • setSelectedOption

      @Nonnull public RadioGroup.Builder setSelectedOption(@Nullable RadioGroupOption option)
      Configures one of the currently applied options to be selected by default.
      Parameters:
      option - The option to select, null to remove the default
      Returns:
      This instance for chaining convenience
    • build

      @Nonnull public RadioGroup build()
      Builds a new RadioGroup from 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