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

import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;

public final class AccountLinkDataToPersist {
   private final String username;
   private final String providerId;
   private final String accountSub;
   private final String accountInfo;

   public static AccountLinkDataToPersist accountLinkDataToPersist(String username, String providerId, String accountSub) {
      return new AccountLinkDataToPersist(username, providerId, accountSub, null);
   }

   public static AccountLinkDataToPersist accountLinkDataToPersist(String username, String providerId, String accountSub, String accountInfo) {
      return new AccountLinkDataToPersist(username, providerId, accountSub, accountInfo);
   }

   private AccountLinkDataToPersist(String username, String providerId, String accountSub, String accountInfo) {
      Preconditions.checkArgument(!StringUtils.isBlank(username), "username must not be empty or null");
      this.username = username;
      Preconditions.checkArgument(!StringUtils.isBlank(providerId), "providerId must not be empty or null");
      this.providerId = providerId;
      Preconditions.checkArgument(!StringUtils.isBlank(accountSub), "accountSub must not be empty or null");
      this.accountSub = accountSub;
      this.accountInfo = accountInfo;
   }

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

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

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

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "AccountLinkDataToPersist(username="
         + this.username()
         + ", providerId="
         + this.providerId()
         + ", accountSub="
         + this.accountSub()
         + ", accountInfo="
         + this.accountInfo()
         + ")";
   }
}
