matt tighe
08/30/2019, 8:58 PMinterface Entity
internal class MyClassEntity : Entity {}
interface Model
class MyClass {} : Model
interface Repository<M: Model, E: Entity> {
fun constructEntity(model: M): E
}
basically I want to expose MyClass
and implementations of Repository
, but I want some way to construct entities internally and still have them be part of a contractTash
08/31/2019, 7:15 AMinterface Entity
internal class MyClassEntity : Entity {}
interface Model
class MyClass : Model {}
interface Repository<M: Model, E: Entity> {
fun constructEntity(model: M): E
}
// Will complain. Can't expose this because its exposing internal type MyClassEntity in the
// return value of constructEntity(...)
class MyRepository: Repository<MyClass, MyClassEntity> {
override fun constructEntity(model: MyClass): MyClassEntity {
}
}
// Won't complain. No internal type is being exposed here
class MyGenericEntityRepository<E: Entity>: Repository<MyClass, E> {
override fun constructEntity(model: MyClass): E {
}
}
Regarding MyRepository
in that example ^, either MyRepository
would have to be internal
too, or MyClassEntity
would have to be exposed