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

import com.airlock.iam.common.api.domain.model.user.ProvidedUsername;
import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;

public final class AccountSub {
   private final String sub;

   public static AccountSub accountSub(ProvidedUsername accountSub) {
      return accountSub(accountSub.getValue());
   }

   public static AccountSub accountSub(String accountSub) {
      Preconditions.checkArgument(!StringUtils.isBlank(accountSub), "accountSub must not be blank");
      return new AccountSub(accountSub);
   }

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

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "AccountSub(sub=" + this.sub() + ")";
   }
}
