dev.krud.crudframework.test.TestCrudDaoImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crud-framework-test Show documentation
Show all versions of crud-framework-test Show documentation
Spring-powered Crud Framework
The newest version!
package dev.krud.crudframework.test
import dev.krud.crudframework.crud.handler.CrudDao
import dev.krud.crudframework.model.BaseCrudEntity
import dev.krud.crudframework.modelfilter.DynamicModelFilter
import dev.krud.crudframework.util.filtersMatch
import java.io.Serializable
class TestCrudDaoImpl : CrudDao {
val entities = mutableListOf>()
override fun , E : DynamicModelFilter> index(filter: E, clazz: Class?): MutableList {
return entities.filter {
filter.filtersMatch(it)
} as MutableList
}
override fun , E : DynamicModelFilter> indexCount(filter: E, clazz: Class?): Long {
return entities.filter {
filter.filtersMatch(it)
}.size.toLong()
}
override fun > hardDeleteById(id: ID, clazz: Class?) {
entities.removeIf {
it.id == id
}
}
override fun > saveOrUpdate(entity: Entity): Entity {
entities.removeIf {
it.id == entity.id
}
entities.add(entity)
return entity
}
override fun > saveOrUpdate(entities: List): List {
entities.forEach {
this.entities.removeIf { entity ->
entity.id == it.id
}
this.entities.add(it)
}
return entities
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy