Convenience for getChoices(message, 0, 1, choices). @param is automatically inferred. @param message a java.lang.String object. @param choices a T object. @return null if choices is missing, empty, or if the users' choices are empty; otherwise, r
(final String message, final T[] choices, final Consumer<T> callback)
| 32 | * @see #getChoices(String, int, int, Object...) |
| 33 | */ |
| 34 | public static <T> void oneOrNone(final String message, final T[] choices, final Consumer<T> callback) { |
| 35 | if ((choices == null) || (choices.length == 0)) { |
| 36 | callback.accept(null); |
| 37 | return; |
| 38 | } |
| 39 | getChoices(message, 0, 1, choices, result -> callback.accept(result.isEmpty() ? null : result.get(0))); |
| 40 | } |
| 41 | |
| 42 | public static <T> void oneOrNone(final String message, final Collection<T> choices, final Consumer<T> callback) { |
| 43 | if ((choices == null) || choices.isEmpty()) { |
no test coverage detected