Skip to content

Instantly share code, notes, and snippets.

@hwclass
Created January 22, 2019 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwclass/f7fa6be776e4f70a51fb8d27aae61039 to your computer and use it in GitHub Desktop.
Save hwclass/f7fa6be776e4f70a51fb8d27aae61039 to your computer and use it in GitHub Desktop.
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