Código Command
public interface Command {
	public void execute();
	public void undo();
}


public class ClientApp {
	public static void main(String[] args) {
		Receiver rec = new Receiver();
		Command Command2 = new ConcreteCommand2(rec);
		Command Command1 = new ConcreteCommand1(rec);
		Invoker invoker = new Invoker();
		invoker.setConcCommand1(Command1);
		invoker.setConcCommand2(Command2);
		invoker.addRequest();
		invoker.addRequest();
		invoker.removeRequest();
		System.out.println(rec.getValue());
	}
}


public class Invoker {
	Stack commands;
	Command Command2;
	Command Command1;

	public Invoker() {
		commands = new Stack();
	}

	public void setIncCommand(Command command) {
		Command2 = command;
	}

	public void setDecCommand(Command command) {
		Command1 = command;
	}

	public void undoAll() {
		Command cmd = null;
		while (!commands.empty()) {
			cmd = commands.pop();
			cmd.undo();
		}
}


public class Receiver {
	private int  valor;

	public Receiver() {
		valor = 0;
	}
 
	public void concCommand2Method() {  
		OPERACIÓN (valor);  
	}
 
	public void concCommand1Method(() {
		OPERACIÓN (valor);
	}
 
	public int getValue() {
		return valor;
	}
}


public class ConcreteCommand1 implements Command {
	Receiver receiver;

	public ConcreteCommand1(Receiver receiver) {
		this.receiver = receiver;    
	}
  
	public void execute() {
		receiver.concCommand1Method();    
	}
}


public class ConcreteCommand2 implements Command {
  	Receiver receiver;  

	Public ConcreteCommand2(Receiver rec) {
		receiver = rec;
	}

	public void execute() {
		receiver.concCommand2Method();
	}
	
	public void undo() {
		....;
	}
}