Skip to content

Commit

Permalink
extract: Copyable
Browse files Browse the repository at this point in the history
wip #377
  • Loading branch information
zin- committed Aug 31, 2024
1 parent 57aab7f commit 8fdb7f1
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 76 deletions.
6 changes: 0 additions & 6 deletions lib/act_counter/act_counter_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ class ActCounterEntity extends ActCounter with Entity, HomeWidgetEntity {
ActCounterEntity(super.memId, super.name, super.actCount, super.updatedAt)
: super();

Check warning on line 7 in lib/act_counter/act_counter_entity.dart

View check run for this annotation

Codecov / codecov/patch

lib/act_counter/act_counter_entity.dart#L6-L7

Added lines #L6 - L7 were not covered by tests

// coverage:ignore-start
@override
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
'initializeMethodName': initializeMethodName,
Expand Down
6 changes: 0 additions & 6 deletions lib/framework/database/definition/database_definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ class DatabaseDefinition with Entity {
}
}

// coverage:ignore-start
@override
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
'name': name,
Expand Down
7 changes: 4 additions & 3 deletions lib/framework/repository/entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ abstract class EntityV1 {}
mixin Entity {
Map<String, dynamic> get toMap;

// FIXME EntityではなくCopyableみたいなmixinで切り出すべきかもしれない
Entity copiedWith();

@override
String toString() => "${super.toString()}: $toMap";

Check warning on line 13 in lib/framework/repository/entity.dart

View check run for this annotation

Codecov / codecov/patch

lib/framework/repository/entity.dart#L12-L13

Added lines #L12 - L13 were not covered by tests

Expand All @@ -27,6 +24,10 @@ mixin Entity {
identical(this, other) ||
(runtimeType == other.runtimeType && hashCode == other.hashCode);
}

mixin Copyable on Entity {
Entity copiedWith();
}
// memo
// - view, domain, dataのそれぞれの領域で似た内容でも型が変わることになるはず
// これをしっかりと定義したい
Expand Down
4 changes: 0 additions & 4 deletions lib/logger/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ class Log with Entity {
}

// coverage:ignore-start
@override
// TODO: implement copiedWith
Entity copiedWith() => throw UnimplementedError();

@override
// TODO: implement toMap
Map<String, dynamic> get toMap => throw UnimplementedError();
Expand Down
6 changes: 0 additions & 6 deletions lib/notifications/notification/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,4 @@ class NotificationV2 with Entity, KeyWithValue<int, Map<String, dynamic>> {
'payload': payload,

Check warning on line 23 in lib/notifications/notification/notification.dart

View check run for this annotation

Codecov / codecov/patch

lib/notifications/notification/notification.dart#L18-L23

Added lines #L18 - L23 were not covered by tests
};
}

// coverage:ignore-start
@override
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end
}
7 changes: 0 additions & 7 deletions lib/notifications/schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ abstract class Schedule with Entity {
},
);

// coverage:ignore-start
@override
// TODO: implement copiedWith
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
'id': id,

Check warning on line 39 in lib/notifications/schedule.dart

View check run for this annotation

Codecov / codecov/patch

lib/notifications/schedule.dart#L38-L39

Added lines #L38 - L39 were not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion lib/repositories/act_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:mem/databases/table_definitions/base.dart';
import 'package:mem/framework/repository/database_tuple_entity.dart';
import 'package:mem/framework/repository/entity.dart';

class ActEntity extends ActV2 with Entity {
class ActEntity extends ActV2 with Entity, Copyable {
ActEntity(super.memId, super.period);

Check warning on line 10 in lib/repositories/act_entity.dart

View check run for this annotation

Codecov / codecov/patch

lib/repositories/act_entity.dart#L10

Added line #L10 was not covered by tests

ActEntity.fromMap(Map<String, dynamic> map)
Expand Down
14 changes: 0 additions & 14 deletions lib/repositories/mem_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ class MemEntity extends Mem with Entity {
).toMap,

Check warning on line 38 in lib/repositories/mem_entity.dart

View check run for this annotation

Codecov / codecov/patch

lib/repositories/mem_entity.dart#L32-L38

Added lines #L32 - L38 were not covered by tests
);

// coverage:ignore-start
@override
Entity copiedWith({
String Function()? name,
DateTime? Function()? doneAt,
DateAndTimePeriod? Function()? period,
}) =>
MemEntity(
name == null ? this.name : name(),
doneAt == null ? this.doneAt : doneAt(),
period == null ? this.period : period(),
// coverage:ignore-end
);

@override
Map<String, dynamic> get toMap => {
defColMemsName.name: name,
Expand Down
17 changes: 0 additions & 17 deletions lib/repositories/mem_item_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ class MemItemEntity extends MemItemV2 with Entity {
: this.fromMap(
MemItemEntity(memItem.memId, memItem.type, memItem.value).toMap);

Check warning on line 22 in lib/repositories/mem_item_entity.dart

View check run for this annotation

Codecov / codecov/patch

lib/repositories/mem_item_entity.dart#L20-L22

Added lines #L20 - L22 were not covered by tests

// coverage:ignore-start
@override
Entity copiedWith() => throw UnimplementedError();

// @override
// Entity copiedWith({
// int Function()? memId,
// MemItemType Function()? type,
// dynamic Function()? value,
// }) =>
// MemItemEntity(
// memId == null ? this.memId : memId(),
// type == null ? this.type : type(),
// value == null ? this.value : value(),
// );
// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
defFkMemItemsMemId.name: memId,
Expand Down
6 changes: 0 additions & 6 deletions lib/repositories/mem_notification_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ class MemNotificationEntity extends MemNotificationV2 with Entity {
MemNotificationEntity.fromV1(MemNotification v1)
: super(v1.memId, v1.type, v1.time, v1.message);

Check warning on line 18 in lib/repositories/mem_notification_entity.dart

View check run for this annotation

Codecov / codecov/patch

lib/repositories/mem_notification_entity.dart#L17-L18

Added lines #L17 - L18 were not covered by tests

// coverage:ignore-start
@override
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
defFkMemNotificationsMemId.name: memId,
Expand Down
6 changes: 0 additions & 6 deletions lib/settings/preference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,4 @@ class PreferenceEntity<VALUE>
this.key = key;
this.value = value;
}

// coverage:ignore-start
@override
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end
}

0 comments on commit 8fdb7f1

Please sign in to comment.