Lost Illusion
07/03/2020, 8:40 PMaraqnid
07/03/2020, 8:56 PMDominaezzz
07/03/2020, 10:10 PMobject
or an instance of a class
? If you mean the former ... then it's not really possible (at least conceptually speaking).Lost Illusion
07/03/2020, 10:11 PMfun <T> Foo<T>.values(vararg values: KProperty1<T, *>) { ... }
In the Foo class it has an instance of T, and could get the values of the kproperties. With this method I know the values are from T and I'm happy with this. However if I use a KProperty0<*> e.g., from an object, I lose the guarantee that the property is from T.Lost Illusion
07/03/2020, 10:12 PMDominaezzz
07/03/2020, 10:19 PMobject UnknownName : T { ... }
.Dominaezzz
07/03/2020, 10:20 PMLost Illusion
07/03/2020, 10:26 PMclass SelectOp<D>(val entity: Entity<D>): Operation
class SelectValuesOp<D>(val entity: Entity<D>, val values: List<Column<*>>): Operation
fun <D> SelectOp<D>.values(vararg values: KProperty1<Entity<D>, Column<*>>) {
...
}
//user code
object SomeEntity: Entity<SomeEntityData>() {
val foo = Column<Int>()
}
data class SomeEntityData(val foo: Int)
in this situation, id like the user to be able to do
SelectOp(SomeEntity).values(SomeEntity::foo)
how would i go about using an interface/class to specify properties that are specified by the user?