...
- we now have three classes here: the mixin, the domain event, and the parameters object.
Parameters on Act syntax (proposed)
This is a variant of the previous, but uses the parameters class in the action as well:
Code Block |
---|
public class Customer { // target
@Value @Accessors(fluent = true)
public class PlaceOrderParameters { // to assist supporting methods
Product product;
int quantity;
}
public static class PlacerOrderEvent extends ActionDomainEvent<Customer> {}
@Action(domainEvent = PlaceOrderEvent.class) // event publishing
public Customer placeOrder(PlaceOrderParameters params) { ... } // execution
public boolean hidePlaceOrder() { ... } // supporting methods use PlaceOrderParameters
public String disablePlaceOrder() { ... }
public String disable1PlaceOrder(PlaceOrderParameters params) { ... }
public Collection<Product> choices0PlaceOrder() { ... }
public Product default0PlaceOrder() { ... }
public int default1PlaceOrder() { ... }
public String validate1PlaceOrder(PlaceOrderParameters params) { ... }
public String validatePlaceOrder(PlaceOrderParameters params) { ... }
} |
Notes:
- this removes the duplication between the placeOrder(...) parameter list and the list of members in PlaceOrderParameters class.
As a mixin, this becomes: