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

import com.airlock.iam.base.misc.log.LogUtil;
import com.airlock.iam.saml2.domain.model.Saml2RelayState;
import com.airlock.iam.saml2.domain.model.sp.Saml2SpEntityId;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;

public final class Saml2IdpInitiatedSsoContinuationParameters {
   private final Saml2SpEntityId spEntityId;
   private final Saml2IdpMetaAlias idpMetaAlias;
   private final Optional<Saml2RelayState> relayState;

   @Override
   public String toString() {
      return String.format(
         "SAML 2.0 SSO Parameters [SP: %s, IDP Meta Alias: %s, Relay State: %s]",
         LogUtil.logSafeQuote(this.spEntityId),
         LogUtil.logSafeQuote(this.idpMetaAlias),
         LogUtil.logSafeQuote(this.relayState.map(Saml2RelayState::value).orElse("none"))
      );
   }

   @SuppressFBWarnings(justification = "generated code")
   public Saml2IdpInitiatedSsoContinuationParameters(Saml2SpEntityId spEntityId, Saml2IdpMetaAlias idpMetaAlias, Optional<Saml2RelayState> relayState) {
      this.spEntityId = spEntityId;
      this.idpMetaAlias = idpMetaAlias;
      this.relayState = relayState;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Saml2SpEntityId getSpEntityId() {
      return this.spEntityId;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Saml2IdpMetaAlias getIdpMetaAlias() {
      return this.idpMetaAlias;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<Saml2RelayState> getRelayState() {
      return this.relayState;
   }

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

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