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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;

public final class ProviderId {
   public static final String PROVIDERID_PATTERN = "[a-zA-Z0-9]+";
   private static final Pattern ALLOWED_PROVIDERID_CHARACTERS_PATTERN = Pattern.compile("[a-zA-Z0-9]+");
   private final String id;

   public static ProviderId providerId(String id) {
      return new ProviderId(id);
   }

   public static boolean isValid(String providerId) {
      return StringUtils.isNotBlank(providerId) && ALLOWED_PROVIDERID_CHARACTERS_PATTERN.matcher(providerId).matches();
   }

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

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

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

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

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