Skip to content

Commit 7c505db

Browse files
authored
fix: Improve conformance to Hashable and Equatable (#198)
1 parent 6798d05 commit 7c505db

16 files changed

+251
-16
lines changed

Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"kind" : "remoteSourceControl",
2424
"location" : "https://github.com/netreconlab/Parse-Swift.git",
2525
"state" : {
26-
"revision" : "10ec67c29050cc7e9d69bc59dda787ec5a145e75",
27-
"version" : "5.10.0"
26+
"revision" : "f13ad6b7ecee396e6fecb2685d3e171823ff6c3d",
27+
"version" : "5.10.3"
2828
}
2929
},
3030
{

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
.package(url: "https://github.com/cbaker6/CareKit.git",
1515
.upToNextMajor(from: "3.0.0-beta.14")),
1616
.package(url: "https://github.com/netreconlab/Parse-Swift.git",
17-
.upToNextMajor(from: "5.10.0"))
17+
.upToNextMajor(from: "5.10.3"))
1818
],
1919
targets: [
2020
.target(

ParseCareKit.xcodeproj/project.pbxproj

+37-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
705DC9292526A55E0035BBE3 /* EncodingCareKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7098A7782524E92900DDF53D /* EncodingCareKitTests.swift */; };
1818
705DC92B2526A5610035BBE3 /* MockURLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7098A7762524E92900DDF53D /* MockURLProtocol.swift */; };
1919
705DC92D2526A5650035BBE3 /* MockURLResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7098A7772524E92900DDF53D /* MockURLResponse.swift */; };
20+
707DC1D22C4345B100FC1DFD /* OCKSemanticVersion+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1D12C4345B100FC1DFD /* OCKSemanticVersion+Parse.swift */; };
21+
707DC1D42C4346D000FC1DFD /* OCKNote+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1D32C4346D000FC1DFD /* OCKNote+Parse.swift */; };
22+
707DC1D62C4347B000FC1DFD /* OCKSchedule+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1D52C4347B000FC1DFD /* OCKSchedule+Parse.swift */; };
23+
707DC1D82C43486900FC1DFD /* OCKScheduleElement+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1D72C43486900FC1DFD /* OCKScheduleElement+Parse.swift */; };
24+
707DC1DA2C43492300FC1DFD /* OCKOutcomeValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1D92C43492300FC1DFD /* OCKOutcomeValue.swift */; };
25+
707DC1DC2C434B1E00FC1DFD /* OCKBiologicalSex+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1DB2C434B1E00FC1DFD /* OCKBiologicalSex+Parse.swift */; };
26+
707DC1DE2C434B8700FC1DFD /* OCKPostalAddress+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1DD2C434B8700FC1DFD /* OCKPostalAddress+Parse.swift */; };
27+
707DC1E02C434BD700FC1DFD /* OCKContactCategory+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1DF2C434BD700FC1DFD /* OCKContactCategory+Parse.swift */; };
28+
707DC1E22C434C1A00FC1DFD /* OCKLabeledValue+Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707DC1E12C434C1A00FC1DFD /* OCKLabeledValue+Parse.swift */; };
2029
7085DDAD26CDA2980033B977 /* Documentation.docc in Sources */ = {isa = PBXBuildFile; fileRef = 7085DDAC26CDA2980033B977 /* Documentation.docc */; };
2130
708A2CA42A092EE100AAB18A /* TestHostAllApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708A2CA32A092EE100AAB18A /* TestHostAllApp.swift */; };
2231
708A2CA62A092EE100AAB18A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708A2CA52A092EE100AAB18A /* ContentView.swift */; };
@@ -119,6 +128,15 @@
119128
700B0EDB270DE0C400EEF103 /* PCKVersionable+combine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PCKVersionable+combine.swift"; sourceTree = "<group>"; };
120129
70365BEA2A0D774400F577F7 /* ParseCareKit.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ParseCareKit.xctestplan; sourceTree = "<group>"; };
121130
705DC91D2526A4B80035BBE3 /* ParseCareKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ParseCareKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
131+
707DC1D12C4345B100FC1DFD /* OCKSemanticVersion+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKSemanticVersion+Parse.swift"; sourceTree = "<group>"; };
132+
707DC1D32C4346D000FC1DFD /* OCKNote+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKNote+Parse.swift"; sourceTree = "<group>"; };
133+
707DC1D52C4347B000FC1DFD /* OCKSchedule+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKSchedule+Parse.swift"; sourceTree = "<group>"; };
134+
707DC1D72C43486900FC1DFD /* OCKScheduleElement+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKScheduleElement+Parse.swift"; sourceTree = "<group>"; };
135+
707DC1D92C43492300FC1DFD /* OCKOutcomeValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OCKOutcomeValue.swift; sourceTree = "<group>"; };
136+
707DC1DB2C434B1E00FC1DFD /* OCKBiologicalSex+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKBiologicalSex+Parse.swift"; sourceTree = "<group>"; };
137+
707DC1DD2C434B8700FC1DFD /* OCKPostalAddress+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKPostalAddress+Parse.swift"; sourceTree = "<group>"; };
138+
707DC1DF2C434BD700FC1DFD /* OCKContactCategory+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKContactCategory+Parse.swift"; sourceTree = "<group>"; };
139+
707DC1E12C434C1A00FC1DFD /* OCKLabeledValue+Parse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCKLabeledValue+Parse.swift"; sourceTree = "<group>"; };
122140
7085DDAC26CDA2980033B977 /* Documentation.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = Documentation.docc; sourceTree = "<group>"; };
123141
708A2CA12A092EE100AAB18A /* TestHostAll.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestHostAll.app; sourceTree = BUILT_PRODUCTS_DIR; };
124142
708A2CA32A092EE100AAB18A /* TestHostAllApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHostAllApp.swift; sourceTree = "<group>"; };
@@ -329,11 +347,20 @@
329347
91226D50274ABFCF00B5C2DF /* Extensions */ = {
330348
isa = PBXGroup;
331349
children = (
350+
707DC1DB2C434B1E00FC1DFD /* OCKBiologicalSex+Parse.swift */,
332351
91226D53274AC1DB00B5C2DF /* OCKCarePlan+Parse.swift */,
333352
91226D55274AC1EF00B5C2DF /* OCKContact+Parse.swift */,
353+
707DC1DF2C434BD700FC1DFD /* OCKContactCategory+Parse.swift */,
334354
91226D57274AC20A00B5C2DF /* OCKHealthKitTask+Parse.swift */,
355+
707DC1E12C434C1A00FC1DFD /* OCKLabeledValue+Parse.swift */,
356+
707DC1D32C4346D000FC1DFD /* OCKNote+Parse.swift */,
335357
91226D59274AC23300B5C2DF /* OCKOutcome+Parse.swift */,
358+
707DC1D92C43492300FC1DFD /* OCKOutcomeValue.swift */,
336359
91226D51274AC00500B5C2DF /* OCKPatient+Parse.swift */,
360+
707DC1DD2C434B8700FC1DFD /* OCKPostalAddress+Parse.swift */,
361+
707DC1D52C4347B000FC1DFD /* OCKSchedule+Parse.swift */,
362+
707DC1D72C43486900FC1DFD /* OCKScheduleElement+Parse.swift */,
363+
707DC1D12C4345B100FC1DFD /* OCKSemanticVersion+Parse.swift */,
337364
91226D5B274AC24A00B5C2DF /* OCKTask+Parse.swift */,
338365
);
339366
path = Extensions;
@@ -579,10 +606,13 @@
579606
files = (
580607
709D175D258551D20002E772 /* ParseCareKitLog.swift in Sources */,
581608
700B0ED3270DD62200EEF103 /* PCKObjectable+async.swift in Sources */,
609+
707DC1DC2C434B1E00FC1DFD /* OCKBiologicalSex+Parse.swift in Sources */,
582610
700B0ED6270DD7D900EEF103 /* PCKVersionable+async.swift in Sources */,
583611
9119D60B24561B02001B7AA3 /* ParseCareKitConstants.swift in Sources */,
584612
700B0ED9270DDF5600EEF103 /* PCKObjectable+combine.swift in Sources */,
585613
9181F1A629EC48B700C50391 /* PCKEntity.swift in Sources */,
614+
707DC1E02C434BD700FC1DFD /* OCKContactCategory+Parse.swift in Sources */,
615+
707DC1DA2C43492300FC1DFD /* OCKOutcomeValue.swift in Sources */,
586616
91226D5A274AC23300B5C2DF /* OCKOutcome+Parse.swift in Sources */,
587617
9119D60D24561B22001B7AA3 /* PCKUtility.swift in Sources */,
588618
700775AA2522686D00EC0EDA /* PCKVersionable.swift in Sources */,
@@ -603,13 +633,19 @@
603633
7099D21C29ED8B420037CD8E /* PCKStoreClass.swift in Sources */,
604634
91226D52274AC00500B5C2DF /* OCKPatient+Parse.swift in Sources */,
605635
70B5578927A744A9002C39D4 /* PCKWriteRole.swift in Sources */,
636+
707DC1D22C4345B100FC1DFD /* OCKSemanticVersion+Parse.swift in Sources */,
637+
707DC1DE2C434B8700FC1DFD /* OCKPostalAddress+Parse.swift in Sources */,
606638
7085DDAD26CDA2980033B977 /* Documentation.docc in Sources */,
607639
91226D56274AC1EF00B5C2DF /* OCKContact+Parse.swift in Sources */,
608640
9181F1A329EC47D800C50391 /* PCKRevisionRecord.swift in Sources */,
609641
91226D54274AC1DB00B5C2DF /* OCKCarePlan+Parse.swift in Sources */,
610642
709D1818258699840002E772 /* ParseRemoteDelegate.swift in Sources */,
611643
70B5578327A74113002C39D4 /* PCKRoleable.swift in Sources */,
644+
707DC1D82C43486900FC1DFD /* OCKScheduleElement+Parse.swift in Sources */,
612645
916570D72462DABC008F2997 /* ParseRemote.swift in Sources */,
646+
707DC1E22C434C1A00FC1DFD /* OCKLabeledValue+Parse.swift in Sources */,
647+
707DC1D62C4347B000FC1DFD /* OCKSchedule+Parse.swift in Sources */,
648+
707DC1D42C4346D000FC1DFD /* OCKNote+Parse.swift in Sources */,
613649
70B5578627A7439B002C39D4 /* PCKReadRole.swift in Sources */,
614650
9119D60724561A28001B7AA3 /* PCKCarePlan.swift in Sources */,
615651
);
@@ -1012,7 +1048,7 @@
10121048
repositoryURL = "https://github.com/netreconlab/Parse-Swift.git";
10131049
requirement = {
10141050
kind = upToNextMajorVersion;
1015-
minimumVersion = 5.10.0;
1051+
minimumVersion = 5.10.3;
10161052
};
10171053
};
10181054
91FF60492AC0A51100E90E16 /* XCRemoteSwiftPackageReference "CareKit" */ = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// OCKBiologicalSex+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKBiologicalSex: @unchecked Sendable {}
13+
14+
extension OCKBiologicalSex: Hashable {
15+
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(self)
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// OCKContactCategory+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKContactCategory: @unchecked Sendable {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// OCKLabeledValue+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKLabeledValue: @unchecked Sendable {}
13+
14+
extension OCKLabeledValue: Hashable {
15+
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(label)
18+
hasher.combine(value)
19+
}
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// OCKNote+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKNote: @unchecked Sendable {}
13+
14+
extension OCKNote: Hashable {
15+
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(author)
18+
hasher.combine(title)
19+
hasher.combine(content)
20+
}
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// OCKOutcomeValue.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKOutcomeValue: @unchecked Sendable {}
13+
14+
extension OCKOutcomeValue: Hashable {
15+
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(kind)
18+
hasher.combine(units)
19+
hasher.combine(createdDate)
20+
hasher.combine(integerValue)
21+
hasher.combine(doubleValue)
22+
hasher.combine(booleanValue)
23+
hasher.combine(stringValue)
24+
hasher.combine(dataValue)
25+
hasher.combine(dateValue)
26+
}
27+
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// OCKPostalAddress+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKPostalAddress: @unchecked Sendable {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// OCKSchedule+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKSchedule: @unchecked Sendable {}
13+
14+
extension OCKSchedule: Hashable {
15+
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(elements)
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// OCKScheduleElement+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKScheduleElement: @unchecked Sendable {}
13+
14+
extension OCKScheduleElement.Duration: Hashable {
15+
public func hash(into hasher: inout Hasher) {
16+
hasher.combine(self)
17+
}
18+
}
19+
20+
extension OCKScheduleElement: Hashable {
21+
22+
public func hash(into hasher: inout Hasher) {
23+
hasher.combine(text)
24+
hasher.combine(duration)
25+
hasher.combine(start)
26+
hasher.combine(end)
27+
hasher.combine(interval)
28+
hasher.combine(targetValues)
29+
}
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// OCKSemanticVersion+Parse.swift
3+
// ParseCareKit
4+
//
5+
// Created by Corey Baker on 7/13/24.
6+
// Copyright © 2024 Network Reconnaissance Lab. All rights reserved.
7+
//
8+
9+
import CareKitStore
10+
import Foundation
11+
12+
extension OCKSemanticVersion: @unchecked Sendable {}
13+
14+
extension OCKSemanticVersion: Hashable {
15+
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(majorVersion)
18+
hasher.combine(minorVersion)
19+
hasher.combine(patchNumber)
20+
}
21+
22+
}

Sources/ParseCareKit/Models/PCKEntity.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import CareKitStore
1010
import Foundation
1111

1212
/// Holds one of several possible modified entities.
13-
public enum PCKEntity: Equatable, Codable {
13+
public enum PCKEntity: Hashable, Codable, Sendable {
1414

1515
/// A patient entity.
1616
case patient(PCKPatient)

Sources/ParseCareKit/Models/PCKRevisionRecord.swift

+21-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import ParseSwift
1212

1313
/// Revision records are exchanged by the CareKit and a ParseCareKit remote during synchronization.
1414
/// Each revision record contains an array of entities as well as a knowledge vector.
15-
struct PCKRevisionRecord: ParseObject, Equatable, Codable {
15+
struct PCKRevisionRecord: ParseObject {
1616

1717
public static var className: String {
1818
"RevisionRecord"
@@ -116,10 +116,29 @@ struct PCKRevisionRecord: ParseObject, Equatable, Codable {
116116
logicalClock, clock, clockUUID
117117
}
118118

119+
func hash(into hasher: inout Hasher) {
120+
hasher.combine(id)
121+
hasher.combine(createdAt)
122+
hasher.combine(updatedAt)
123+
hasher.combine(ACL)
124+
hasher.combine(originalData)
125+
hasher.combine(clockUUID)
126+
hasher.combine(knowledgeVectorString)
127+
hasher.combine(logicalClock)
128+
hasher.combine(clock)
129+
hasher.combine(entities)
130+
}
131+
119132
static func == (lhs: PCKRevisionRecord, rhs: PCKRevisionRecord) -> Bool {
133+
lhs.id == rhs.id &&
134+
lhs.createdAt == rhs.createdAt &&
135+
lhs.updatedAt == rhs.updatedAt &&
136+
lhs.ACL == rhs.ACL &&
137+
lhs.originalData == rhs.originalData &&
138+
lhs.clockUUID == rhs.clockUUID &&
139+
lhs.clock == rhs.clock &&
120140
lhs.knowledgeVectorString == rhs.knowledgeVectorString &&
121141
lhs.logicalClock == rhs.logicalClock &&
122-
lhs.objectId == rhs.objectId &&
123142
lhs.entities == rhs.entities
124143
}
125144

Sources/ParseCareKit/Models/PCKStoreClass.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import os.log
1313
// swiftlint:disable line_length
1414

1515
/// Types of ParseCareKit classes.
16-
public enum PCKStoreClass: String, Equatable, CaseIterable {
16+
public enum PCKStoreClass: String, Hashable, CaseIterable, Sendable {
1717
/// The ParseCareKit equivalent of `OCKPatient`.
1818
case patient
1919
/// The ParseCareKit equivalent of `OCKCarePlan`.

Sources/ParseCareKit/Protocols/PCKObjectable.swift

-8
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ extension PCKObjectable {
116116
}
117117
return returnId
118118
}
119-
120-
public static func == (lhs: Self, rhs: Self) -> Bool {
121-
lhs.uuid == rhs.uuid
122-
}
123-
124-
public func hash(into hasher: inout Hasher) {
125-
hasher.combine(self.uuid)
126-
}
127119
}
128120

129121
extension PCKObjectable {

0 commit comments

Comments
 (0)