|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.command.LogCommand<E>
E
- The type of result obtained by executing this command.
This command type always return null as the result.@Participant(value="ConcreteCommand") public class LogCommand<E>
A log command simply logs the operation performed on the receiver object.
A log command carries no state, and is considered
undoable
as to not interfere with
regular commands.
Log commands are thread-safe and can be shared as they do not alter the receiver, only prints it to the log.
Field Summary | |
---|---|
private Object |
receiver
The receiver object. |
Constructor Summary | |
---|---|
LogCommand(Object receiver)
Constructor. |
Method Summary | |
---|---|
LogCommand<E> |
copy()
Creates a copy of this command, excluding internal state information required for execution and undo. |
boolean |
equals(Object object)
Returns true if object is an instance
of a this class and has the same receiver (compared
using equals(Object) . |
List<Command<E>> |
execute()
Logs the string representation of the receiver object followed by " .execute() ". |
E |
getResult()
Returns the result of the execution of this
command. |
int |
hashCode()
Returns the hash code of this log command. |
boolean |
isUndoable()
Returns true. |
String |
toString()
Returns the string representation of this log command. |
E |
undo()
Logs the string representation of the receiver object followed by " .undo() ". |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
@Participant(value="Receiver") private final Object receiver
Never null.
Constructor Detail |
---|
public LogCommand(@Participant(value="Receiver") Object receiver)
receiver
- The receiver object; cannot be null.
NullPointerException
- If receiver
is null.Method Detail |
---|
public LogCommand<E> copy()
Command
copy
in interface Command<E>
copy
in interface Copyable<Command<E>>
public boolean equals(Object object)
object
is an instance
of a this class and has the same receiver (compared
using equals(Object)
.
equals
in class Object
object
- The object to test; can be null.
public List<Command<E>> execute()
.execute()
".
execute
in interface Command<E>
Command.undo()
public E getResult()
Command
execution
of this
command.
Invoking this method before execution will cause an illegal
state exception to be thrown. If undone
,
this command must be re-executed before the result can be
fetched again.
getResult
in interface Command<E>
public int hashCode()
hashCode
in class Object
public boolean isUndoable()
isUndoable
in interface Command<E>
public String toString()
toString
in class Object
public E undo()
.undo()
".
undo
in interface Command<E>
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |