java.lang.Object
hudson.model.AbstractDescribableImpl<Choice>
io.jenkins.plugins.interactiveinput.model.Choice
All Implemented Interfaces:
Describable<Choice>, Serializable

public class Choice extends AbstractDescribableImpl<Choice> implements Serializable
A single selectable option offered to the human, optionally carrying a why rationale that explains, in plain language, when this option is the right one.

Instances are immutable once constructed and are safe to persist via XStream and to serialise across a Jenkins restart.

It is a Describable (B17) so the askInteractive step's config.jelly can render the choice list as a repeatable nested form block in the Pipeline Snippet Generator. The descriptor adds no persisted state, so existing XStream data is unaffected.

See Also:
  • Constructor Details

    • Choice

      @DataBoundConstructor public Choice(@NonNull String id, @NonNull String label)
      Parameters:
      id - stable identifier returned to the pipeline when this choice is picked (required)
      label - human-readable label shown in the UI (required)
  • Method Details

    • setWhy

      @DataBoundSetter public void setWhy(@CheckForNull String why)
      Parameters:
      why - optional rationale shown in muted text beneath the label
    • getId

      @NonNull public String getId()
    • getLabel

      @NonNull public String getLabel()
    • getWhy

      @CheckForNull public String getWhy()
    • toJson

      @NonNull public net.sf.json.JSONObject toJson()
      Returns:
      this choice as a JSON object with id, label and (if present) why. Values are stored raw; JSON string escaping is handled by the JSON library and HTML escaping is the caller/Jelly's responsibility.