Class CheckboxesQuestion

java.lang.Object
com.marcpg.libpg.formular.question.Question
com.marcpg.libpg.formular.question.CheckboxesQuestion

public class CheckboxesQuestion extends Question
A question with multiple choices, that can each be checked or unchecked. Supports multiple checked choices.
Note that most features will require you to manually implement the JNA dependency (>5.14.0)!
Since:
0.0.8
See Also:
  • Constructor Details

    • CheckboxesQuestion

      public CheckboxesQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, @NotNull @NotNull List<String> choices)
      Creates a new checkboxes question.
      Parameters:
      id - The question's unique identifier.
      title - The question's title.
      description - The question's description.
      choices - A list of all choices that can be checked.
    • CheckboxesQuestion

      public CheckboxesQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, String... choices)
      Creates a new checkboxes question.
      Parameters:
      id - The question's unique identifier.
      title - The question's title.
      description - The question's description.
      choices - All choices that can be checked.
  • Method Details

    • resetState

      public void resetState()
      Description copied from class: Question
      Resets the state of this question to be as if it was just created. Won't reset the question's settings, but only the already chosen and rendered things.
      Specified by:
      resetState in class Question
    • up

      public void up()
      Moves the cursor up one choice, if it's not already all the way up.
    • down

      public void down()
      Moves the cursor down one choice, if it's not already at the bottom.
    • toggle

      public void toggle(String choice)
      Toggles a choice based on its name, if the question wasn't already submitted.
      Parameters:
      choice - The choice to toggle.
    • submit

      public void submit()
      Description copied from class: Question
      Submits the question with the current choice and locks in a final answer.
      Specified by:
      submit in class Question
    • getInput

      public String[] getInput()
      Description copied from class: Question
      Gets the current or preferably final input of the question.
      Specified by:
      getInput in class Question
      Returns:
      The current or preferably final input of this question.
    • toResult

      public FormularResult.Result toResult()
      Description copied from class: Question
      Converts this question to a Result, that can be used in a FormularResult.
      Specified by:
      toResult in class Question
      Returns:
      The converted result.
    • cliRender

      public void cliRender()
      Renders the current question to System.out. Will only work for CLIFormulars.
      Gives the user a list of checkboxes ([ ] Name/[x] Name), which can be navigated using W for up, S for down and Space for toggling.
      Specified by:
      cliRender in class Question