<commit_before>package org.codetome.zircon.graphics.style

import org.codetome.zircon.Modifier
import org.codetome.zircon.TextColor
import org.codetome.zircon.builder.TextColorFactory
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicReference

open class DefaultStyleSet : StyleSet {

    private var foregroundColor = AtomicReference<TextColor>(TextColorFactory.DEFAULT_FOREGROUND_COLOR)
    private var backgroundColor = AtomicReference<TextColor>(TextColorFactory.DEFAULT_BACKGROUND_COLOR)
    private val modifiers = ConcurrentHashMap<Modifier, Any>()

    override fun getForegroundColor(): TextColor = foregroundColor.get()

    override fun getBackgroundColor(): TextColor = backgroundColor.get()

    override fun getActiveModifiers() = modifiers.keys.toSet()

    override fun setBackgroundColor(backgroundColor: TextColor) {
        this.backgroundColor.set(backgroundColor)
    }

    override fun setForegroundColor(foregroundColor: TextColor) {
        this.foregroundColor.set(foregroundColor)
    }

    override fun enableModifiers(vararg modifiers: Modifier) {
        this.modifiers.putAll(modifiers.map { Pair(it, Unit) })
    }

    override fun enableModifier(modifier: Modifier) {
        enableModifiers(modifier)
    }


    @Synchronized
    override fun disableModifiers(vararg modifiers: Modifier) {
        modifiers.forEach {
            this.modifiers.remove(it)
        }
    }

    override fun disableModifier(modifier: Modifier) {
        disableModifiers(modifier)
    }

    @Synchronized
    override fun setModifiers(modifiers: Set<Modifier>) {
        this.modifiers.clear()
        enableModifiers(*modifiers.toTypedArray())
    }

    override fun clearModifiers() {
        this.modifiers.clear()
    }

    @Synchronized
    override fun resetColorsAndModifiers() {
        modifiers.clear()
        foregroundColor.set(TextColorFactory.DEFAULT_FOREGROUND_COLOR)
        backgroundColor.set(TextColorFactory.DEFAULT_BACKGROUND_COLOR)
    }

    @Synchronized
    override fun setStyleFrom(source: StyleSet) {
        setBackgroundColor(source.getBackgroundColor())
        setForegroundColor(source.getForegroundColor())
        setModifiers(source.getActiveModifiers().toSet())
    }

}<commit_msg>DefaultStyleSet noew takes parameters in its constructor<commit_after>package org.codetome.zircon.graphics.style

import org.codetome.zircon.Modifier
import org.codetome.zircon.TextColor
import org.codetome.zircon.builder.TextColorFactory
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicReference

open class DefaultStyleSet(
        foregroundColor: TextColor = TextColorFactory.DEFAULT_FOREGROUND_COLOR,
        backgroundColor: TextColor = TextColorFactory.DEFAULT_BACKGROUND_COLOR,
        modifiers: Set<Modifier> = setOf()
) : StyleSet {

    private var foregroundColor = AtomicReference<TextColor>(foregroundColor)
    private var backgroundColor = AtomicReference<TextColor>(backgroundColor)
    private val modifiers = ConcurrentHashMap<Modifier, Unit>()

    init {
        modifiers.forEach {
            this.modifiers.put(it, Unit)
        }
    }

    override fun getForegroundColor(): TextColor = foregroundColor.get()

    override fun getBackgroundColor(): TextColor = backgroundColor.get()

    override fun getActiveModifiers() = modifiers.keys.toSet()

    override fun setBackgroundColor(backgroundColor: TextColor) {
        this.backgroundColor.set(backgroundColor)
    }

    override fun setForegroundColor(foregroundColor: TextColor) {
        this.foregroundColor.set(foregroundColor)
    }

    override fun enableModifiers(vararg modifiers: Modifier) {
        this.modifiers.putAll(modifiers.map { Pair(it, Unit) })
    }

    override fun enableModifier(modifier: Modifier) {
        enableModifiers(modifier)
    }


    @Synchronized
    override fun disableModifiers(vararg modifiers: Modifier) {
        modifiers.forEach {
            this.modifiers.remove(it)
        }
    }

    override fun disableModifier(modifier: Modifier) {
        disableModifiers(modifier)
    }

    @Synchronized
    override fun setModifiers(modifiers: Set<Modifier>) {
        this.modifiers.clear()
        enableModifiers(*modifiers.toTypedArray())
    }

    override fun clearModifiers() {
        this.modifiers.clear()
    }

    @Synchronized
    override fun resetColorsAndModifiers() {
        modifiers.clear()
        foregroundColor.set(TextColorFactory.DEFAULT_FOREGROUND_COLOR)
        backgroundColor.set(TextColorFactory.DEFAULT_BACKGROUND_COLOR)
    }

    @Synchronized
    override fun setStyleFrom(source: StyleSet) {
        setBackgroundColor(source.getBackgroundColor())
        setForegroundColor(source.getForegroundColor())
        setModifiers(source.getActiveModifiers().toSet())
    }

}
{'fraction_non_alphanumeric': 0.08403707518022657, 'fraction_numerical': 0.0, 'mean_word_length': 3.7421875, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '4333904', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1331, 'n_words': 229}