/**
 * Value Object: VersionCode
 *
 * Encapsulates the version code (integer build number) validation logic.
 * A version code must be a positive integer, typically auto-incremented
 * with each release build.
 */
export class VersionCode {
  private readonly value: number;

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

  static create(value: number): VersionCode {
    if (!Number.isInteger(value) || value < 1) {
      throw new Error(`Invalid version code: ${value}. Must be a positive integer.`);
    }
    return new VersionCode(value);
  }

  getValue(): number {
    return this.value;
  }

  isNewerThan(other: VersionCode): boolean {
    return this.value > other.value;
  }

  equals(other: VersionCode): boolean {
    return this.value === other.value;
  }

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