Allocator
Base class for Allocation implementations. This class implements the Template Method pattern. Subclasses need to override the following members:
differenceAllocator: an DifferenceAllocation strategy used to allocate the difference between the original Money amount and its resulting allocations
calculate: calculates the allocations for a Money amount
calculateReverse: calculates the reverse result for sanity check purposes
With these methods implemented, the allocate method does the allocation and applies the DifferenceAllocation strategy to fix any difference generated by calculate. Also, the method handles the allocation of negative Money amounts.
See EvenAllocator and ProportionalAllocator for example implementations.