// Generated by SwiftModelGenerator
// Do not modify this file manually

import Foundation
import LeStorage
import SwiftUI

@Observable
class BaseMonthData: BaseModelObject, Storable {

    static func resourceName() -> String { return "month-data" }
    static func tokenExemptedMethods() -> [HTTPMethod] { return [] }

    var id: String = Store.randomId()
    var monthKey: String = ""
    var creationDate: Date = Date()
    var maleUnrankedValue: Int? = nil
    var femaleUnrankedValue: Int? = nil
    var maleCount: Int? = nil
    var femaleCount: Int? = nil
    var anonymousCount: Int? = nil
    var incompleteMode: Bool = false
    var dataModelIdentifier: String? = nil
    var fileModelIdentifier: String? = nil

    init(
        id: String = Store.randomId(),
        monthKey: String = "",
        creationDate: Date = Date(),
        maleUnrankedValue: Int? = nil,
        femaleUnrankedValue: Int? = nil,
        maleCount: Int? = nil,
        femaleCount: Int? = nil,
        anonymousCount: Int? = nil,
        incompleteMode: Bool = false,
        dataModelIdentifier: String? = nil,
        fileModelIdentifier: String? = nil
    ) {
        super.init()
        self.id = id
        self.monthKey = monthKey
        self.creationDate = creationDate
        self.maleUnrankedValue = maleUnrankedValue
        self.femaleUnrankedValue = femaleUnrankedValue
        self.maleCount = maleCount
        self.femaleCount = femaleCount
        self.anonymousCount = anonymousCount
        self.incompleteMode = incompleteMode
        self.dataModelIdentifier = dataModelIdentifier
        self.fileModelIdentifier = fileModelIdentifier
    }
    required public override init() {
        super.init()
    }

    enum CodingKeys: String, CodingKey {
        case _id = "id"
        case _monthKey = "monthKey"
        case _creationDate = "creationDate"
        case _maleUnrankedValue = "maleUnrankedValue"
        case _femaleUnrankedValue = "femaleUnrankedValue"
        case _maleCount = "maleCount"
        case _femaleCount = "femaleCount"
        case _anonymousCount = "anonymousCount"
        case _incompleteMode = "incompleteMode"
        case _dataModelIdentifier = "dataModelIdentifier"
        case _fileModelIdentifier = "fileModelIdentifier"
    }

    required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId()
        self.monthKey = try container.decodeIfPresent(String.self, forKey: ._monthKey) ?? ""
        self.creationDate = try container.decodeIfPresent(Date.self, forKey: ._creationDate) ?? Date()
        self.maleUnrankedValue = try container.decodeIfPresent(Int.self, forKey: ._maleUnrankedValue) ?? nil
        self.femaleUnrankedValue = try container.decodeIfPresent(Int.self, forKey: ._femaleUnrankedValue) ?? nil
        self.maleCount = try container.decodeIfPresent(Int.self, forKey: ._maleCount) ?? nil
        self.femaleCount = try container.decodeIfPresent(Int.self, forKey: ._femaleCount) ?? nil
        self.anonymousCount = try container.decodeIfPresent(Int.self, forKey: ._anonymousCount) ?? nil
        self.incompleteMode = try container.decodeIfPresent(Bool.self, forKey: ._incompleteMode) ?? false
        self.dataModelIdentifier = try container.decodeIfPresent(String.self, forKey: ._dataModelIdentifier) ?? nil
        self.fileModelIdentifier = try container.decodeIfPresent(String.self, forKey: ._fileModelIdentifier) ?? nil
        try super.init(from: decoder)
    }

    override func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(self.id, forKey: ._id)
        try container.encode(self.monthKey, forKey: ._monthKey)
        try container.encode(self.creationDate, forKey: ._creationDate)
        try container.encode(self.maleUnrankedValue, forKey: ._maleUnrankedValue)
        try container.encode(self.femaleUnrankedValue, forKey: ._femaleUnrankedValue)
        try container.encode(self.maleCount, forKey: ._maleCount)
        try container.encode(self.femaleCount, forKey: ._femaleCount)
        try container.encode(self.anonymousCount, forKey: ._anonymousCount)
        try container.encode(self.incompleteMode, forKey: ._incompleteMode)
        try container.encode(self.dataModelIdentifier, forKey: ._dataModelIdentifier)
        try container.encode(self.fileModelIdentifier, forKey: ._fileModelIdentifier)
        try super.encode(to: encoder)
    }

    func copy(from other: any Storable) {
        guard let monthdata = other as? BaseMonthData else { return }
        self.id = monthdata.id
        self.monthKey = monthdata.monthKey
        self.creationDate = monthdata.creationDate
        self.maleUnrankedValue = monthdata.maleUnrankedValue
        self.femaleUnrankedValue = monthdata.femaleUnrankedValue
        self.maleCount = monthdata.maleCount
        self.femaleCount = monthdata.femaleCount
        self.anonymousCount = monthdata.anonymousCount
        self.incompleteMode = monthdata.incompleteMode
        self.dataModelIdentifier = monthdata.dataModelIdentifier
        self.fileModelIdentifier = monthdata.fileModelIdentifier
    }

    static func relationships() -> [Relationship] {
        return []
    }

}