<commit_before>//
// Created by <NAME> on 10/08/2017.
// Copyright (c) 2017 lucas34. All rights reserved.
//

import Foundation

public final class JobBuilder {

    private let type: String

    private var uuid: String =  UUID().uuidString
    private var group: String = "GLOBAL"
    private var tags = Set<String>()
    private var delay: Int = 0
    private var deadline: Date?
    private var requireNetwork: NetworkType = NetworkType.any
    private var isPersisted: Bool = false
    private var params: Any?
    private var createTime: Date = Date()
    private var maxRun: Int = 1
    private var retries: Int = 0
    private var interval: Double = -1.0

    public init(type: String) {
        self.type = type
    }

    public func singleInstance(forId: String) -> JobBuilder {
        self.uuid = forId
        return self
    }

    public func group(name: String) -> JobBuilder {
        self.group = name
        return self
    }

    public func delay(inSecond: Int) -> JobBuilder {
        delay = inSecond
        return self
    }

    public func deadline(date: Date) -> JobBuilder {
        deadline = date
        return self
    }

    public func periodic(count: Int = -1, interval: Double = 0) -> JobBuilder {
        maxRun = count
        self.interval = interval
        return self
    }

    #if os(iOS) || os(macOS) || os(tvOS)
    public func internet(atLeast: NetworkType) -> JobBuilder {
        requireNetwork = atLeast
        return self
    }
    #endif

    public func persist(required: Bool) -> JobBuilder {
        isPersisted = required<commit_msg>Enable internet constraint for all devices. Constraint to be ignore on watch<commit_after>//
// Created by <NAME> on 10/08/2017.
// Copyright (c) 2017 lucas34. All rights reserved.
//

import Foundation

public final class JobBuilder {

    private let type: String

    private var uuid: String =  UUID().uuidString
    private var group: String = "GLOBAL"
    private var tags = Set<String>()
    private var delay: Int = 0
    private var deadline: Date?
    private var requireNetwork: NetworkType = NetworkType.any
    private var isPersisted: Bool = false
    private var params: Any?
    private var createTime: Date = Date()
    private var maxRun: Int = 1
    private var retries: Int = 0
    private var interval: Double = -1.0

    public init(type: String) {
        self.type = type
    }

    public func singleInstance(forId: String) -> JobBuilder {
        self.uuid = forId
        return self
    }

    public func group(name: String) -> JobBuilder {
        self.group = name
        return self
    }

    public func delay(inSecond: Int) -> JobBuilder {
        delay = inSecond
        return self
    }

    public func deadline(date: Date) -> JobBuilder {
        deadline = date
        return self
    }

    public func periodic(count: Int = -1, interval: Double = 0) -> JobBuilder {
        maxRun = count
        self.interval = interval
        return self
    }

    public func internet(atLeast: NetworkType) -> JobBuilder {
        requireNetwork = atLeast
        return self
    }

    public func persist(required: Bool) -> JobBuilder {
        isPersisted = required
{'fraction_non_alphanumeric': 0.08539255552080074, 'fraction_numerical': 0.013137316233969347, 'mean_word_length': 2.2901234567901234, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '3801080', 'n_tokens_mistral': 927, 'n_tokens_neox': 875, 'n_words': 319}