All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.prevayler.demos.memento.commands.AccountDeletion Maven / Gradle / Ivy

The newest version!
package org.prevayler.demos.memento.commands;

import java.io.Serializable;
import org.prevayler.util.memento.MementoCollector;
import org.prevayler.util.memento.MementoTransaction;
import org.prevayler.demos.memento.Account;
import org.prevayler.demos.memento.Bank;

public class AccountDeletion extends MementoTransaction {
	private final long accountNumber;

  /**
   * Set by findObjects(...)
   */  
  protected transient Bank bank;
  
	public AccountDeletion(Account account) {
		accountNumber = account.number();
	}
  
  protected void findObjects(Object prevalentSystem) {
    bank = (Bank)prevalentSystem;
  }
  
  protected void checkPrecondition() {
  }

  protected void createMementos(MementoCollector collector) {
    bank.createMemento(collector);
  }
  
	protected Serializable execute(MementoCollector collector) throws Bank.AccountNotFound {
		bank.deleteAccount(accountNumber);
		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy