package de.cannamanage.domain.entity;

import java.util.UUID;

/**
 * ThreadLocal holder for the current tenant's UUID.
 * Must be set at the start of each request (e.g., via a servlet filter or Spring interceptor)
 * and cleared at the end to prevent tenant leakage.
 */
public final class TenantContext {

    private static final ThreadLocal<UUID> CURRENT_TENANT = new ThreadLocal<>();

    private TenantContext() {}

    public static UUID getCurrentTenant() {
        return CURRENT_TENANT.get();
    }

    public static void setCurrentTenant(UUID tenantId) {
        CURRENT_TENANT.set(tenantId);
    }

    public static void clear() {
        CURRENT_TENANT.remove();
    }
}
