All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockserver.client.MockServerEventBus Maven / Gradle / Ivy

There is a newer version: 5.14.1
Show newest version
package org.mockserver.client;

import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;

/**
 * A publish/subscribe communication channel between {@link MockServerClient} and {@link ForwardChainExpectation} instances
 *
 * @author albans
 */
final class MockServerEventBus {
    private final Multimap subscribers = LinkedListMultimap.create();

    void publish(EventType event) {
        for (SubscriberHandler subscriber : subscribers.get(event)) {
            subscriber.handle();
        }
    }

    public void subscribe(SubscriberHandler subscriber, EventType... events) {
        for (EventType event : events) {
            subscribers.put(event, subscriber);
        }
    }

    enum EventType {
        STOP, RESET
    }

    interface SubscriberHandler {
        void handle();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy