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

import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.factor.domain.model.airlock2fa.qrcode.Airlock2FAQrCodeImage;
import com.airlock.iam.flow.api.domain.model.step.StepResultData;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class Airlock2FAOfflineQrCodeChallenge implements StepResultData {
   private static final String IMAGE_KEY = "image";
   @NonNull
   private final Airlock2FAQrCodeImage challengeImage;

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().put("image", this.challengeImage.getEncodedImage()).build();
   }

   public static Airlock2FAOfflineQrCodeChallenge demapify(MapifiedValues values) {
      return new Airlock2FAOfflineQrCodeChallenge(new Airlock2FAQrCodeImage(values.get("image")));
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAOfflineQrCodeChallenge(@NonNull Airlock2FAQrCodeImage challengeImage) {
      if (challengeImage == null) {
         throw new NullPointerException("challengeImage is marked non-null but is null");
      }

      this.challengeImage = challengeImage;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAQrCodeImage getChallengeImage() {
      return this.challengeImage;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "Airlock2FAOfflineQrCodeChallenge(challengeImage=" + this.getChallengeImage() + ")";
   }
}
