//
//  UpdatableModelObject.swift
//  1Weather
//
//  Created by Demid Merzlyakov on 03.03.2021.
//

import Foundation

public protocol UpdatableModelObject {
    func mergedWith(incrementalChanges: Self) -> Self
    func mergedWith(incrementalChanges: Self?) -> Self
}

public extension UpdatableModelObject {
    func mergedWith(incrementalChanges: Self?) -> Self {
        if let incrementalChanges = incrementalChanges {
            return self.mergedWith(incrementalChanges: incrementalChanges)
        }
        else {
            return self
        }
    }
}

extension Array: UpdatableModelObject where Element: UpdatableModelObjectInTime {
    public func mergedWith(incrementalChanges: Array<Element>) -> Array<Element> {
        #warning("Not implemented!")
        //TODO: Implement!
        return incrementalChanges
    }
}
