Add EntityCollection
This commit is contained in:
@@ -6,7 +6,7 @@ interface EntityI<T> {
|
||||
var id: T
|
||||
}
|
||||
abstract class Entity<T>(override var id: T) : EntityI<T>
|
||||
abstract class UuidEntity(override var id: UUID = UUID.randomUUID()) : Entity<UUID>(id) {}
|
||||
abstract class UuidEntity(override var id: UUID = UUID.randomUUID()) : Entity<UUID>(id)
|
||||
abstract class IdEntity(override var id: Int) : Entity<Int>(id)
|
||||
|
||||
interface EntityVersioning<T> {
|
||||
|
||||
13
src/main/kotlin/fr/postgresjson/entity/EntityCollection.kt
Normal file
13
src/main/kotlin/fr/postgresjson/entity/EntityCollection.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package fr.postgresjson.entity
|
||||
|
||||
class EntityCollection<T, E : EntityI<T>> {
|
||||
var collection: MutableMap<T, E> = mutableMapOf()
|
||||
|
||||
fun get(id: T): E? {
|
||||
return collection[id]
|
||||
}
|
||||
|
||||
fun set(entity: E) {
|
||||
collection.set(entity.id, entity)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user