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

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

public final class MtlsCertificate {
   @NonNull
   private final CertificateX500Name subject;
   @NonNull
   private final CertificateX500Name issuer;

   @SuppressFBWarnings(justification = "generated code")
   MtlsCertificate(@NonNull CertificateX500Name subject, @NonNull CertificateX500Name issuer) {
      if (subject == null) {
         throw new NullPointerException("subject is marked non-null but is null");
      }

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

      this.subject = subject;
      this.issuer = issuer;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static MtlsCertificate.MtlsCertificateBuilder builder() {
      return new MtlsCertificate.MtlsCertificateBuilder();
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public CertificateX500Name getSubject() {
      return this.subject;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public CertificateX500Name getIssuer() {
      return this.issuer;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "MtlsCertificate(subject=" + this.getSubject() + ", issuer=" + this.getIssuer() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class MtlsCertificateBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private CertificateX500Name subject;
      @SuppressFBWarnings(justification = "generated code")
      private CertificateX500Name issuer;

      @SuppressFBWarnings(justification = "generated code")
      MtlsCertificateBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public MtlsCertificate.MtlsCertificateBuilder subject(@NonNull CertificateX500Name subject) {
         if (subject == null) {
            throw new NullPointerException("subject is marked non-null but is null");
         }

         this.subject = subject;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MtlsCertificate.MtlsCertificateBuilder issuer(@NonNull CertificateX500Name issuer) {
         if (issuer == null) {
            throw new NullPointerException("issuer is marked non-null but is null");
         }

         this.issuer = issuer;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MtlsCertificate build() {
         return new MtlsCertificate(this.subject, this.issuer);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "MtlsCertificate.MtlsCertificateBuilder(subject=" + this.subject + ", issuer=" + this.issuer + ")";
      }
   }
}
