Skip to content

Commit 7b9179d

Browse files
committed
Make Relationship generic
1 parent 2edcf73 commit 7b9179d

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

lib/src/document/many.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:json_api/src/document/identifier.dart';
22
import 'package:json_api/src/document/relationship.dart';
33

4-
class ToMany extends Relationship {
4+
class ToMany extends Relationship<Identifier> {
55
ToMany(Iterable<Identifier> identifiers) {
66
_ids.addAll(identifiers);
77
}

lib/src/document/one.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:json_api/src/document/identifier.dart';
22
import 'package:json_api/src/document/relationship.dart';
33

4-
class ToOne extends Relationship {
4+
class ToOne extends Relationship<Identifier> {
55
ToOne(this.identifier);
66

77
ToOne.empty() : this(null);
@@ -13,5 +13,5 @@ class ToOne extends Relationship {
1313

1414
@override
1515
Iterator<Identifier> get iterator =>
16-
identifier == null ? <Identifier>[].iterator : [identifier!].iterator;
16+
identifier == null ? super.iterator : [identifier!].iterator;
1717
}

lib/src/document/relationship.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import 'dart:collection';
22

3-
import 'package:json_api/src/document/identifier.dart';
43
import 'package:json_api/src/document/link.dart';
54

6-
class Relationship with IterableMixin<Identifier> {
5+
class Relationship<T> with IterableMixin<T> {
76
final links = <String, Link>{};
87
final meta = <String, Object?>{};
98

@@ -13,5 +12,5 @@ class Relationship with IterableMixin<Identifier> {
1312
};
1413

1514
@override
16-
Iterator<Identifier> get iterator => const <Identifier>[].iterator;
15+
Iterator<T> get iterator => <T>[].iterator;
1716
}

0 commit comments

Comments
 (0)