import { UniqueEntityID } from './UniqueEntityID'; const isEntity = (v: any): v is Entity => { return v instanceof Entity; }; export abstract class Entity { protected readonly _id: UniqueEntityID; public readonly props: T; constructor(props: T, id?: UniqueEntityID) { this._id = id ? id : new UniqueEntityID(); this.props = props; } public equals(object?: Entity): boolean { if (object == null || object == undefined) { return false; } if (this === object) { return true; } if (!isEntity(object)) { return false; } return this._id.equals(object._id); } }