//
//  ListTwoColumnCompareChangesModel.swift
//  MVMCoreUI
//
//  Created by Lekshmi S on 24/02/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


public class ListTwoColumnCompareChangesModel: ListItemModel, MoleculeModelProtocol {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    public static var identifier: String = "list2CCmpr1"
    public var leftHeadline1: LabelModel
    public var leftHeadline2: LabelModel
    public var leftHeadline3: LabelModel
    public var leftBody: LabelModel
    public var leftLink: LinkModel
    public var rightHeadline1: LabelModel
    public var rightHeadline2: LabelModel
    public var rightHeadline3: LabelModel
    public var rightBody: LabelModel
    public var rightLink: LinkModel
    
    //--------------------------------------------------
    // MARK: - Initializer
    //--------------------------------------------------
    
    public init(leftHeadline1: LabelModel, leftHeadline2: LabelModel, leftHeadline3: LabelModel, leftBody: LabelModel, leftLink: LinkModel, rightHeadline1: LabelModel, rightHeadline2: LabelModel, rightHeadline3: LabelModel, rightBody: LabelModel, rightLink: LinkModel) {
        self.leftHeadline1 = leftHeadline1
        self.leftHeadline2 = leftHeadline2
        self.leftHeadline3 = leftHeadline3
        self.leftBody = leftBody
        self.leftLink = leftLink
        self.rightHeadline1 = rightHeadline1
        self.rightHeadline2 = rightHeadline2
        self.rightHeadline3 = rightHeadline3
        self.rightBody = rightBody
        self.rightLink = rightLink
        super.init()
    }
    
    //--------------------------------------------------
    // MARK: - Keys
    //--------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case moleculeName
        case leftHeadline1
        case leftHeadline2
        case leftHeadline3
        case leftBody
        case leftLink
        case rightHeadline1
        case rightHeadline2
        case rightHeadline3
        case rightBody
        case rightLink
    }
    
    //--------------------------------------------------
    // MARK: - Codec
    //--------------------------------------------------
    
    required public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        leftHeadline1 = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline1)
        leftHeadline2 = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline2)
        leftHeadline3 = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline3)
        leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody)
        leftLink = try typeContainer.decode(LinkModel.self, forKey: .leftLink)
        rightHeadline1 = try typeContainer.decode(LabelModel.self, forKey: .rightHeadline1)
        rightHeadline2 = try typeContainer.decode(LabelModel.self, forKey: .rightHeadline2)
        rightHeadline3 = try typeContainer.decode(LabelModel.self, forKey: .rightHeadline3)
        rightBody = try typeContainer.decode(LabelModel.self, forKey: .rightBody)
        rightLink = try typeContainer.decode(LinkModel.self, forKey: .rightLink)
        try super.init(from: decoder)
    }
    
    public  override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(moleculeName, forKey: .moleculeName)
        try container.encode(leftHeadline1, forKey: .leftHeadline1)
        try container.encode(leftHeadline2, forKey: .leftHeadline2)
        try container.encode(leftHeadline3, forKey: .leftHeadline3)
        try container.encode(leftBody, forKey: .leftBody)
        try container.encode(leftLink, forKey: .leftLink)
        try container.encode(rightHeadline1, forKey: .rightHeadline1)
        try container.encode(rightHeadline2, forKey: .rightHeadline2)
        try container.encode(rightHeadline3, forKey: .rightHeadline3)
        try container.encode(rightBody, forKey: .rightBody)
        try container.encode(rightLink, forKey: .rightLink)
    }
}
