Skip to content

Commit

Permalink
refactor: migrate from hash* to Object.hash* (#8797)
Browse files Browse the repository at this point in the history
  • Loading branch information
werainkhatri committed Jun 1, 2022
1 parent 479afe4 commit 3dfc099
Show file tree
Hide file tree
Showing 24 changed files with 24 additions and 37 deletions.
Expand Up @@ -11,7 +11,6 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'
show FirebasePluginPlatform;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';

export 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart'
Expand Down
Expand Up @@ -141,7 +141,7 @@ class _JsonCollectionReference extends _JsonQuery
other.path == path;

@override
int get hashCode => hashValues(firestore, path);
int get hashCode => Object.hash(firestore, path);

@override
String toString() => 'CollectionReference<Map<String, dynamic>>($path)';
Expand Down Expand Up @@ -219,7 +219,7 @@ class _WithConverterCollectionReference<T extends Object?>
other._toFirestore == _toFirestore;

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
runtimeType,
_originalCollectionReferenceQuery,
_fromFirestore,
Expand Down
Expand Up @@ -190,7 +190,7 @@ class _JsonDocumentReference
other.path == path;

@override
int get hashCode => hashValues(firestore, path);
int get hashCode => Object.hash(firestore, path);

@override
String toString() => 'DocumentReference<Map<String, dynamic>>($path)';
Expand Down Expand Up @@ -307,7 +307,7 @@ class _WithConverterDocumentReference<T extends Object?>
other._toFirestore == _toFirestore;

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
runtimeType,
_originalDocumentReference,
_fromFirestore,
Expand Down
Expand Up @@ -284,7 +284,7 @@ class FirebaseFirestore extends FirebasePluginPlatform {

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => hashValues(app.name, app.options);
int get hashCode => Object.hash(app.name, app.options);

@override
String toString() => '$FirebaseFirestore(app: ${app.name})';
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud_firestore/cloud_firestore/lib/src/query.dart
Expand Up @@ -807,7 +807,7 @@ class _JsonQuery implements Query<Map<String, dynamic>> {
}

@override
int get hashCode => hashValues(runtimeType, firestore, _delegate);
int get hashCode => Object.hash(runtimeType, firestore, _delegate);
}

class _WithConverterQuery<T extends Object?> implements Query<T> {
Expand Down Expand Up @@ -969,5 +969,5 @@ class _WithConverterQuery<T extends Object?> implements Query<T> {

@override
int get hashCode =>
hashValues(runtimeType, _fromFirestore, _toFirestore, _originalQuery);
Object.hash(runtimeType, _fromFirestore, _toFirestore, _originalQuery);
}
Expand Up @@ -4,7 +4,6 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:typed_data';
import 'dart:ui' show hashList;

import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart' show immutable;
Expand All @@ -24,5 +23,5 @@ class Blob {
const DeepCollectionEquality().equals(other.bytes, bytes);

@override
int get hashCode => hashList(bytes);
int get hashCode => Object.hashAll(bytes);
}
Expand Up @@ -56,7 +56,7 @@ class FieldPath {
const ListEquality().equals(other.components, components);

@override
int get hashCode => hashList(components);
int get hashCode => Object.hashAll(components);

@override
String toString() => 'FieldPath($components)';
Expand Down
Expand Up @@ -3,8 +3,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:ui' show hashValues;

import 'package:flutter/foundation.dart';

/// Represents a geographical point by its longitude and latitude
Expand All @@ -25,5 +23,5 @@ class GeoPoint {
other.longitude == longitude;

@override
int get hashCode => hashValues(latitude, longitude);
int get hashCode => Object.hash(latitude, longitude);
}
Expand Up @@ -3,7 +3,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:ui' show hashValues;
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart' show immutable;

Expand Down Expand Up @@ -50,5 +49,5 @@ class MethodChannelFieldValue {
const DeepCollectionEquality().equals(other.value, value);

@override
int get hashCode => hashValues(type, value);
int get hashCode => Object.hash(type, value);
}
Expand Up @@ -9,7 +9,6 @@ import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_inte
import 'package:cloud_firestore_platform_interface/src/internal/pointer.dart';
import 'package:collection/collection.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import 'method_channel_firestore.dart';
import 'method_channel_query_snapshot.dart';
Expand Down Expand Up @@ -224,7 +223,7 @@ class MethodChannelQuery extends QueryPlatform {
}

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
runtimeType,
firestore,
_pointer,
Expand Down
Expand Up @@ -77,7 +77,7 @@ class Settings {
other.cacheSizeBytes == cacheSizeBytes;

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
runtimeType,
persistenceEnabled,
host,
Expand Down
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:ui';

import 'package:flutter/foundation.dart';

const int _kThousand = 1000;
Expand Down Expand Up @@ -85,7 +83,7 @@ class Timestamp implements Comparable<Timestamp> {
}

@override
int get hashCode => hashValues(seconds, nanoseconds);
int get hashCode => Object.hash(seconds, nanoseconds);

@override
bool operator ==(Object other) =>
Expand Down
Expand Up @@ -6,7 +6,6 @@
import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:collection/collection.dart';
import 'package:cloud_firestore_web/src/utils/encode_utility.dart';
import 'package:flutter/material.dart';

import 'internals.dart';
import 'interop/firestore.dart' as firestore_interop;
Expand Down Expand Up @@ -42,7 +41,7 @@ class QueryWeb extends QueryPlatform {
}

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
runtimeType,
firestore,
_path,
Expand Down
Expand Up @@ -65,7 +65,7 @@ class FirebaseApp {

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => hashValues(name, options);
int get hashCode => Object.hash(name, options);

@override
String toString() => '$FirebaseApp($name)';
Expand Down
Expand Up @@ -9,7 +9,6 @@ library firebase_core_platform_interface;
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' show hashValues;
import 'package:flutter/services.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:collection/collection.dart';
Expand Down
Expand Up @@ -63,7 +63,7 @@ class FirebaseException implements Exception {
}

@override
int get hashCode => hashValues(plugin, code, message);
int get hashCode => Object.hash(plugin, code, message);

@override
String toString() {
Expand Down
Expand Up @@ -69,7 +69,7 @@ class FirebaseAppPlatform extends PlatformInterface {

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => hashValues(name, options);
int get hashCode => Object.hash(name, options);

@override
String toString() => '$FirebaseAppPlatform($name)';
Expand Down
Expand Up @@ -16,7 +16,6 @@ import 'package:firebase_core_platform_interface/firebase_core_platform_interfac
show FirebasePluginPlatform;
import 'package:firebase_storage_platform_interface/firebase_storage_platform_interface.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

import 'src/utils.dart';

Expand Down
Expand Up @@ -209,7 +209,7 @@ class FirebaseStorage extends FirebasePluginPlatform {
other.bucket == bucket;

@override
int get hashCode => hashValues(app.name, bucket);
int get hashCode => Object.hash(app.name, bucket);

@override
String toString() => '$FirebaseStorage(app: ${app.name}, bucket: $bucket)';
Expand Down
Expand Up @@ -202,7 +202,7 @@ class Reference {
other.storage == storage;

@override
int get hashCode => hashValues(storage, fullPath);
int get hashCode => Object.hash(storage, fullPath);

@override
String toString() =>
Expand Down
Expand Up @@ -46,7 +46,7 @@ class TaskSnapshot {
other is TaskSnapshot && other.ref == ref && other.storage == storage;

@override
int get hashCode => hashValues(storage, ref);
int get hashCode => Object.hash(storage, ref);

@override
String toString() => '$TaskSnapshot(ref: $ref, state: $state)';
Expand Down
Expand Up @@ -6,7 +6,6 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:firebase_storage_platform_interface/firebase_storage_platform_interface.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

Expand Down Expand Up @@ -228,7 +227,7 @@ void main() {
test('returns the correct value', () {
expect(
storage.hashCode,
hashValues(app.name, kBucket.replaceFirst('gs://', '')),
Object.hash(app.name, kBucket.replaceFirst('gs://', '')),
);
});
});
Expand Down
Expand Up @@ -10,7 +10,6 @@ import 'dart:typed_data';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:firebase_storage_platform_interface/firebase_storage_platform_interface.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

Expand Down Expand Up @@ -310,7 +309,7 @@ Future<void> main() async {
});

test('hashCode()', () {
expect(testRef.hashCode, hashValues(storage, testFullPath));
expect(testRef.hashCode, Object.hash(storage, testFullPath));
});

test('toString()', () {
Expand Down
Expand Up @@ -10,7 +10,7 @@ class ProviderKey {
ProviderKey(this.auth, this.providerType);

@override
int get hashCode => hashValues(auth, providerType);
int get hashCode => Object.hash(auth, providerType);

@override
bool operator ==(Object other) {
Expand Down

0 comments on commit 3dfc099

Please sign in to comment.