package p.studio.workspaces.framework;

import p.studio.utilities.events.EventSubscription;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public final class StudioSubscriptionBag {
    private final List<EventSubscription> subscriptions = new ArrayList<>();

    public void add(EventSubscription subscription) {
        subscriptions.add(Objects.requireNonNull(subscription, "subscription"));
    }

    public void clear() {
        subscriptions.forEach(EventSubscription::unsubscribe);
        subscriptions.clear();
    }

    public boolean isEmpty() {
        return subscriptions.isEmpty();
    }
}
