package com.airlock.iam.authentication.domain.model.airlock2fa;

import com.airlock.iam.common.api.domain.model.valueprovider.ValueProvider;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FADeviceSettings;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAFactor;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAShortLivedOnlineQrCodeSettings;
import com.airlock.iam.flow.api.domain.model.tag.Tag;
import com.airlock.iam.flow.shared.api.domain.model.message.Airlock2FAMessageProvider;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

public final class Airlock2FAAuthenticationStepSettings {
   private final Airlock2FADeviceSettings deviceSettings;
   private final boolean enforceDeviceSelection;
   private final boolean pushToAllEnabled;
   private final String frontEndBaseUrl;
   private final Map<Airlock2FAFactor, Set<Tag>> tagsOnSuccess;
   private final Set<Tag> tagsOnBypass;
   private final int maxFailedPasscodeCheckAttempts;
   private final boolean enableBypassMode;
   private final Optional<ValueProvider<String>> loginIdProvider;
   private final Optional<Airlock2FAMessageProvider> oneTouchMessageProvider;
   private final Optional<Airlock2FAMessageProvider> qrCodeMessageProvider;
   private final Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedOnlineQrCodeSettings;

   public Airlock2FAAuthenticationStepSettings(
      Airlock2FADeviceSettings deviceSettings,
      boolean enforceDeviceSelection,
      boolean pushToAllEnabled,
      String frontEndBaseUrl,
      Set<Tag> tagsOnSuccessfulOneTouch,
      Set<Tag> tagsOnSuccessfulOnlineQrCode,
      Set<Tag> tagsOnSuccessfulPasscodeCheck,
      Set<Tag> tagsOnSuccessfulOfflineQrCode,
      Set<Tag> tagsOnSuccessfulBypass,
      int maxFailedPasscodeCheckAttempts,
      boolean enableBypassMode,
      Optional<ValueProvider<String>> loginIdProvider,
      Optional<Airlock2FAMessageProvider> oneTouchMessageProvider,
      Optional<Airlock2FAMessageProvider> qrCodeMessageProvider,
      Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedOnlineQrCodeSettings
   ) {
      this.deviceSettings = deviceSettings;
      this.enforceDeviceSelection = enforceDeviceSelection;
      this.pushToAllEnabled = pushToAllEnabled;
      this.frontEndBaseUrl = frontEndBaseUrl;
      this.enableBypassMode = enableBypassMode;
      this.loginIdProvider = loginIdProvider;
      this.tagsOnSuccess = Map.ofEntries(
         Map.entry(Airlock2FAFactor.ONE_TOUCH, nullToEmptySet(tagsOnSuccessfulOneTouch)),
         Map.entry(Airlock2FAFactor.ONLINE_QR_CODE, nullToEmptySet(tagsOnSuccessfulOnlineQrCode)),
         Map.entry(Airlock2FAFactor.PASSCODE, nullToEmptySet(tagsOnSuccessfulPasscodeCheck)),
         Map.entry(Airlock2FAFactor.OFFLINE_QR_CODE, nullToEmptySet(tagsOnSuccessfulOfflineQrCode))
      );
      this.tagsOnBypass = nullToEmptySet(tagsOnSuccessfulBypass);
      this.maxFailedPasscodeCheckAttempts = maxFailedPasscodeCheckAttempts;
      this.oneTouchMessageProvider = oneTouchMessageProvider;
      this.qrCodeMessageProvider = qrCodeMessageProvider;
      this.shortLivedOnlineQrCodeSettings = shortLivedOnlineQrCodeSettings;
   }

   private static Set<Tag> nullToEmptySet(Set<Tag> set) {
      return set == null ? Set.of() : Set.copyOf(set);
   }

   @SuppressFBWarnings(justification = "generated code")
   public static Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder builder() {
      return new Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder();
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FADeviceSettings getDeviceSettings() {
      return this.deviceSettings;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public String getFrontEndBaseUrl() {
      return this.frontEndBaseUrl;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Map<Airlock2FAFactor, Set<Tag>> getTagsOnSuccess() {
      return this.tagsOnSuccess;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Set<Tag> getTagsOnBypass() {
      return this.tagsOnBypass;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public Optional<ValueProvider<String>> getLoginIdProvider() {
      return this.loginIdProvider;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<Airlock2FAMessageProvider> getOneTouchMessageProvider() {
      return this.oneTouchMessageProvider;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<Airlock2FAMessageProvider> getQrCodeMessageProvider() {
      return this.qrCodeMessageProvider;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<Airlock2FAShortLivedOnlineQrCodeSettings> getShortLivedOnlineQrCodeSettings() {
      return this.shortLivedOnlineQrCodeSettings;
   }

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

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

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

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

         Object this$deviceSettings = this.deviceSettings;
         Object other$deviceSettings = other.deviceSettings;
         if (this$deviceSettings == null ? other$deviceSettings == null : this$deviceSettings.equals(other$deviceSettings)) {
            Object this$frontEndBaseUrl = this.frontEndBaseUrl;
            Object other$frontEndBaseUrl = other.frontEndBaseUrl;
            if (this$frontEndBaseUrl == null ? other$frontEndBaseUrl == null : this$frontEndBaseUrl.equals(other$frontEndBaseUrl)) {
               Object this$tagsOnSuccess = this.tagsOnSuccess;
               Object other$tagsOnSuccess = other.tagsOnSuccess;
               if (this$tagsOnSuccess == null ? other$tagsOnSuccess == null : this$tagsOnSuccess.equals(other$tagsOnSuccess)) {
                  Object this$tagsOnBypass = this.tagsOnBypass;
                  Object other$tagsOnBypass = other.tagsOnBypass;
                  if (this$tagsOnBypass == null ? other$tagsOnBypass == null : this$tagsOnBypass.equals(other$tagsOnBypass)) {
                     Object this$loginIdProvider = this.loginIdProvider;
                     Object other$loginIdProvider = other.loginIdProvider;
                     if (this$loginIdProvider == null ? other$loginIdProvider == null : this$loginIdProvider.equals(other$loginIdProvider)) {
                        Object this$oneTouchMessageProvider = this.oneTouchMessageProvider;
                        Object other$oneTouchMessageProvider = other.oneTouchMessageProvider;
                        if (this$oneTouchMessageProvider == null
                           ? other$oneTouchMessageProvider == null
                           : this$oneTouchMessageProvider.equals(other$oneTouchMessageProvider)) {
                           Object this$qrCodeMessageProvider = this.qrCodeMessageProvider;
                           Object other$qrCodeMessageProvider = other.qrCodeMessageProvider;
                           if (this$qrCodeMessageProvider == null
                              ? other$qrCodeMessageProvider == null
                              : this$qrCodeMessageProvider.equals(other$qrCodeMessageProvider)) {
                              Object this$shortLivedOnlineQrCodeSettings = this.shortLivedOnlineQrCodeSettings;
                              Object other$shortLivedOnlineQrCodeSettings = other.shortLivedOnlineQrCodeSettings;
                              return this$shortLivedOnlineQrCodeSettings == null
                                 ? other$shortLivedOnlineQrCodeSettings == null
                                 : this$shortLivedOnlineQrCodeSettings.equals(other$shortLivedOnlineQrCodeSettings);
                           } else {
                              return false;
                           }
                        } else {
                           return false;
                        }
                     } else {
                        return false;
                     }
                  } else {
                     return false;
                  }
               } else {
                  return false;
               }
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      result = result * 59 + (this.enforceDeviceSelection ? 79 : 97);
      result = result * 59 + (this.pushToAllEnabled ? 79 : 97);
      result = result * 59 + this.maxFailedPasscodeCheckAttempts;
      result = result * 59 + (this.enableBypassMode ? 79 : 97);
      Object $deviceSettings = this.deviceSettings;
      result = result * 59 + ($deviceSettings == null ? 43 : $deviceSettings.hashCode());
      Object $frontEndBaseUrl = this.frontEndBaseUrl;
      result = result * 59 + ($frontEndBaseUrl == null ? 43 : $frontEndBaseUrl.hashCode());
      Object $tagsOnSuccess = this.tagsOnSuccess;
      result = result * 59 + ($tagsOnSuccess == null ? 43 : $tagsOnSuccess.hashCode());
      Object $tagsOnBypass = this.tagsOnBypass;
      result = result * 59 + ($tagsOnBypass == null ? 43 : $tagsOnBypass.hashCode());
      Object $loginIdProvider = this.loginIdProvider;
      result = result * 59 + ($loginIdProvider == null ? 43 : $loginIdProvider.hashCode());
      Object $oneTouchMessageProvider = this.oneTouchMessageProvider;
      result = result * 59 + ($oneTouchMessageProvider == null ? 43 : $oneTouchMessageProvider.hashCode());
      Object $qrCodeMessageProvider = this.qrCodeMessageProvider;
      result = result * 59 + ($qrCodeMessageProvider == null ? 43 : $qrCodeMessageProvider.hashCode());
      Object $shortLivedOnlineQrCodeSettings = this.shortLivedOnlineQrCodeSettings;
      return result * 59 + ($shortLivedOnlineQrCodeSettings == null ? 43 : $shortLivedOnlineQrCodeSettings.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "Airlock2FAAuthenticationStepSettings(deviceSettings="
         + this.getDeviceSettings()
         + ", enforceDeviceSelection="
         + this.isEnforceDeviceSelection()
         + ", pushToAllEnabled="
         + this.isPushToAllEnabled()
         + ", frontEndBaseUrl="
         + this.getFrontEndBaseUrl()
         + ", tagsOnSuccess="
         + this.getTagsOnSuccess()
         + ", tagsOnBypass="
         + this.getTagsOnBypass()
         + ", maxFailedPasscodeCheckAttempts="
         + this.getMaxFailedPasscodeCheckAttempts()
         + ", enableBypassMode="
         + this.isEnableBypassMode()
         + ", loginIdProvider="
         + this.getLoginIdProvider()
         + ", oneTouchMessageProvider="
         + this.getOneTouchMessageProvider()
         + ", qrCodeMessageProvider="
         + this.getQrCodeMessageProvider()
         + ", shortLivedOnlineQrCodeSettings="
         + this.getShortLivedOnlineQrCodeSettings()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class Airlock2FAAuthenticationStepSettingsBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Airlock2FADeviceSettings deviceSettings;
      @SuppressFBWarnings(justification = "generated code")
      private boolean enforceDeviceSelection;
      @SuppressFBWarnings(justification = "generated code")
      private boolean pushToAllEnabled;
      @SuppressFBWarnings(justification = "generated code")
      private String frontEndBaseUrl;
      @SuppressFBWarnings(justification = "generated code")
      private Set<Tag> tagsOnSuccessfulOneTouch;
      @SuppressFBWarnings(justification = "generated code")
      private Set<Tag> tagsOnSuccessfulOnlineQrCode;
      @SuppressFBWarnings(justification = "generated code")
      private Set<Tag> tagsOnSuccessfulPasscodeCheck;
      @SuppressFBWarnings(justification = "generated code")
      private Set<Tag> tagsOnSuccessfulOfflineQrCode;
      @SuppressFBWarnings(justification = "generated code")
      private Set<Tag> tagsOnSuccessfulBypass;
      @SuppressFBWarnings(justification = "generated code")
      private int maxFailedPasscodeCheckAttempts;
      @SuppressFBWarnings(justification = "generated code")
      private boolean enableBypassMode;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<ValueProvider<String>> loginIdProvider;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Airlock2FAMessageProvider> oneTouchMessageProvider;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Airlock2FAMessageProvider> qrCodeMessageProvider;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedOnlineQrCodeSettings;

      @SuppressFBWarnings(justification = "generated code")
      Airlock2FAAuthenticationStepSettingsBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder deviceSettings(Airlock2FADeviceSettings deviceSettings) {
         this.deviceSettings = deviceSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder enforceDeviceSelection(boolean enforceDeviceSelection) {
         this.enforceDeviceSelection = enforceDeviceSelection;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder pushToAllEnabled(boolean pushToAllEnabled) {
         this.pushToAllEnabled = pushToAllEnabled;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder frontEndBaseUrl(String frontEndBaseUrl) {
         this.frontEndBaseUrl = frontEndBaseUrl;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder tagsOnSuccessfulOneTouch(Set<Tag> tagsOnSuccessfulOneTouch) {
         this.tagsOnSuccessfulOneTouch = tagsOnSuccessfulOneTouch;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder tagsOnSuccessfulOnlineQrCode(
         Set<Tag> tagsOnSuccessfulOnlineQrCode
      ) {
         this.tagsOnSuccessfulOnlineQrCode = tagsOnSuccessfulOnlineQrCode;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder tagsOnSuccessfulPasscodeCheck(
         Set<Tag> tagsOnSuccessfulPasscodeCheck
      ) {
         this.tagsOnSuccessfulPasscodeCheck = tagsOnSuccessfulPasscodeCheck;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder tagsOnSuccessfulOfflineQrCode(
         Set<Tag> tagsOnSuccessfulOfflineQrCode
      ) {
         this.tagsOnSuccessfulOfflineQrCode = tagsOnSuccessfulOfflineQrCode;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder tagsOnSuccessfulBypass(Set<Tag> tagsOnSuccessfulBypass) {
         this.tagsOnSuccessfulBypass = tagsOnSuccessfulBypass;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder maxFailedPasscodeCheckAttempts(int maxFailedPasscodeCheckAttempts) {
         this.maxFailedPasscodeCheckAttempts = maxFailedPasscodeCheckAttempts;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder enableBypassMode(boolean enableBypassMode) {
         this.enableBypassMode = enableBypassMode;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder loginIdProvider(Optional<ValueProvider<String>> loginIdProvider) {
         this.loginIdProvider = loginIdProvider;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder oneTouchMessageProvider(
         Optional<Airlock2FAMessageProvider> oneTouchMessageProvider
      ) {
         this.oneTouchMessageProvider = oneTouchMessageProvider;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder qrCodeMessageProvider(
         Optional<Airlock2FAMessageProvider> qrCodeMessageProvider
      ) {
         this.qrCodeMessageProvider = qrCodeMessageProvider;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder shortLivedOnlineQrCodeSettings(
         Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedOnlineQrCodeSettings
      ) {
         this.shortLivedOnlineQrCodeSettings = shortLivedOnlineQrCodeSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationStepSettings build() {
         return new Airlock2FAAuthenticationStepSettings(
            this.deviceSettings,
            this.enforceDeviceSelection,
            this.pushToAllEnabled,
            this.frontEndBaseUrl,
            this.tagsOnSuccessfulOneTouch,
            this.tagsOnSuccessfulOnlineQrCode,
            this.tagsOnSuccessfulPasscodeCheck,
            this.tagsOnSuccessfulOfflineQrCode,
            this.tagsOnSuccessfulBypass,
            this.maxFailedPasscodeCheckAttempts,
            this.enableBypassMode,
            this.loginIdProvider,
            this.oneTouchMessageProvider,
            this.qrCodeMessageProvider,
            this.shortLivedOnlineQrCodeSettings
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "Airlock2FAAuthenticationStepSettings.Airlock2FAAuthenticationStepSettingsBuilder(deviceSettings="
            + this.deviceSettings
            + ", enforceDeviceSelection="
            + this.enforceDeviceSelection
            + ", pushToAllEnabled="
            + this.pushToAllEnabled
            + ", frontEndBaseUrl="
            + this.frontEndBaseUrl
            + ", tagsOnSuccessfulOneTouch="
            + this.tagsOnSuccessfulOneTouch
            + ", tagsOnSuccessfulOnlineQrCode="
            + this.tagsOnSuccessfulOnlineQrCode
            + ", tagsOnSuccessfulPasscodeCheck="
            + this.tagsOnSuccessfulPasscodeCheck
            + ", tagsOnSuccessfulOfflineQrCode="
            + this.tagsOnSuccessfulOfflineQrCode
            + ", tagsOnSuccessfulBypass="
            + this.tagsOnSuccessfulBypass
            + ", maxFailedPasscodeCheckAttempts="
            + this.maxFailedPasscodeCheckAttempts
            + ", enableBypassMode="
            + this.enableBypassMode
            + ", loginIdProvider="
            + this.loginIdProvider
            + ", oneTouchMessageProvider="
            + this.oneTouchMessageProvider
            + ", qrCodeMessageProvider="
            + this.qrCodeMessageProvider
            + ", shortLivedOnlineQrCodeSettings="
            + this.shortLivedOnlineQrCodeSettings
            + ")";
      }
   }
}
