package com.airlock.iam.authentication.domain.model.rememberme;

import com.airlock.iam.common.api.domain.model.binary.ByteSequence;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class RememberMeJspTokenHmacKey {
   private final ByteSequence key;

   private RememberMeJspTokenHmacKey(@NonNull ByteSequence key) {
      if (key == null) {
         throw new NullPointerException("key is marked non-null but is null");
      }

      this.key = key;
   }

   public static RememberMeJspTokenHmacKey rememberMeHmacKey(byte[] key) {
      return new RememberMeJspTokenHmacKey(ByteSequence.byteSequence(key));
   }

   public byte[] bytes() {
      return this.key.bytes();
   }

   @Override
   public String toString() {
      return "*****";
   }

   @SuppressFBWarnings(justification = "generated code")
   public ByteSequence getKey() {
      return this.key;
   }

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

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