package com.airlock.iam.publicselfservice.infrastructure.transfer;

import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nonnull;
import java.util.Date;

@JsonTypeName("public-self-service.device-token.challenge")
public final class PublicSelfServiceDeviceTokenChallengeData {
   public static final String DEVICE_TOKEN_CHALLENGE_TYPE = "public-self-service.device-token.challenge";
   @Nonnull
   @Schema(description = "Alphanumeric challenge string.")
   private final String challenge;
   @Nonnull
   @Schema(description = "The challenge can be verified up to this point in time, it will no longer be accepted afterwards.")
   private final Date validTo;

   @SuppressFBWarnings(justification = "generated code")
   public PublicSelfServiceDeviceTokenChallengeData(@Nonnull String challenge, @Nonnull Date validTo) {
      if (challenge == null) {
         throw new NullPointerException("challenge is marked non-null but is null");
      }

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

      this.challenge = challenge;
      this.validTo = validTo;
   }

   @Nonnull
   @SuppressFBWarnings(justification = "generated code")
   public String getChallenge() {
      return this.challenge;
   }

   @Nonnull
   @SuppressFBWarnings(justification = "generated code")
   public Date getValidTo() {
      return this.validTo;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "PublicSelfServiceDeviceTokenChallengeData(challenge=" + this.getChallenge() + ", validTo=" + this.getValidTo() + ")";
   }
}
