Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.command
Class CommandProcessingResult<E>

java.lang.Object
  extended by dk.rode.thesis.command.CommandProcessingResult<E>
Type Parameters:
E - The type of result obtained from the executed commands.

public class CommandProcessingResult<E>
extends Object

A command processing result represents the result of executing a list commands by a given command processor.

The result can represent two scenarios:

  1. The execution succeeded: executed is true, and result stores the value, which may be null. The result is the command value fetched from the last - possibly spawned - command executed.

  2. The execution failed, but was able to be completely undone: executed is false, and result is always null.
In case the execution and undo fails completely, the processor will throw an exception, and not return a result.

Author:
Gunni Rode / rode.dk
See Also:
CommandProcessor.execute(List), Command.getResult()

Field Summary
 boolean executed
          True if the commands that generated this result were successfully executed, and hence the value of result is known to be valid.
 E result
          The result of the command execution.
 
Constructor Summary
CommandProcessingResult(boolean executed, E result)
          Constructor.
 
Method Summary
 String toString()
          Returns the string representation of this result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

executed

public final boolean executed
True if the commands that generated this result were successfully executed, and hence the value of result is known to be valid.

If false, the execution failed, but all commands were successfully undone. The value of result will always be null in such cases.


result

public final E result
The result of the command execution.

The value is the result value from the last - possibly spawned - command executed.

Can be null, even if executed is true.

Constructor Detail

CommandProcessingResult

CommandProcessingResult(boolean executed,
                        E result)
Constructor.

Parameters:
executed - The executed flag.
result - The result of the execution; can be null.
Method Detail

toString

public String toString()
Returns the string representation of this result.

Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.