updated to have a casted isEqual

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-09-15 16:58:54 -05:00
parent 378802eb5e
commit 48797d2003
7 changed files with 11 additions and 12 deletions

View File

@ -19,7 +19,7 @@ public struct LabelAttributeActionModel: LabelAttributeActionable {
lhs.isEqual(rhs) lhs.isEqual(rhs)
} }
public func isEqualSelf(_ equatable: LabelAttributeActionModel) -> Bool { public func isEqual(_ equatable: LabelAttributeActionModel) -> Bool {
return id == equatable.id && range == equatable.range return id == equatable.id && range == equatable.range
} }

View File

@ -9,7 +9,7 @@ import Foundation
import UIKit import UIKit
public struct LabelAttributeColor: LabelAttributeModel { 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 return id == equatable.id && range == equatable.range && color == equatable.color
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -9,7 +9,7 @@ import Foundation
import UIKit import UIKit
public struct LabelAttributeFont: LabelAttributeModel { public struct LabelAttributeFont: LabelAttributeModel {
public func isEqualSelf(_ equatable: LabelAttributeFont) -> Bool { public func isEqual(_ equatable: LabelAttributeFont) -> Bool {
return id == equatable.id return id == equatable.id
&& range == equatable.range && range == equatable.range
&& color == equatable.color && color == equatable.color

View File

@ -9,7 +9,7 @@ import Foundation
import UIKit import UIKit
public struct LabelAttributeStrikeThrough: LabelAttributeModel { public struct LabelAttributeStrikeThrough: LabelAttributeModel {
public func isEqualSelf(_ equatable: LabelAttributeStrikeThrough) -> Bool { public func isEqual(_ equatable: LabelAttributeStrikeThrough) -> Bool {
return id == equatable.id return id == equatable.id
&& range == equatable.range && range == equatable.range
} }

View File

@ -10,7 +10,7 @@ import UIKit
public struct LabelAttributeUnderline: LabelAttributeModel { public struct LabelAttributeUnderline: LabelAttributeModel {
public func isEqualSelf(_ equatable: LabelAttributeUnderline) -> Bool { public func isEqual(_ equatable: LabelAttributeUnderline) -> Bool {
return id == equatable.id return id == equatable.id
&& range == equatable.range && range == equatable.range
&& color == equatable.color && color == equatable.color

View File

@ -15,10 +15,10 @@ public protocol LabelModel: Modelable, Labelable {
public struct DefaultLabelModel: LabelModel, AnyEquatable, Equatable { public struct DefaultLabelModel: LabelModel, AnyEquatable, Equatable {
public static func == (lhs: DefaultLabelModel, rhs: DefaultLabelModel) -> Bool { 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 return id == equatable.id
&& attributes == equatable.attributes && attributes == equatable.attributes
&& text == equatable.text && text == equatable.text

View File

@ -8,16 +8,15 @@
import Foundation import Foundation
public protocol AnyEquatable { public protocol AnyEquatable {
func isEqual(_ equatable: any AnyEquatable) -> Bool func isEqual(_ equatable: Self) -> Bool
func isEqualSelf(_ equatable: Self) -> Bool
} }
extension AnyEquatable { extension AnyEquatable {
public func isEqual(_ equatable: any AnyEquatable) -> Bool { public func isEqual(_ anyEquatable: any AnyEquatable) -> Bool {
guard let equatable = equatable as? Self else { guard let equatable = anyEquatable as? Self else {
return false return false
} }
return isEqualSelf(equatable) return isEqual(equatable)
} }
} }