The definition of “mediator” is, a person who attempts to make people involved in a conflict come to an agreement; a go-between.
Problem

Solution

The Mediator pattern suggests that all direct communication should be ceased between the components.
Instead, these components must collaborate indirectly, by calling a special mediator object that redirects the calls to appropriate components. As a result, the components depend only on a single mediator class instead of being coupled to dozens of their colleagues.
How to Regulate a set of Colleagues.
This article will show you how to act like a traffic controller to coordinate between colleagues.
The key here is to make the Commander/Mediator to contain a flag, and each colleagues only execute something based on the flag within Commander/Mediator.
- Mediator (Commander): Is an interface that declares methods for communicating with Colleague objects.
- ConcreteMediator (CommanderImpl): Implements Mediator. This class maintains and coordinates Colleague objects.
- Colleague(BroadCastA, BroadCastB and other BroadCastN…): Communicates with its Mediator when their state changes and responds to requests from the Mediator.