Template Method: a fixed order-processing skeleton
One invariant sequence, varying steps supplied by a subclass or by lambdas, proven equivalent.
Template Method fixes the shape of an algorithm and lets the steps vary. This module runs one order-processing sequence (precondition, validate, price, record) two idiomatic ways: an abstract-method skeleton where each channel overrides the hooks, and a functional skeleton where the varying steps arrive as lambdas. Retail, wholesale, and marketplace channels are built both ways.
The JUnit 5 tests prove the sequence is invariant (a recording subclass checks
hook order; Mockito InOrder checks the functional form), that the skeleton
method is final, and that both forms produce an identical result per channel.
Build, run, observe
cd examples/09-template-method
mvn -q test
./demo.sh
The module also runs from the aggregator root with
mvn -q -f examples/pom.xml test.