refactoring: cleanup and reformat
This commit is contained in:
@@ -5,17 +5,17 @@ import kotlin.reflect.KClass
|
||||
class EntitiesCollections {
|
||||
private val collections: MutableMap<KClass<*>, EntityCollection<Any, EntityI<Any?>>> = mutableMapOf()
|
||||
|
||||
fun <I, R : EntityI<I?>> get(id: I, className: KClass<R>): R? {
|
||||
fun <I, R: EntityI<I?>> get(id: I, className: KClass<R>): R? {
|
||||
val collection = collections[className]
|
||||
val entity = collection?.get(id!!)
|
||||
return entity as R?
|
||||
}
|
||||
|
||||
inline fun <I, reified R : EntityI<I?>> get(id: I): R? {
|
||||
inline fun <I, reified R: EntityI<I?>> get(id: I): R? {
|
||||
return get(id, R::class)
|
||||
}
|
||||
|
||||
fun <I, R : EntityI<out I?>> set(entity: R): EntitiesCollections {
|
||||
fun <I, R: EntityI<out I?>> set(entity: R): EntitiesCollections {
|
||||
if (collections[entity.className] == null) {
|
||||
collections[entity.className] = EntityCollection()
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class EntitiesCollections {
|
||||
return this
|
||||
}
|
||||
|
||||
class EntityCollection<T, E : EntityI<T?>> {
|
||||
class EntityCollection<T, E: EntityI<T?>> {
|
||||
private var collection: MutableMap<T, E> = mutableMapOf()
|
||||
|
||||
fun get(id: T): E? {
|
||||
|
||||
Reference in New Issue
Block a user