package com.airlock.iam.saml2.domain.model.sp;

import com.airlock.iam.base.api.domain.model.exception.ViolationException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;

public final class Saml2AuthnRequestId {
   private final String id;

   public static Saml2AuthnRequestId parseAuthnRequestId(@Nullable String value) {
      if (StringUtils.isBlank(value)) {
         throw new ViolationException("Authn Request ID cannot be blank!");
      } else {
         return new Saml2AuthnRequestId(value);
      }
   }

   public String value() {
      return this.id;
   }

   @Override
   public String toString() {
      return this.id;
   }

   @SuppressFBWarnings(justification = "generated code")
   private Saml2AuthnRequestId(String id) {
      this.id = id;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof Saml2AuthnRequestId other)) {
         return false;
      } else {
         Object this$id = this.id;
         Object other$id = other.id;
         return this$id == null ? other$id == null : this$id.equals(other$id);
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      Object $id = this.id;
      return result * 59 + ($id == null ? 43 : $id.hashCode());
   }
}
