rename to core
This commit is contained in:
40
core/racing/domain/value-objects/MonthlyRecurrencePattern.ts
Normal file
40
core/racing/domain/value-objects/MonthlyRecurrencePattern.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { Weekday } from '../types/Weekday';
|
||||
import type { IValueObject } from '@gridpilot/shared/domain';
|
||||
|
||||
export interface MonthlyRecurrencePatternProps {
|
||||
ordinal: 1 | 2 | 3 | 4;
|
||||
weekday: Weekday;
|
||||
}
|
||||
|
||||
export class MonthlyRecurrencePattern implements IValueObject<MonthlyRecurrencePatternProps> {
|
||||
readonly ordinal: 1 | 2 | 3 | 4;
|
||||
readonly weekday: Weekday;
|
||||
|
||||
constructor(ordinal: 1 | 2 | 3 | 4, weekday: Weekday);
|
||||
constructor(props: MonthlyRecurrencePatternProps);
|
||||
constructor(
|
||||
ordinalOrProps: 1 | 2 | 3 | 4 | MonthlyRecurrencePatternProps,
|
||||
weekday?: Weekday,
|
||||
) {
|
||||
if (typeof ordinalOrProps === 'object') {
|
||||
this.ordinal = ordinalOrProps.ordinal;
|
||||
this.weekday = ordinalOrProps.weekday;
|
||||
} else {
|
||||
this.ordinal = ordinalOrProps;
|
||||
this.weekday = weekday as Weekday;
|
||||
}
|
||||
}
|
||||
|
||||
get props(): MonthlyRecurrencePatternProps {
|
||||
return {
|
||||
ordinal: this.ordinal,
|
||||
weekday: this.weekday,
|
||||
};
|
||||
}
|
||||
|
||||
equals(other: IValueObject<MonthlyRecurrencePatternProps>): boolean {
|
||||
const a = this.props;
|
||||
const b = other.props;
|
||||
return a.ordinal === b.ordinal && a.weekday === b.weekday;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user