27 lines
668 B
Kotlin
27 lines
668 B
Kotlin
package me.theentropyshard.kvinchik.database.impl
|
|
|
|
import me.theentropyshard.kvinchik.database.Database
|
|
import me.theentropyshard.kvinchik.entity.KvinchikUser
|
|
import me.theentropyshard.kvinchik.util.search
|
|
|
|
class RuntimeDatabase : Database {
|
|
private val users: MutableList<KvinchikUser>
|
|
|
|
init {
|
|
this.users = ArrayList()
|
|
}
|
|
|
|
override fun userExists(id: Long): Boolean = users.search { it.id == id } != null
|
|
|
|
override fun saveUser(user: KvinchikUser) {
|
|
if (this.userExists(user.id)) {
|
|
return
|
|
}
|
|
|
|
this.users.add(user)
|
|
}
|
|
|
|
override fun getUsers(): List<KvinchikUser> {
|
|
return this.users
|
|
}
|
|
}
|