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

import com.airlock.iam.core.misc.authen.result.AuthenticationFailed;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class Airlock2FADeviceChoice implements AuthenticationFailed.ChoiceToken {
   @NonNull
   private final Airlock2FAAuthDevice device;
   @NonNull
   private final String desc;
   private final boolean preSelected;

   @Override
   public String getId() {
      return this.device.getId().getId();
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAAuthDevice getDevice() {
      return this.device;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean isPreSelected() {
      return this.preSelected;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "Airlock2FADeviceChoice(device=" + this.getDevice() + ", desc=" + this.getDesc() + ", preSelected=" + this.isPreSelected() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FADeviceChoice(@NonNull Airlock2FAAuthDevice device, @NonNull String desc, boolean preSelected) {
      if (device == null) {
         throw new NullPointerException("device is marked non-null but is null");
      }

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

      this.device = device;
      this.desc = desc;
      this.preSelected = preSelected;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String getDesc() {
      return this.desc;
   }
}
