< prev index next >

src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  81      *                  is represented as an index into the
  82      *                  {@code choices} array.
  83      *
  84      * @param multipleSelectionsAllowed boolean specifying whether or
  85      *                  not multiple selections can be made from the
  86      *                  list of choices.
  87      *
  88      * @exception IllegalArgumentException if {@code prompt} is null,
  89      *                  if {@code prompt} has a length of 0,
  90      *                  if {@code choices} is null,
  91      *                  if {@code choices} has a length of 0,
  92      *                  if any element from {@code choices} is null,
  93      *                  if any element from {@code choices}
  94      *                  has a length of 0 or if {@code defaultChoice}
  95      *                  does not fall within the array boundaries of
  96      *                  {@code choices}.
  97      */
  98     public ChoiceCallback(String prompt, String[] choices,
  99                 int defaultChoice, boolean multipleSelectionsAllowed) {
 100 
 101         if (prompt == null || prompt.length() == 0 ||
 102             choices == null || choices.length == 0 ||
 103             defaultChoice < 0 || defaultChoice >= choices.length)
 104             throw new IllegalArgumentException();
 105 
 106         for (int i = 0; i < choices.length; i++) {
 107             if (choices[i] == null || choices[i].length() == 0)
 108                 throw new IllegalArgumentException();
 109         }
 110 
 111         this.prompt = prompt;
 112         this.choices = choices;
 113         this.defaultChoice = defaultChoice;
 114         this.multipleSelectionsAllowed = multipleSelectionsAllowed;
 115     }
 116 
 117     /**
 118      * Get the prompt.
 119      *
 120      * @return the prompt.
 121      */
 122     public String getPrompt() {
 123         return prompt;
 124     }
 125 
 126     /**
 127      * Get the list of choices.




  81      *                  is represented as an index into the
  82      *                  {@code choices} array.
  83      *
  84      * @param multipleSelectionsAllowed boolean specifying whether or
  85      *                  not multiple selections can be made from the
  86      *                  list of choices.
  87      *
  88      * @exception IllegalArgumentException if {@code prompt} is null,
  89      *                  if {@code prompt} has a length of 0,
  90      *                  if {@code choices} is null,
  91      *                  if {@code choices} has a length of 0,
  92      *                  if any element from {@code choices} is null,
  93      *                  if any element from {@code choices}
  94      *                  has a length of 0 or if {@code defaultChoice}
  95      *                  does not fall within the array boundaries of
  96      *                  {@code choices}.
  97      */
  98     public ChoiceCallback(String prompt, String[] choices,
  99                 int defaultChoice, boolean multipleSelectionsAllowed) {
 100 
 101         if (prompt == null || prompt.isEmpty() ||
 102             choices == null || choices.length == 0 ||
 103             defaultChoice < 0 || defaultChoice >= choices.length)
 104             throw new IllegalArgumentException();
 105 
 106         for (int i = 0; i < choices.length; i++) {
 107             if (choices[i] == null || choices[i].isEmpty())
 108                 throw new IllegalArgumentException();
 109         }
 110 
 111         this.prompt = prompt;
 112         this.choices = choices;
 113         this.defaultChoice = defaultChoice;
 114         this.multipleSelectionsAllowed = multipleSelectionsAllowed;
 115     }
 116 
 117     /**
 118      * Get the prompt.
 119      *
 120      * @return the prompt.
 121      */
 122     public String getPrompt() {
 123         return prompt;
 124     }
 125 
 126     /**
 127      * Get the list of choices.


< prev index next >