//
//  LKFFilterIntRange.swift
//  lkfc
//
//  Created by Alexander Holzer on 12.01.2022.
//  Copyright © 2022 Alexander Holzer. All rights reserved.
//

import Foundation

public class LKFFilterIntRange : LKFFilter {
    let field: LKFAufenthaltFields
    let value: (Int?,Int?)
    
    init (field: LKFAufenthaltFields, value:(Int?,Int?)) {
        self.field = field
        self.value = value
    }
    
    public override func isIncluded(contact: LKFAufenthalt) -> Bool {
        let v = contact.getResultField(field)
        if let minValue = value.0, v < minValue {
            return false
        }
        if let maxValue = value.1, v > maxValue {
            return false
        }
        return true
    }
}

public class LKFFilterDayRange : LKFFilterIntRange {
    public init (value:(Int?, Int?)) {
        super.init(field: .gesvd, value: value)
    }
}

public class LKFFilterAgeRange : LKFFilterIntRange {
    public init (value:(Int?, Int?)) {
        super.init(field: .alter, value: value)
    }
}

public class LKFFilterPointRange : LKFFilterIntRange {
    public init (value:(Int?, Int?)) {
        super.init(field: .ges, value: value)
    }
}
