Mediator is a behavioral design pattern that reduces coupling between components of a program by making them communicate indirectly, through a special mediator object.
The Mediator makes it easy to modify, extend and reuse individual components because they are no longer dependent on the dozens of other classes.
Application of the pattern in Java
Usage examples: The most popular usage of the Mediator pattern in Java code is facilitating communications between GUI components of an app. The synonym of Mediator is Controller part of MVC pattern.
Here are some examples of the pattern in core Java libraries:
Example: Notes app
This example shows how to organize lots of GUI elements so that they cooperate with the help of mediator but don't depend on each other.
components: Colleague classes
mediator/Mediator.java: Defines common mediator interface
mediator/Editor.java: Concrete mediator
mediator/Note.java: A note's class
Demo.java: Initialization code
OutputDemo.png: Execution result