//
//  Copyright (c) 2020 gematik GmbH
//  
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//  
//     http://www.apache.org/licenses/LICENSE-2.0
//  
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//

//
//  This file was generated from an xsd file and represents a simple or complex type of it.
//  Generated by a fork of xsd2cocoa (see https://github.com/Daij-Djan/xsd2cocoa) and a specified custom transform template.
//

import Foundation
import XMLTools

// MARK: - Generated file, do not edit. Any edits of this file will be overwritten and thus discarded.
public class NFD_NFD_Freiwillige_Zusatzinformationen {
    
    public static let namespacePrefix: String? = "NFD"
    public static let namespaceUri: String? = "http://ws.gematik.de/fa/nfds/NFD_Document/v1.3"
    
    // attributes:
    
    // elements:
    public var Freiwillige_Zusatzinformationen: String?
    
    // default Constructor
    public init() {
        
        self.Freiwillige_Zusatzinformationen = nil
        
    }
    
    // copy Constructor
    public init(_ _NFD_NFD_Freiwillige_Zusatzinformationen: NFD_NFD_Freiwillige_Zusatzinformationen ) {
        
        self.Freiwillige_Zusatzinformationen = _NFD_NFD_Freiwillige_Zusatzinformationen.Freiwillige_Zusatzinformationen
        
    }
    
    public class func deserialize(_ infoset: Infoset) -> NFD_NFD_Freiwillige_Zusatzinformationen {
        
        let _NFD_NFD_Freiwillige_Zusatzinformationen = NFD_NFD_Freiwillige_Zusatzinformationen()
        
        let uriFreiwillige_Zusatzinformationen = String.namespaceUri ?? self.namespaceUri ?? infoset.namespaceContext.defaultURI!
        let qNameFreiwillige_Zusatzinformationen = QName("Freiwillige_Zusatzinformationen", uri: uriFreiwillige_Zusatzinformationen)
        _NFD_NFD_Freiwillige_Zusatzinformationen.Freiwillige_Zusatzinformationen = String?.deserialize(infoset.select(qNameFreiwillige_Zusatzinformationen))
        
        return _NFD_NFD_Freiwillige_Zusatzinformationen
    }
}

extension Optional where Wrapped == NFD_NFD_Freiwillige_Zusatzinformationen {
    public static func deserialize(_ infoset: Infoset) -> NFD_NFD_Freiwillige_Zusatzinformationen? {
        if infoset.count == 0 {
            return nil
        } else {
            return NFD_NFD_Freiwillige_Zusatzinformationen.deserialize(infoset)
        }
    }
}

extension Array where Element: NFD_NFD_Freiwillige_Zusatzinformationen {
    public var namespaceUri: String? {
        get {
            return NFD_NFD_Freiwillige_Zusatzinformationen.namespaceUri
        }
    }
    
    public static func deserialize(_ infoset: Infoset) -> [NFD_NFD_Freiwillige_Zusatzinformationen] {
        return infoset.map { (element: Infoset) in
        NFD_NFD_Freiwillige_Zusatzinformationen.deserialize(element)
    }
}
}

// utility functions
fileprivate extension String {
    static let namespacePrefix: String? = nil
    static let namespaceUri: String? = nil
    
    static func deserialize(_ infoset: Infoset) -> String {
        return infoset.text
    }
}

fileprivate extension Optional where Wrapped == String {
    static func deserialize(_ infoset: Infoset) -> String? {
        if infoset.count == 0 {
            return nil
        } else {
            return String.deserialize(infoset)
        }
    }
}

fileprivate extension Int {
    static let namespacePrefix: String? = nil
    static let namespaceUri: String? = nil
    
    static func deserialize(_ infoset: Infoset) -> Int {
        guard let ret = Int(infoset.text) else {
            return 0
        }
        return ret
    }
}

fileprivate extension Optional where Wrapped == Int {
    static func deserialize(_ infoset: Infoset) -> Int? {
        if infoset.count == 0 {
            return nil
        } else {
            return Int.deserialize(infoset)
        }
    }
}

fileprivate extension Double {
    static let namespacePrefix: String? = nil
    static let namespaceUri: String? = nil
    
    static func deserialize(_ infoset: Infoset) -> Double {
        guard let ret = Double(infoset.text) else {
            return 0
        }
        return ret
    }
}

fileprivate extension Optional where Wrapped == Double {
    static func deserialize(_ infoset: Infoset) -> Double? {
        if infoset.count == 0 {
            return nil
        } else {
            return Double.deserialize(infoset)
        }
    }
}

