Files
privacy.sexy/src/infrastructure/Entity/BaseEntity.ts
2020-01-01 12:31:41 +01:00

14 lines
354 B
TypeScript

import { IEntity } from './IEntity';
export abstract class BaseEntity<TId> implements IEntity<TId> {
protected constructor(public id: TId) {
if (typeof id !== 'number' && !id) {
throw new Error('Id cannot be null or empty');
}
}
public equals(otherId: TId): boolean {
return this.id === otherId;
}
}