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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.regex.Pattern;
import lombok.NonNull;

public final class OAuth2ClientId {
   public static final String ALLOWED_CLIENTID_CHARACTERS_REGEX = "[a-zA-Z0-9-_.]+";
   public static final Pattern ALLOWED_CLIENTID_CHARACTERS_PATTERN = Pattern.compile("[a-zA-Z0-9-_.]+");
   @NonNull
   private final String id;

   public static OAuth2ClientId oAuth2ClientId(String id) {
      return new OAuth2ClientId(id);
   }

   @Override
   public String toString() {
      return this.id;
   }

   public boolean hasId(String otherId) {
      return this.id.equals(otherId);
   }

   @NonNull
   @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 OAuth2ClientId 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")
   private OAuth2ClientId(@NonNull String id) {
      if (id == null) {
         throw new NullPointerException("id is marked non-null but is null");
      }

      this.id = id;
   }
}
