package com.bonus.canteen.core.common.utils;

public final class TenantContextHolder {
   private static final ThreadLocal<Long> THREAD_LOCAL_TENANT = new InheritableThreadLocal();

   public static Long getTenantId() {
      return (Long)THREAD_LOCAL_TENANT.get();
   }

   public static void setTenantId(Long tenantId) {
      THREAD_LOCAL_TENANT.set(tenantId);
   }

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

   private TenantContextHolder() {
      throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
   }
}
