/*
* Sample pattern: Aggregate generates Value Object using function<br>
* Higher order function is closured by policy
*/
Offer newOffer = reservation.calculateOffer(
discountFactory.create(loadClient()));
/*
* Sample pattern: Client Tier sends back old VOs, Server generates new VOs based on Aggregate state<br>
* Notice that this VO is not stored in Repo, it's stored on the Client Tier.
*/
if (! newOffer.sameAs(seenOffer, 5))//TODO load delta from conf.
throw new OfferChangedExcpetion(reservation.getAggregateId(), seenOffer, newOffer);
Client client = loadClient();//create per logged client, not reservation owner
Purchase purchase = purchaseFactory.create(reservation.getAggregateId(), client, seenOffer);