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

import com.airlock.iam.airlock2fa.api.domain.model.Airlock2FADeviceId;
import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.flow.api.domain.model.session.SingleFlowScopedFlowAttribute;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public final class Airlock2FACurrentDeviceIdFlowAttribute implements SingleFlowScopedFlowAttribute<Airlock2FACurrentDeviceIdFlowAttribute> {
   private static final String DEVICE_ID_KEY = "id";
   private final Airlock2FADeviceId deviceId;

   public static Airlock2FACurrentDeviceIdFlowAttribute airlock2FACurrentDeviceIdFlowAttribute(Airlock2FADeviceId deviceId) {
      return new Airlock2FACurrentDeviceIdFlowAttribute(deviceId);
   }

   public Airlock2FACurrentDeviceIdFlowAttribute mergeWith(Airlock2FACurrentDeviceIdFlowAttribute newAttribute) {
      return newAttribute;
   }

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().put("id", this.deviceId.id()).build();
   }

   public static Airlock2FACurrentDeviceIdFlowAttribute demapify(MapifiedValues values) {
      return new Airlock2FACurrentDeviceIdFlowAttribute(Airlock2FADeviceId.airlock2FADeviceId(values.get("id")));
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FADeviceId getDeviceId() {
      return this.deviceId;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "Airlock2FACurrentDeviceIdFlowAttribute(deviceId=" + this.getDeviceId() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   private Airlock2FACurrentDeviceIdFlowAttribute(Airlock2FADeviceId deviceId) {
      this.deviceId = deviceId;
   }
}
