Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

public class Customer {

public Customer placeOrder(Product p, int quantity) { ... }
public boolean hidePlaceOrder() { return this.isBlackListed(); }
public String disablePlaceOrder() { return clockService.outsideShoppingHours(); }
public String disable1PlaceOrder(Product p) { return p.isOutOfStock() ? "Out of stock": null; } // could also hide parameters similarly
public Collection<Product> choices0PlaceOrder() { ... } // or autoComplete0PlaceOrder(String search) { ... }
public Product default0PlaceOrder() { return orderService.findLastProductPurchasedBy(this); }
public int default1PlaceOrder() { return 1; }
public String validate1PlaceOrder(int quantity) { return quantity <= 0 ? "Can only order +ve amounts": null; }
public String validatePlaceOrder(Product p, int quantity) { return catalogService.runningLowOn(p) && quantity > 4 ? "We're running low on that product, no more than 4" : null; }
}

Mixins syntax

Mixins change the target, by allowing this set of methods to be moved to a different object target:

public class Customer { ... }

@Action // or @Mixin(method="act") and a bunch of other annotations
public class Customer_placeOrder() { // infer action name from the mixin class name

private final Customer target; // constructor omitted

public Customer act(Product p, int quantity) { ... }
public boolean hideAct() { ... }
public String disableAct() { ... }
public String disable1Act(Product p) { ... }
public Collection<Product> choices0Act() { ... }
public Product default0Act() { ... }
public int default1Act() { ...}
public String validate1Act(int quantity) { ... }
public String validateAct(Product p, int quantity) { ... }
}

Parameters syntax (proposed)

...