org.opends.server.util.cli
Class MenuResult<T>

java.lang.Object
  extended by org.opends.server.util.cli.MenuResult<T>
Type Parameters:
T - The type of result value(s) contained in success results. Use Void if success results should not contain values.

public final class MenuResult<T>
extends java.lang.Object

The result of running a Menu. The result indicates to the application how it should proceed:


Method Summary
static
<T> MenuResult<T>
again()
          Creates a new menu result indicating that the menu should be displayed again.
static
<T> MenuResult<T>
cancel()
          Creates a new menu result indicating that the user chose to cancel any task currently in progress and go back to the previous main menu if applicable.
 T getValue()
          Gets the menu result value if this is a menu result indicating success.
 java.util.Collection<T> getValues()
          Gets the menu result values if this is a menu result indicating success.
 boolean isAgain()
          Determines if this menu result indicates that the menu should be displayed again.
 boolean isCancel()
          Determines if this menu result indicates that the user chose to cancel any task currently in progress and go back to the previous main menu if applicable.
 boolean isQuit()
          Determines if this menu result indicates that the user chose to quit the application and cancel all outstanding tasks.
 boolean isSuccess()
          Determines if this menu result indicates that the user chose to apply any task currently in progress and go back to the previous menu if applicable.
static
<T> MenuResult<T>
quit()
          Creates a new menu result indicating that the user chose to quit the application and cancel all outstanding tasks.
static
<T> MenuResult<T>
success()
          Creates a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable.
static
<T> MenuResult<T>
success(java.util.Collection<T> values)
          Creates a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable.
static
<T> MenuResult<T>
success(T value)
          Creates a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

again

public static <T> MenuResult<T> again()
Creates a new menu result indicating that the menu should be displayed again. A good example of this is when a user chooses to view some help. Normally, after the help is displayed, the user is allowed to select another option.

Type Parameters:
T - The type of result value(s) contained in success results. Use Void if success results should not contain values.
Returns:
Returns a new menu result indicating that the menu should be displayed again.

cancel

public static <T> MenuResult<T> cancel()
Creates a new menu result indicating that the user chose to cancel any task currently in progress and go back to the previous main menu if applicable.

Type Parameters:
T - The type of result value(s) contained in success results. Use Void if success results should not contain values.
Returns:
Returns a new menu result indicating that the user chose to cancel any task currently in progress and go back to the previous main menu if applicable.

quit

public static <T> MenuResult<T> quit()
Creates a new menu result indicating that the user chose to quit the application and cancel all outstanding tasks.

Type Parameters:
T - The type of result value(s) contained in success results. Use Void if success results should not contain values.
Returns:
Returns a new menu result indicating that the user chose to quit the application and cancel all outstanding tasks.

success

public static <T> MenuResult<T> success()
Creates a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable. The menu result will not contain any result values.

Type Parameters:
T - The type of result value(s) contained in success results. Use Void if success results should not contain values.
Returns:
Returns a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable.The menu result will not contain any result values.

success

public static <T> MenuResult<T> success(java.util.Collection<T> values)
Creates a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable. The menu result will contain the provided values, which can be retrieved using getValue() or getValues().

Type Parameters:
T - The type of the result values.
Parameters:
values - The result values.
Returns:
Returns a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable. The menu result will contain the provided values, which can be retrieved using getValue() or getValues().

success

public static <T> MenuResult<T> success(T value)
Creates a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable. The menu result will contain the provided value, which can be retrieved using getValue() or getValues().

Type Parameters:
T - The type of the result value.
Parameters:
value - The result value.
Returns:
Returns a new menu result indicating that the user chose to apply any task currently in progress and go back to the previous menu if applicable. The menu result will contain the provided value, which can be retrieved using getValue() or getValues().

getValue

public T getValue()
Gets the menu result value if this is a menu result indicating success.

Returns:
Returns the menu result value, or null if there was no result value or if this is not a success menu result.
See Also:
isSuccess()

getValues

public java.util.Collection<T> getValues()
Gets the menu result values if this is a menu result indicating success.

Returns:
Returns the menu result values, which may be empty if there were no result values or if this is not a success menu result.
See Also:
isSuccess()

isAgain

public boolean isAgain()
Determines if this menu result indicates that the menu should be displayed again. A good example of this is when a user chooses to view some help. Normally, after the help is displayed, the user is allowed to select another option.

Returns:
Returns true if this menu result indicates that the menu should be displayed again.

isCancel

public boolean isCancel()
Determines if this menu result indicates that the user chose to cancel any task currently in progress and go back to the previous main menu if applicable.

Returns:
Returns true if this menu result indicates that the user chose to cancel any task currently in progress and go back to the previous main menu if applicable.

isQuit

public boolean isQuit()
Determines if this menu result indicates that the user chose to quit the application and cancel all outstanding tasks.

Returns:
Returns true if this menu result indicates that the user chose to quit the application and cancel all outstanding tasks.

isSuccess

public boolean isSuccess()
Determines if this menu result indicates that the user chose to apply any task currently in progress and go back to the previous menu if applicable. Any result values can be retrieved using the getValue() or getValues() methods.

Returns:
Returns true if this menu result indicates that the user chose to apply any task currently in progress and go back to the previous menu if applicable.
See Also:
getValue(), getValues()