This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol JSONFactory { | |
static func make(jsonData: Data?) -> Self? | |
} | |
extension JSONFactory where Self: Decodable { | |
static func make(jsonData: Data?) -> Self? { | |
guard let jsonData = jsonData, | |
let result = try? JSONDecoder().decode(Self.self, from: jsonData) else { | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Compare 2 nullable for equality. If both are null they are considered to be equal. | |
* | |
* @param lhs Left Hand Side value | |
* @param rhs Right Hand Side value | |
* @param <T> A Type on which `equals()` will be called | |
* @return true if the 2 values are equals taking `null` into account. | |
*/ | |
public static <T> Boolean isEqual(@Nullable T lhs, @Nullable T rhs) { | |
Boolean result; |