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)
}
public func isEqualSelf(_ equatable: LabelAttributeActionModel) -> Bool {
public func isEqual(_ equatable: LabelAttributeActionModel) -> Bool {
return id == equatable.id && range == equatable.range
}

View File

@ -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
}
//--------------------------------------------------

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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)
}
}