<commit_before>//
//  EntityCodeGenerator.swift
//  ACDGen
//
//  Created by <NAME> on 2015-02-28.
//  Copyright (c) 2015 Alecrim. All rights reserved.
//

import Foundation
import CoreData

public final class EntityCodeGenerator: CodeGenerator {
    
    public let parameters: CodeGeneratorParameters
    private let entityDescription: NSEntityDescription
    
    public init(parameters: CodeGeneratorParameters, entityDescription: NSEntityDescription) {
        self.parameters = parameters
        self.entityDescription = entityDescription
    }
    
    public func generate() throws {
        //
        let string = NSMutableString()
        
        //
        let className = self.entityDescription.managedObjectClassName.components(separatedBy: ".").last!
        
        // header
        string.appendHeader(className, type: .class)
        
        // import
        string.appendLine("import Foundation")
        string.appendLine("import CoreData")
        string.appendLine()
        
        // class
        let superClassName = (self.entityDescription.superentity == nil ? "NSManagedObject" : self.entityDescription.superentity!.managedObjectClassName.components(separatedBy: ".").last!)
        let abstractOrFinal = self.entityDescription.isAbstract ? "/* abstract */ " : "final "
        
        string.appendLine("@objc(\(className))")
        string.appendLine(self.parameters.accessModifier + "\(abstractOrFinal)class \(className): \(superClassName) {")
        string.appendLine()<commit_msg>ACDGen: Removed "final" from generated entity classes<commit_after>//
//  EntityCodeGenerator.swift
//  ACDGen
//
//  Created by <NAME> on 2015-02-28.
//  Copyright (c) 2015 Alecrim. All rights reserved.
//

import Foundation
import CoreData

public final class EntityCodeGenerator: CodeGenerator {
    
    public let parameters: CodeGeneratorParameters
    private let entityDescription: NSEntityDescription
    
    public init(parameters: CodeGeneratorParameters, entityDescription: NSEntityDescription) {
        self.parameters = parameters
        self.entityDescription = entityDescription
    }
    
    public func generate() throws {
        //
        let string = NSMutableString()
        
        //
        let className = self.entityDescription.managedObjectClassName.components(separatedBy: ".").last!
        
        // header
        string.appendHeader(className, type: .class)
        
        // import
        string.appendLine("import Foundation")
        string.appendLine("import CoreData")
        string.appendLine()
        
        // class
        let superClassName = (self.entityDescription.superentity == nil ? "NSManagedObject" : self.entityDescription.superentity!.managedObjectClassName.components(separatedBy: ".").last!)
        let abstractOrFinal = self.entityDescription.isAbstract ? "/* abstract */ " : "" // "final "
        
        string.appendLine("@objc(\(className))")
        string.appendLine(self.parameters.accessModifier + "\(abstractOrFinal)class \(className): \(superClassName) {")
        string.appendLine()
{'fraction_non_alphanumeric': 0.10517799352750809, 'fraction_numerical': 0.007766990291262136, 'mean_word_length': 2.7649208282582216, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '816428', 'n_tokens_mistral': 799, 'n_tokens_neox': 774, 'n_words': 167}