30 lines
701 B
TypeScript
30 lines
701 B
TypeScript
import { Entity } from '@core/shared/domain/Entity';
|
|
import { GameId } from './GameId';
|
|
import { GameName } from './GameName';
|
|
|
|
export class Game extends Entity<GameId> {
|
|
readonly name: GameName;
|
|
|
|
private constructor(props: { id: GameId; name: GameName }) {
|
|
super(props.id);
|
|
|
|
this.name = props.name;
|
|
}
|
|
|
|
static create(props: { id: string; name: string }): Game {
|
|
const id = GameId.create(props.id);
|
|
const name = GameName.create(props.name);
|
|
|
|
return new Game({
|
|
id,
|
|
name,
|
|
});
|
|
}
|
|
|
|
static rehydrate(props: { id: string; name: string }): Game {
|
|
return new Game({
|
|
id: GameId.create(props.id),
|
|
name: GameName.create(props.name),
|
|
});
|
|
}
|
|
} |