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

kr.summitsystems.springbukkit.view.ViewModelStore.kt Maven / Gradle / Ivy

There is a newer version: 0.0.9-beta2
Show newest version
package kr.summitsystems.springbukkit.view

class ViewModelStore(
    private val map: MutableMap = mutableMapOf()
) : MutableMap by map {
    override fun put(key: String, value: ViewModel): ViewModel? {
        val oldViewModel = map.put(key, value)
        oldViewModel?.dispose()
        return oldViewModel
    }

    fun put(viewModel: ViewModel): ViewModel? {
        return put(viewModel::class.java.name, viewModel)
    }

    override fun clear() {
        for (viewModel in values) {
            viewModel.dispose()
        }
        map.clear()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy