Base on my understand a mediator is a central authority that varies the interaction between objects in the same group. So can I classify the code below as a mediator?
package com.mediator;
public class BaseMediator {
public void store(){
System.out.println("store");
}
public void retrieve(){
System.out.println("retrieve");
}
}
package com.mediator;
public class Consumer extends BaseMediator {
private BaseMediator b;
public Consumer(BaseMediator b){
this.b = b;
}
}
package com.mediator;
public class Producer extends BaseMediator {
private BaseMediator b;
public Producer(BaseMediator b){
this.b = b;
}
}
package com.mediator;
public class Driver {
public static void main(String[] args){
BaseMediator mediator = new BaseMediator();
Producer p = new Producer(mediator);
Consumer c = new Consumer(mediator);
p.store();
c.retrieve();
}
}
Your help is kindly appeciated.
Thank You.