Skip to content

Commit

Permalink
refactor(model): improve == and hashCode methods (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Dec 8, 2022
1 parent 6b2c6f0 commit e1ad57e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/model/date/date_range_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ class DateRangeItem extends Item with DateRanger {

@override
bool operator ==(Object other) =>
super == other &&
other is DateRangeItem &&
startDate == other.startDate &&
endDate == other.endDate;

@override
int get hashCode => Object.hash(startDate, endDate);
int get hashCode => Object.hash(super.hashCode, startDate, endDate);

@override
int compareTo(covariant DateRangeItem other) =>
Expand Down
7 changes: 7 additions & 0 deletions lib/src/model/date/holiday.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class Holiday extends DateRangeItem {
...super.toJson(),
_JsonFields.kind: kind.index,
};

@override
bool operator ==(Object other) =>
super == other && other is Holiday && kind == other.kind;

@override
int get hashCode => Object.hash(super.hashCode, kind.hashCode);
}

enum HolidayKind { festivity, freeDisposal }

0 comments on commit e1ad57e

Please sign in to comment.