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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;

public final class OAuth2ClientSecret {
   private final String secret;
   private final Optional<Instant> expiresAt;

   public OAuth2ClientSecret(String secret) {
      Objects.requireNonNull(secret);
      this.secret = secret;
      this.expiresAt = Optional.empty();
   }

   public OAuth2ClientSecret(String secret, Instant expiresAt) {
      Objects.requireNonNull(secret);
      this.secret = secret;
      this.expiresAt = Optional.of(expiresAt);
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public Optional<Instant> getExpiresAt() {
      return this.expiresAt;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "OAuth2ClientSecret(secret=" + this.getSecret() + ", expiresAt=" + this.getExpiresAt() + ")";
   }
}
