package com.airlock.iam.oauth2.domain.model.remoteconsent;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Serializable;

public final class RemoteConsentSessionNonce implements Serializable {
   private String nonce;

   public RemoteConsentSessionNonce(RemoteConsentRequestNonce requestNonce) {
      this.nonce = requestNonce.nonce();
   }

   public boolean matches(RemoteConsentResponseNonce nonceToVerify) {
      if (this.nonce != null) {
         boolean result = this.nonce.equals(nonceToVerify.nonce());
         this.nonce = null;
         return result;
      } else {
         return false;
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   public RemoteConsentSessionNonce(String nonce) {
      this.nonce = nonce;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getNonce() {
      return this.nonce;
   }

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

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