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

io.cucumber.core.runtime.SynchronizedEventBus Maven / Gradle / Ivy

The newest version!
package io.cucumber.core.runtime;

import io.cucumber.core.eventbus.EventBus;
import io.cucumber.plugin.event.EventHandler;

import java.time.Instant;
import java.util.UUID;

public final class SynchronizedEventBus implements EventBus {

    private final EventBus delegate;

    private SynchronizedEventBus(final EventBus delegate) {
        this.delegate = delegate;
    }

    public static SynchronizedEventBus synchronize(EventBus eventBus) {
        if (eventBus instanceof SynchronizedEventBus) {
            return (SynchronizedEventBus) eventBus;
        }

        return new SynchronizedEventBus(eventBus);
    }

    @Override
    public synchronized  void registerHandlerFor(Class eventType, EventHandler handler) {
        delegate.registerHandlerFor(eventType, handler);
    }

    @Override
    public synchronized  void removeHandlerFor(Class eventType, EventHandler handler) {
        delegate.removeHandlerFor(eventType, handler);
    }

    @Override
    public Instant getInstant() {
        return delegate.getInstant();
    }

    @Override
    public UUID generateId() {
        return delegate.generateId();
    }

    @Override
    public synchronized  void send(final T event) {
        delegate.send(event);
    }

    @Override
    public synchronized  void sendAll(final Iterable events) {
        delegate.sendAll(events);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy