package com.airlock.iam.oauth2.domain.service.codegrant;

import com.airlock.iam.oauth2.domain.model.token.OpenIDConnectIDToken;
import com.airlock.iam.oauth2.domain.model.token.RawOAuth2TokenWithHash;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class AuthorizationCodeIDToken {
   @NonNull
   private final RawOAuth2TokenWithHash authorizationCode;
   @NonNull
   private final OpenIDConnectIDToken idToken;

   @SuppressFBWarnings(justification = "generated code")
   public AuthorizationCodeIDToken(@NonNull RawOAuth2TokenWithHash authorizationCode, @NonNull OpenIDConnectIDToken idToken) {
      if (authorizationCode == null) {
         throw new NullPointerException("authorizationCode is marked non-null but is null");
      }

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

      this.authorizationCode = authorizationCode;
      this.idToken = idToken;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public RawOAuth2TokenWithHash getAuthorizationCode() {
      return this.authorizationCode;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OpenIDConnectIDToken getIdToken() {
      return this.idToken;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "AuthorizationCodeIDToken(authorizationCode=" + this.getAuthorizationCode() + ", idToken=" + this.getIdToken() + ")";
   }
}
