/***
 * Excerpted from "Domain-Driven Design Using Naked Objects",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/dhnako for more book information.
***/
public void modifyOwningCustomer( final Customer owningCustomer) {
    Customer currentOwningCustomer = getOwningCustomer();
    // check for no-op
    if (owningCustomer == null || 
        owningCustomer.equals(currentOwningCustomer)) {
        return;
    }

    // associate new
    setOwningCustomer(owningCustomer);

    // additional business logic
    onModifyOwningCustomer(currentOwningCustomer, owningCustomer);
}
public void clearOwningCustomer() {
    Customer currentOwningCustomer = getOwningCustomer();
    // check for no-op
    if (currentOwningCustomer == null) {
        return;
    }

    // dissociate existing
    setOwningCustomer(null);

    // additional business logic
    onClearOwningCustomer(currentOwningCustomer);
}
protected void onModifyOwningCustomer(
        final Customer oldOwningCustomer, 
        final Customer newOwningCustomer) {
}
protected void onClearOwningCustomer(
        final Customer oldOwningCustomer) {
}
