export class DeviceId { constructor( public readonly manufacturer: string, public readonly oui: string, public readonly productClass: string, public readonly serialNumber: string ) { this.validate() } private validate(): void { if (!this.manufacturer?.trim()) { throw new Error('Manufacturer is required') } if (!this.serialNumber?.trim()) { throw new Error('Serial number is required') } } public toIdentifier(): string { return `${this.manufacturer}-${this.oui}-${this.productClass}-${this.serialNumber}` } public equals(other: DeviceId): boolean { return ( this.manufacturer === other.manufacturer && this.oui === other.oui && this.productClass === other.productClass && this.serialNumber === other.serialNumber ) } public static fromInform(informData: any): DeviceId { return new DeviceId( String(informData?.Manufacturer ?? ''), String(informData?.OUI ?? ''), String(informData?.ProductClass ?? ''), String(informData?.SerialNumber ?? '') ) } public toString(): string { return this.toIdentifier() } }