All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.pocketbyte.locolaser.config.ConfigResourceBuilder.kt Maven / Gradle / Ivy

package ru.pocketbyte.locolaser.config

import ru.pocketbyte.locolaser.config.resources.ResourcesConfig
import ru.pocketbyte.locolaser.config.resources.ResourcesSetConfig

abstract class ConfigResourceBuilder(
    val hasMainResource: Boolean = false
) {

    abstract var config: ResourcesConfig?

    private val resources = LinkedHashSet()
    private var innerConfig: ResourcesSetConfig? = null

    fun add(resourcesConfig: ResourcesConfig) {
        resources.add(resourcesConfig)
        if (resources.size == 1) {
            config = resourcesConfig
        } else if (config == null || config != innerConfig) {
            if (innerConfig == null) {
                innerConfig = ResourcesSetConfig(resources, if (hasMainResource) resourcesConfig else null)
            }
            config = innerConfig
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy