<commit_before>package org.stepic.droid.core

import org.stepic.droid.di.AppCoreComponent
import org.stepic.droid.di.course_general.CourseGeneralComponent
import org.stepic.droid.di.downloads.DownloadsComponent
import org.stepic.droid.di.login.LoginComponent
import org.stepic.droid.di.mainscreen.MainScreenComponent
import org.stepic.droid.di.routing.RoutingComponent
import org.stepic.droid.di.step.StepComponent
import timber.log.Timber

class ComponentManagerImpl(private val appCoreComponent: AppCoreComponent) : ComponentManager {

    //Downloads

    private val downloadsComponent
            by lazy {
                appCoreComponent
                        .downloadsComponentBuilder()
                        .build()
            }

    override fun downloadsComponent(): DownloadsComponent {
        return downloadsComponent
    }

//    Step

    private val stepComponentMap = HashMap<Long, StepComponent>()
    private val stepComponentCountMap = HashMap<Long, Int>()

    override fun stepComponent(stepId: Long): StepComponent {
        val count = stepComponentCountMap[stepId] ?: 0
        stepComponentCountMap[stepId] = count + 1
        val routingComponent = routingComponent() //increment routing component by invoking method
        return stepComponentMap.getOrPut(stepId) {
            routingComponent
                    .stepComponentBuilder()
                    .build()
        }
    }

    override fun releaseStepComponent(stepId: Long) {
        releaseRoutingComponent()
        val count = stepComponentCountMap.get(stepId) ?: throw IllegalStateException("release step component, which is not allocated")
        if (count == 1) {
            //it is last
            stepComponentMap.remove(stepId)
        }
        stepComponentCountMap[stepId] = count - 1
    }


//    Login

    private val loginComponentMap = HashMap<String, LoginComponent>()

    override fun releaseLoginComponent(tag: String) {
        loginComponentMap.remove(tag)
    }

    override fun loginComponent(tag: String) =<commit_msg>suppress false positive findbugs in Compoonent manager<commit_after>package org.stepic.droid.core

import org.stepic.droid.di.AppCoreComponent
import org.stepic.droid.di.course_general.CourseGeneralComponent
import org.stepic.droid.di.downloads.DownloadsComponent
import org.stepic.droid.di.login.LoginComponent
import org.stepic.droid.di.mainscreen.MainScreenComponent
import org.stepic.droid.di.routing.RoutingComponent
import org.stepic.droid.di.step.StepComponent
import org.stepic.droid.util.SuppressFBWarnings
import timber.log.Timber

class ComponentManagerImpl(private val appCoreComponent: AppCoreComponent) : ComponentManager {

    //Downloads

    private val downloadsComponent
            by lazy {
                appCoreComponent
                        .downloadsComponentBuilder()
                        .build()
            }

    override fun downloadsComponent(): DownloadsComponent {
        return downloadsComponent
    }

//    Step

    private val stepComponentMap = HashMap<Long, StepComponent>()
    private val stepComponentCountMap = HashMap<Long, Int>()

    override fun stepComponent(stepId: Long): StepComponent {
        val count = stepComponentCountMap[stepId] ?: 0
        stepComponentCountMap[stepId] = count + 1
        val routingComponent = routingComponent() //increment routing component by invoking method
        return stepComponentMap.getOrPut(stepId) {
            routingComponent
                    .stepComponentBuilder()
                    .build()
        }
    }

    @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification = "false positive")
    override fun releaseStepComponent(stepId: Long) {
        releaseRoutingComponent()
        val count: Int = stepComponentCountMap[stepId] ?: throw IllegalStateException("release step component, which is not allocated")
        if (count == 1) {
            //it is last
            stepComponentMap.remove(stepId)
        }
        stepComponentCountMap[stepId] = count - 1
    }


//    Login

    private val loginComponentMap = HashMap<String, LoginComponent>()

    override fun releaseLoginComponent(tag: String) {
        loginComponentMap.remove(tag)
    }

    override fun loginComponent(tag: String) =
{'fraction_non_alphanumeric': 0.07767441860465116, 'fraction_numerical': 0.0018604651162790699, 'mean_word_length': 2.881768953068592, '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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3749583', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1095, 'n_words': 248}