<commit_before>//
//  File.swift
//  SOGraphDB-Mac
//
//  Created by <NAME> on 17.11.17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation

public enum PropertyType {
    case undefined
    case boolean
    case integer
    //case double
    case string
    //kNSNumberType,
    //     kLongType,
    // kUnsignedLongType,
    //    kNSDataType,
    //    kSOIDType,
    //    kNSDateType,
    //    kNSPointType,
    //    kNSRangeType,
    // kNSDecimalType,
    // kNSUUIDType
    //    kNSURLType  // may not work
}

public struct Property {
    
    public var uid: UID!
    public var dirty: Bool = true
    
    public var type = PropertyType.undefined 
    
    public var boolValue : Bool? = nil {
        didSet {
            type = PropertyType.boolean
        }
    }
    public var intValue : Int? = nil {
        didSet {
            type = PropertyType.integer
        }
    }
    public var stringValue : String? = nil {
        didSet {
            type = PropertyType.string
        }
    }
    
    
    //public var owner : PropertyAccess! = nil
    //public var keyNode : Node
    public var keyNodeID : UID
    
    //var isNodeSource: Bool = false;         // 3  <- yes = property of a node / no = property of a relationship
    
    //var sourceID: UID = 0  // the ID of the related node or relationship

    public init(keyNodeID: UID) {
        //self.keyNode = key
        self.keyNodeID = keyNodeID // key.uid
    }
    
    public func string() -> String {
        switch type {
        case .boolean:
            if let value = boolValue {
                return String(value)
            }
            break
        case .integer:
            if let value = intValue {
                return String(value)
            }
            break
        case .string:
            if let value = stringValue {
                return value
            }
            break
        case .undefined:
            return ""
        }
        
        return ""
    }
    
    /**
    public init( related : PropertyAccess) {
        
        sourceID = related.uid!
        
        // default is false
        if related is Node {<commit_msg>add comment<commit_after>//
//  File.swift
//  SOGraphDB-Mac
//
//  Created by <NAME> on 17.11.17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation

public enum PropertyType {
    case undefined
    case boolean
    case integer
    //case double
    case string
    //kNSNumberType,
    //     kLongType,
    // kUnsignedLongType,
    //    kNSDataType,
    //    kSOIDType,
    //    kNSDateType,
    //    kNSPointType,
    //    kNSRangeType,
    // kNSDecimalType,
    // kNSUUIDType
    //    kNSURLType  // may not work
}

public struct Property {
    
    public var uid: UID!
    public var dirty: Bool = true
    
    public var type = PropertyType.undefined 
    
    public var boolValue : Bool? = nil {
        didSet {
            type = PropertyType.boolean
        }
    }
    public var intValue : Int? = nil {
        didSet {
            type = PropertyType.integer
        }
    }
    public var stringValue : String? = nil {
        didSet {
            type = PropertyType.string
        }
    }
    
    
    //public var owner : PropertyAccess! = nil
    //public var keyNode : Node
    public var keyNodeID : UID
    
    //var isNodeSource: Bool = false;         // 3  <- yes = property of a node / no = property of a relationship
    
    //var sourceID: UID = 0  // the ID of the related node or relationship

    public init(keyNodeID: UID) {
        //self.keyNode = key
        self.keyNodeID = keyNodeID // key.uid
    }
    
    
    // TODO extend String(_ node: Node) as usual for SWIFT 4.0
    public func string() -> String {
        switch type {
        case .boolean:
            if let value = boolValue {
                return String(value)
            }
            break
        case .integer:
            if let value = intValue {
                return String(value)
            }
            break
        case .string:
            if let value = stringValue {
                return value
            }
            break
        case .undefined:
            return ""
        }
        
        return ""
    }
    
    /**
    public init( related : PropertyAccess) {
        
        sourceID = related.uid!
        
        // default is false
        if related is Node {
{'fraction_non_alphanumeric': 0.08581752484191509, 'fraction_numerical': 0.005871725383920506, 'mean_word_length': 1.3007792207792208, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6600918', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1254, 'n_words': 375}