diff --git a/packages/dynamite/dynamite/lib/src/type_result/base.dart b/packages/dynamite/dynamite/lib/src/type_result/base.dart index c8b5db5f..08a006ba 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/base.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/base.dart @@ -1,5 +1,6 @@ part of 'type_result.dart'; +@immutable class TypeResultBase extends TypeResult { TypeResultBase( super.name, { diff --git a/packages/dynamite/dynamite/lib/src/type_result/enum.dart b/packages/dynamite/dynamite/lib/src/type_result/enum.dart index 34901958..7ef627a0 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/enum.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/enum.dart @@ -1,5 +1,6 @@ part of 'type_result.dart'; +@immutable class TypeResultEnum extends TypeResult { TypeResultEnum( super.name, @@ -27,4 +28,15 @@ class TypeResultEnum extends TypeResult { @override String decode(final String object) => subType.decode(object); + + @override + bool operator ==(final Object other) => + other is TypeResultEnum && + other.className == className && + other.generics == generics && + other.nullable == nullable && + other.subType == subType; + + @override + int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; } diff --git a/packages/dynamite/dynamite/lib/src/type_result/list.dart b/packages/dynamite/dynamite/lib/src/type_result/list.dart index 472ccc83..2034436e 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/list.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/list.dart @@ -1,5 +1,6 @@ part of 'type_result.dart'; +@immutable class TypeResultList extends TypeResult { TypeResultList( super.name, @@ -27,4 +28,15 @@ class TypeResultList extends TypeResult { @override TypeResultList get dartType => TypeResultList('List', subType, nullable: nullable); + + @override + bool operator ==(final Object other) => + other is TypeResultList && + other.className == className && + other.generics == generics && + other.nullable == nullable && + other.subType == subType; + + @override + int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; } diff --git a/packages/dynamite/dynamite/lib/src/type_result/map.dart b/packages/dynamite/dynamite/lib/src/type_result/map.dart index c4d576cb..0050354d 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/map.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/map.dart @@ -1,5 +1,6 @@ part of 'type_result.dart'; +@immutable class TypeResultMap extends TypeResult { TypeResultMap( super.name, @@ -14,4 +15,15 @@ class TypeResultMap extends TypeResult { @override TypeResultMap get dartType => TypeResultMap('Map', subType, nullable: nullable); + + @override + bool operator ==(final Object other) => + other is TypeResultMap && + other.className == className && + other.generics == generics && + other.nullable == nullable && + other.subType == subType; + + @override + int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode + subType.hashCode; } diff --git a/packages/dynamite/dynamite/lib/src/type_result/object.dart b/packages/dynamite/dynamite/lib/src/type_result/object.dart index 47841de5..b6f94bc3 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/object.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/object.dart @@ -2,6 +2,7 @@ part of 'type_result.dart'; const _contentString = 'ContentString'; +@immutable class TypeResultObject extends TypeResult { TypeResultObject( super.className, { diff --git a/packages/dynamite/dynamite/lib/src/type_result/type_result.dart b/packages/dynamite/dynamite/lib/src/type_result/type_result.dart index ed0d1d2e..e295f758 100644 --- a/packages/dynamite/dynamite/lib/src/type_result/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/type_result/type_result.dart @@ -7,6 +7,7 @@ part 'list.dart'; part 'map.dart'; part 'object.dart'; +@immutable abstract class TypeResult { TypeResult( this.className, { @@ -91,4 +92,11 @@ abstract class TypeResult { /// Native dart type equivalent // ignore: avoid_returning_this TypeResult get dartType => this; + + @override + bool operator ==(final Object other) => + other is TypeResult && other.className == className && other.generics == generics && other.nullable == nullable; + + @override + int get hashCode => className.hashCode + generics.hashCode + nullable.hashCode; } diff --git a/packages/dynamite/dynamite/pubspec.yaml b/packages/dynamite/dynamite/pubspec.yaml index f8781950..0a134f6b 100644 --- a/packages/dynamite/dynamite/pubspec.yaml +++ b/packages/dynamite/dynamite/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: dart_style: ^2.3.1 intersperse: ^2.0.0 json_annotation: ^4.8.1 + meta: ^1.9.1 path: ^1.8.3 dev_dependencies: