import { DomainException } from '../../shared/exceptions/domain.exception';

export class InstallId {
  private readonly _value: string;

  private constructor(value: string) {
    this._value = value;
  }

  get value(): string {
    return this._value;
  }

  static fromString(value: string): InstallId {
    if (!value || value.trim() === '') {
      throw new DomainException('InstallId cannot be empty');
    }
    if (value.length < 8 || value.length > 128) {
      throw new DomainException('InstallId length must be between 8 and 128 characters');
    }
    return new InstallId(value.trim());
  }

  equals(other: InstallId): boolean {
    return this._value === other._value;
  }

  toString(): string {
    return this._value;
  }
}
