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

import com.airlock.iam.base.api.domain.model.exception.ViolationException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;

public final class ExternalCrontoDeviceId {
   private final String id;

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

   public static ExternalCrontoDeviceId externalDeviceId(String externalId) {
      ViolationException.checkFalse(StringUtils.isBlank(externalId), "External Cronto device ID must not be null or blank");
      ViolationException.checkTrue(externalId.length() < 50, "External Cronto device ID is too long");
      return new ExternalCrontoDeviceId(externalId);
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof ExternalCrontoDeviceId 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 ExternalCrontoDeviceId(String id) {
      this.id = id;
   }
}
