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

import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.common.api.domain.model.e2ee.PublicE2eEncryptionInformation;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;

public final class JwePublicE2eEncryptionInformation implements PublicE2eEncryptionInformation {
   private static final String NONCE_KEY = "nonce";
   private static final String PUBLIC_KEY = "publicKey";
   private final String nonce;
   private final Map<String, Object> publicKey;

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().put("nonce", this.nonce).put("publicKey", this.publicKey).build();
   }

   public static JwePublicE2eEncryptionInformation demapify(MapifiedValues values) {
      return new JwePublicE2eEncryptionInformation(values.get("nonce"), values.getValues("publicKey").asMap());
   }

   @SuppressFBWarnings(justification = "generated code")
   public JwePublicE2eEncryptionInformation(String nonce, Map<String, Object> publicKey) {
      this.nonce = nonce;
      this.publicKey = publicKey;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public Map<String, Object> getPublicKey() {
      return this.publicKey;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "JwePublicE2eEncryptionInformation(nonce=" + this.getNonce() + ", publicKey=" + this.getPublicKey() + ")";
   }
}
