package de.accso.flexinale.common.infrastructure.eventbus;

import de.accso.flexinale.common.api.eventbus.EventContextHolder;
import de.accso.flexinale.common.api.event.EventContext;

public final class ThreadLocalEventContextHolder implements EventContextHolder {
    private static final ThreadLocal<EventContext> CONTEXT = new ThreadLocal<>();

    @Override
    public EventContext get() {
        return CONTEXT.get();
    }

    @Override
    public void set(EventContext eventContext) {
        CONTEXT.set(eventContext);
    }

    @Override
    public void remove() {
        CONTEXT.remove();
    }

    @Override
    public boolean isEmpty() {
        return CONTEXT.get() == null;
    }
}
