package com.airlock.iam.common.domain.model.event;

import com.airlock.iam.base.api.domain.model.event.EventType;
import com.airlock.iam.base.api.domain.model.user.UserId;
import com.airlock.iam.base.domain.model.event.EventCreationData;
import com.airlock.iam.common.api.domain.model.cronto.CrontoDeviceId;
import com.airlock.iam.common.api.domain.model.event.CrontoDeviceActivated;
import com.airlock.iam.core.domain.model.authentication.method.KnownAuthenticationMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class CrontoDeviceActivatedImpl extends AbstractAuthenticationDeviceEvent implements CrontoDeviceActivated {
   @NonNull
   private final CrontoDeviceId deviceId;

   public CrontoDeviceActivatedImpl(EventCreationData eventCreationData, UserId userId, @NonNull CrontoDeviceId deviceId) {
      super(eventCreationData, "Cronto Device Activated", userId, KnownAuthenticationMethods.CRONTO);
      if (deviceId == null) {
         throw new NullPointerException("deviceId is marked non-null but is null");
      }

      this.deviceId = deviceId;
   }

   @Override
   public EventType type() {
      return CommonEventTypes.CRONTO_DEVICE_ACTIVATED;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   @Override
   public CrontoDeviceId deviceId() {
      return this.deviceId;
   }

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

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

         if (!super.equals(o)) {
            return false;
         }

         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")
   protected boolean canEqual(Object other) {
      return other instanceof CrontoDeviceActivatedImpl;
   }

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