package com.airlock.iam.flow.shared.domain.model.airlock2fa;

import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAShortLivedOnlineQrCodeSettings;
import com.airlock.iam.factor.domain.model.airlock2fa.activation.Airlock2FAActivationSettings;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Duration;
import java.util.Optional;
import lombok.NonNull;

public record Airlock2FAActivationStepSettings(
   @NonNull Duration enrollmentTimeout,
   @NonNull Boolean activationFlowBindingEnabled,
   @NonNull Boolean recoveryFlowBindingEnabled,
   @NonNull Duration flowBindingTokenValidity,
   @NonNull Boolean provideActivationCodeShortEnabled,
   @NonNull Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedQrCodeSettings
) {
   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAActivationStepSettings {
      if (enrollmentTimeout == null) {
         throw new NullPointerException("enrollmentTimeout is marked non-null but is null");
      }

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

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

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

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

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

   public Airlock2FAActivationSettings activationSettings() {
      return new Airlock2FAActivationSettings(
         this.enrollmentTimeout,
         this.activationFlowBindingEnabled,
         this.recoveryFlowBindingEnabled,
         this.provideActivationCodeShortEnabled,
         this.shortLivedQrCodeSettings
      );
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class Airlock2FAActivationStepSettingsBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Duration enrollmentTimeout;
      @SuppressFBWarnings(justification = "generated code")
      private Boolean activationFlowBindingEnabled;
      @SuppressFBWarnings(justification = "generated code")
      private Boolean recoveryFlowBindingEnabled;
      @SuppressFBWarnings(justification = "generated code")
      private Duration flowBindingTokenValidity;
      @SuppressFBWarnings(justification = "generated code")
      private Boolean provideActivationCodeShortEnabled;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedQrCodeSettings;

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

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder enrollmentTimeout(@NonNull Duration enrollmentTimeout) {
         if (enrollmentTimeout == null) {
            throw new NullPointerException("enrollmentTimeout is marked non-null but is null");
         }

         this.enrollmentTimeout = enrollmentTimeout;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder activationFlowBindingEnabled(
         @NonNull Boolean activationFlowBindingEnabled
      ) {
         if (activationFlowBindingEnabled == null) {
            throw new NullPointerException("activationFlowBindingEnabled is marked non-null but is null");
         }

         this.activationFlowBindingEnabled = activationFlowBindingEnabled;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder recoveryFlowBindingEnabled(@NonNull Boolean recoveryFlowBindingEnabled) {
         if (recoveryFlowBindingEnabled == null) {
            throw new NullPointerException("recoveryFlowBindingEnabled is marked non-null but is null");
         }

         this.recoveryFlowBindingEnabled = recoveryFlowBindingEnabled;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder flowBindingTokenValidity(@NonNull Duration flowBindingTokenValidity) {
         if (flowBindingTokenValidity == null) {
            throw new NullPointerException("flowBindingTokenValidity is marked non-null but is null");
         }

         this.flowBindingTokenValidity = flowBindingTokenValidity;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder provideActivationCodeShortEnabled(
         @NonNull Boolean provideActivationCodeShortEnabled
      ) {
         if (provideActivationCodeShortEnabled == null) {
            throw new NullPointerException("provideActivationCodeShortEnabled is marked non-null but is null");
         }

         this.provideActivationCodeShortEnabled = provideActivationCodeShortEnabled;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder shortLivedQrCodeSettings(
         @NonNull Optional<Airlock2FAShortLivedOnlineQrCodeSettings> shortLivedQrCodeSettings
      ) {
         if (shortLivedQrCodeSettings == null) {
            throw new NullPointerException("shortLivedQrCodeSettings is marked non-null but is null");
         }

         this.shortLivedQrCodeSettings = shortLivedQrCodeSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAActivationStepSettings build() {
         return new Airlock2FAActivationStepSettings(
            this.enrollmentTimeout,
            this.activationFlowBindingEnabled,
            this.recoveryFlowBindingEnabled,
            this.flowBindingTokenValidity,
            this.provideActivationCodeShortEnabled,
            this.shortLivedQrCodeSettings
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "Airlock2FAActivationStepSettings.Airlock2FAActivationStepSettingsBuilder(enrollmentTimeout="
            + this.enrollmentTimeout
            + ", activationFlowBindingEnabled="
            + this.activationFlowBindingEnabled
            + ", recoveryFlowBindingEnabled="
            + this.recoveryFlowBindingEnabled
            + ", flowBindingTokenValidity="
            + this.flowBindingTokenValidity
            + ", provideActivationCodeShortEnabled="
            + this.provideActivationCodeShortEnabled
            + ", shortLivedQrCodeSettings="
            + this.shortLivedQrCodeSettings
            + ")";
      }
   }
}
