From 48797d2003f9254c53f902c1a3a4466c55480804 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 15 Sep 2022 16:58:54 -0500 Subject: [PATCH] updated to have a casted isEqual Signed-off-by: Matt Bruce --- .../Label/Attributes/LabelAttributeAction.swift | 2 +- .../Label/Attributes/LabelAttributeColor.swift | 2 +- VDS/Components/Label/Attributes/LabelAttributeFont.swift | 2 +- .../Label/Attributes/LabelAttributeStrikeThrough.swift | 2 +- .../Label/Attributes/LabelAttributeUnderline.swift | 2 +- VDS/Components/Label/LabelModel.swift | 4 ++-- VDS/Protocols/AnyEquatable.swift | 9 ++++----- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/VDS/Components/Label/Attributes/LabelAttributeAction.swift b/VDS/Components/Label/Attributes/LabelAttributeAction.swift index 584ba947..f2a5fe49 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeAction.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeAction.swift @@ -19,7 +19,7 @@ public struct LabelAttributeActionModel: LabelAttributeActionable { lhs.isEqual(rhs) } - public func isEqualSelf(_ equatable: LabelAttributeActionModel) -> Bool { + public func isEqual(_ equatable: LabelAttributeActionModel) -> Bool { return id == equatable.id && range == equatable.range } diff --git a/VDS/Components/Label/Attributes/LabelAttributeColor.swift b/VDS/Components/Label/Attributes/LabelAttributeColor.swift index b63781ca..6d3f35aa 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeColor.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeColor.swift @@ -9,7 +9,7 @@ import Foundation import UIKit public struct LabelAttributeColor: LabelAttributeModel { - public func isEqualSelf(_ equatable: LabelAttributeColor) -> Bool { + public func isEqual(_ equatable: LabelAttributeColor) -> Bool { return id == equatable.id && range == equatable.range && color == equatable.color } //-------------------------------------------------- diff --git a/VDS/Components/Label/Attributes/LabelAttributeFont.swift b/VDS/Components/Label/Attributes/LabelAttributeFont.swift index 15a0da1b..af559184 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeFont.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeFont.swift @@ -9,7 +9,7 @@ import Foundation import UIKit public struct LabelAttributeFont: LabelAttributeModel { - public func isEqualSelf(_ equatable: LabelAttributeFont) -> Bool { + public func isEqual(_ equatable: LabelAttributeFont) -> Bool { return id == equatable.id && range == equatable.range && color == equatable.color diff --git a/VDS/Components/Label/Attributes/LabelAttributeStrikeThrough.swift b/VDS/Components/Label/Attributes/LabelAttributeStrikeThrough.swift index 67341da7..6b62691c 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeStrikeThrough.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeStrikeThrough.swift @@ -9,7 +9,7 @@ import Foundation import UIKit public struct LabelAttributeStrikeThrough: LabelAttributeModel { - public func isEqualSelf(_ equatable: LabelAttributeStrikeThrough) -> Bool { + public func isEqual(_ equatable: LabelAttributeStrikeThrough) -> Bool { return id == equatable.id && range == equatable.range } diff --git a/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift b/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift index 2796e4f6..d7c302cc 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift @@ -10,7 +10,7 @@ import UIKit public struct LabelAttributeUnderline: LabelAttributeModel { - public func isEqualSelf(_ equatable: LabelAttributeUnderline) -> Bool { + public func isEqual(_ equatable: LabelAttributeUnderline) -> Bool { return id == equatable.id && range == equatable.range && color == equatable.color diff --git a/VDS/Components/Label/LabelModel.swift b/VDS/Components/Label/LabelModel.swift index 51987176..94c270ee 100644 --- a/VDS/Components/Label/LabelModel.swift +++ b/VDS/Components/Label/LabelModel.swift @@ -15,10 +15,10 @@ public protocol LabelModel: Modelable, Labelable { public struct DefaultLabelModel: LabelModel, AnyEquatable, Equatable { public static func == (lhs: DefaultLabelModel, rhs: DefaultLabelModel) -> Bool { - lhs.isEqualSelf(rhs) + lhs.isEqual(rhs) } - public func isEqualSelf(_ equatable: DefaultLabelModel) -> Bool { + public func isEqual(_ equatable: DefaultLabelModel) -> Bool { return id == equatable.id && attributes == equatable.attributes && text == equatable.text diff --git a/VDS/Protocols/AnyEquatable.swift b/VDS/Protocols/AnyEquatable.swift index 54a96aef..c4c3f8a8 100644 --- a/VDS/Protocols/AnyEquatable.swift +++ b/VDS/Protocols/AnyEquatable.swift @@ -8,16 +8,15 @@ import Foundation public protocol AnyEquatable { - func isEqual(_ equatable: any AnyEquatable) -> Bool - func isEqualSelf(_ equatable: Self) -> Bool + func isEqual(_ equatable: Self) -> Bool } extension AnyEquatable { - public func isEqual(_ equatable: any AnyEquatable) -> Bool { - guard let equatable = equatable as? Self else { + public func isEqual(_ anyEquatable: any AnyEquatable) -> Bool { + guard let equatable = anyEquatable as? Self else { return false } - return isEqualSelf(equatable) + return isEqual(equatable) } }