| | |
| | | */ |
| | | public final class MenuResult<T> { |
| | | |
| | | /** |
| | | * The type of result returned from the menu. |
| | | */ |
| | | /** The type of result returned from the menu. */ |
| | | private static enum Type { |
| | | /** |
| | | * The user selected an option which did not return a result, |
| | |
| | | * @return Returns a new menu result indicating that the menu should be displayed again. |
| | | */ |
| | | public static <T> MenuResult<T> again() { |
| | | return new MenuResult<T>(Type.AGAIN, Collections.<T> emptyList()); |
| | | return new MenuResult<>(Type.AGAIN, Collections.<T> emptyList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * back to the previous main menu if applicable. |
| | | */ |
| | | public static <T> MenuResult<T> cancel() { |
| | | return new MenuResult<T>(Type.CANCEL, Collections.<T> emptyList()); |
| | | return new MenuResult<>(Type.CANCEL, Collections.<T> emptyList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * outstanding tasks. |
| | | */ |
| | | public static <T> MenuResult<T> quit() { |
| | | return new MenuResult<T>(Type.QUIT, Collections.<T> emptyList()); |
| | | return new MenuResult<>(Type.QUIT, Collections.<T> emptyList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * retrieved using {@link #getValue()} or {@link #getValues()}. |
| | | */ |
| | | public static <T> MenuResult<T> success(Collection<T> values) { |
| | | return new MenuResult<T>(Type.SUCCESS, new ArrayList<T>(values)); |
| | | return new MenuResult<>(Type.SUCCESS, new ArrayList<>(values)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @see #isSuccess() |
| | | */ |
| | | public Collection<T> getValues() { |
| | | return new ArrayList<T>(values); |
| | | return new ArrayList<>(values); |
| | | } |
| | | |
| | | /** |