package com.airlock.iam.publicselfservice.domain.model.step;

import com.airlock.iam.common.api.domain.model.authmethod.AuthenticationMethod;
import com.airlock.iam.core.application.configuration.contextdata.StringContextDataItemNameConfig;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Duration;
import lombok.NonNull;

public final class EmailIdentityVerificationStepSettings {
   @NonNull
   private final StringContextDataItemNameConfig emailItem;
   private final int maxFailedAttempts;
   @NonNull
   private final Duration otpValidity;
   private final boolean otpCaseSensitive;
   @NonNull
   private final AuthenticationMethod authMethodId;

   @SuppressFBWarnings(justification = "generated code")
   public EmailIdentityVerificationStepSettings(
      @NonNull StringContextDataItemNameConfig emailItem,
      int maxFailedAttempts,
      @NonNull Duration otpValidity,
      boolean otpCaseSensitive,
      @NonNull AuthenticationMethod authMethodId
   ) {
      if (emailItem == null) {
         throw new NullPointerException("emailItem is marked non-null but is null");
      }

      if (otpValidity == null) {
         throw new NullPointerException("otpValidity is marked non-null but is null");
      }

      if (authMethodId == null) {
         throw new NullPointerException("authMethodId is marked non-null but is null");
      }

      this.emailItem = emailItem;
      this.maxFailedAttempts = maxFailedAttempts;
      this.otpValidity = otpValidity;
      this.otpCaseSensitive = otpCaseSensitive;
      this.authMethodId = authMethodId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public StringContextDataItemNameConfig getEmailItem() {
      return this.emailItem;
   }

   @SuppressFBWarnings(justification = "generated code")
   public int getMaxFailedAttempts() {
      return this.maxFailedAttempts;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Duration getOtpValidity() {
      return this.otpValidity;
   }

   @SuppressFBWarnings(justification = "generated code")
   public boolean isOtpCaseSensitive() {
      return this.otpCaseSensitive;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public AuthenticationMethod getAuthMethodId() {
      return this.authMethodId;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof EmailIdentityVerificationStepSettings other)) {
         return false;
      } else {
         if (this.maxFailedAttempts != other.maxFailedAttempts) {
            return false;
         }

         if (this.otpCaseSensitive != other.otpCaseSensitive) {
            return false;
         }

         Object this$emailItem = this.emailItem;
         Object other$emailItem = other.emailItem;
         if (this$emailItem == null ? other$emailItem == null : this$emailItem.equals(other$emailItem)) {
            Object this$otpValidity = this.otpValidity;
            Object other$otpValidity = other.otpValidity;
            if (this$otpValidity == null ? other$otpValidity == null : this$otpValidity.equals(other$otpValidity)) {
               Object this$authMethodId = this.authMethodId;
               Object other$authMethodId = other.authMethodId;
               return this$authMethodId == null ? other$authMethodId == null : this$authMethodId.equals(other$authMethodId);
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      result = result * 59 + this.maxFailedAttempts;
      result = result * 59 + (this.otpCaseSensitive ? 79 : 97);
      Object $emailItem = this.emailItem;
      result = result * 59 + ($emailItem == null ? 43 : $emailItem.hashCode());
      Object $otpValidity = this.otpValidity;
      result = result * 59 + ($otpValidity == null ? 43 : $otpValidity.hashCode());
      Object $authMethodId = this.authMethodId;
      return result * 59 + ($authMethodId == null ? 43 : $authMethodId.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "EmailIdentityVerificationStepSettings(emailItem="
         + this.getEmailItem()
         + ", maxFailedAttempts="
         + this.getMaxFailedAttempts()
         + ", otpValidity="
         + this.getOtpValidity()
         + ", otpCaseSensitive="
         + this.isOtpCaseSensitive()
         + ", authMethodId="
         + this.getAuthMethodId()
         + ")";
   }
}
