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

com.skillw.pouvoir.api.feature.database.ContainerHolder.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.pouvoir.api.feature.database

import com.skillw.pouvoir.api.plugin.map.LowerKeyMap

/**
 * @className ContainerHolder
 *
 * 容器持有者,负责管理一种特定类型的容器
 *
 * 包括此类型容器的创建 销毁
 *
 * @author Glom
 * @date 2023/1/20 17:26 Copyright 2024 Glom.
 */
abstract class ContainerHolder : LowerKeyMap() {
    var userContainerSyncTime: Long = 360000

    /**
     * Create table
     *
     * @param tableName
     * @return
     */
    protected abstract fun createContainer(tableName: String, userKey: Boolean = false): C
    fun container(tableName: String, userKey: Boolean = false): C {
        return computeIfAbsent(tableName) { this.createContainer(tableName, userKey).apply { onEnable() } }
    }

    protected abstract fun disconnect()
    fun disconnectAll() {
        values.forEach(BaseContainer::onDisable)
        disconnect()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy