//
//  LKFIssue.swift
//  lkfc
//
//  Created by Alexander Holzer on 06.06.22.
//  Copyright © 2022 Alexander Holzer. All rights reserved.
//

import Foundation
@_implementationOnly import LibLKF

public class LKFIssue {
    
    public let index : UInt32
    public let code: String
    public let aufenthaltIndex: Int?
    
    public let values: [String]
    
    public var isError : Bool {
        return code.starts(with: "E")
    }
    
    public var isWarning: Bool {
        return code.starts(with: "W")
    }
    
    public var isInfo: Bool {
        return code.starts(with: "H")
    }
    
    public var isFatal : Bool {
        return code.starts(with: "F")
    }

    init (index: UInt32, code: String, aufenthaltIndex: Int?, values:[String]) {
        if let aufenthaltIndex, aufenthaltIndex >= 0 {
            self.aufenthaltIndex = aufenthaltIndex
        }
        else {
            self.aufenthaltIndex = nil
        }
        self.index = index
        self.code = code
        self.values = values
    }
}
