package com.airlock.iam.common.domain.service.sso;

import java.util.List;
import lombok.NonNull;

public record ContextDataEntry(String key, Object value) {
   public static ContextDataEntry contextData(@NonNull String key, @NonNull String value) {
      if (key == null) {
         throw new NullPointerException("key is marked non-null but is null");
      } else if (value == null) {
         throw new NullPointerException("value is marked non-null but is null");
      } else {
         return new ContextDataEntry(key, value);
      }
   }

   public static ContextDataEntry contextData(@NonNull String key, @NonNull List<String> values) {
      if (key == null) {
         throw new NullPointerException("key is marked non-null but is null");
      } else if (values == null) {
         throw new NullPointerException("values is marked non-null but is null");
      } else {
         return new ContextDataEntry(key, values);
      }
   }

   public static ContextDataEntry contextData(@NonNull String key, String... values) {
      if (key == null) {
         throw new NullPointerException("key is marked non-null but is null");
      } else {
         return contextData(key, List.of(values));
      }
   }
}
