//
//  LKFFilterError.swift
//  lkfc
//
//  Created by Alexander Holzer on 13.01.22.
//  Copyright © 2022 Alexander Holzer. All rights reserved.
//

import Foundation

public class LKFFilterError : LKFFilter {
    let error : Bool
    let warning : Bool
    let info : Bool

    public init (type: String) {
        error = type.firstIndex(of: "E") != nil
        warning = type.firstIndex(of: "W") != nil
        info = type.firstIndex(of: "I") != nil
    }
    
    override public func isIncluded(contact: LKFAufenthalt) -> Bool {
        if error && contact.errorCount > 0 {
            return true
        }
        if warning && contact.warningCount > 0 {
            return true
        }
        if info && contact.infoCount > 0 {
            return true
        }
        return false
    }
}
