Created
January 22, 2019 11:00
-
-
Save hwclass/f7fa6be776e4f70a51fb8d27aae61039 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuidv4 from 'uuid/v4'; | |
class OrderId { | |
private id: string; | |
private constructor(id: string) { | |
this.id = id; | |
} | |
public static fromString(id: string): OrderId { | |
return new OrderId(id); | |
} | |
public static generateNew(): OrderId { | |
return new OrderId(uuidv4()); | |
} | |
public equals(that: OrderId): boolean { | |
return this.id === that.id; | |
} | |
public toString(): string { | |
return this.id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment