natpryce
08/03/2016, 3:32 PMval property: KProperty1<Fruit,Double> = getThePropertySomehow()
val fruit : Fruit = getTheFruitSomehow()
val newStateOfFruit = property.copy(fruit, 1.0) // What do I have to do here instead of this made up API call?
voddan
08/03/2016, 4:50 PMGiven a reference to a property of a data classI was not thinking of that scenario. Is that a real use case? I mean, when one dynamically gets a reff to a property? I would use an array instead of those properties then and updated by index
voddan
08/03/2016, 4:51 PMrocketraman
08/03/2016, 8:54 PMKProperty
information, and then to execute the copy constructor for the updated fields.fellshard
08/03/2016, 9:13 PMrocketraman
08/03/2016, 10:13 PM@Updateable
property annotation specifying what can be updated and what can't and it all fits together nicely. What other paradigm(s) were you thinking of?fellshard
08/03/2016, 10:15 PMrocketraman
08/03/2016, 10:16 PMa
, b
, and c
, but it is possible to only update c
, therefore one can't use the same data class for the update.fellshard
08/03/2016, 10:17 PMrocketraman
08/03/2016, 10:18 PMfellshard
08/03/2016, 10:19 PMrocketraman
08/03/2016, 10:19 PMKProperty
and copy constructorfellshard
08/04/2016, 1:07 AMvoddan
08/04/2016, 8:09 AMvoddan
08/04/2016, 8:11 AMvoddan
08/04/2016, 8:12 AMvoddan
08/04/2016, 8:14 AMvoddan
08/04/2016, 8:15 AMrocketraman
08/04/2016, 1:28 PMMap
). I like the idea of using reflection only once on initialization -- that sounds promising. Thinking about implementation: each type could use reflection to create a lambda for each of its properties to (recursively) convert from the JSON value to the property type. Updates would then use the pre-created lambda rather than reflection for the type conversion. Then each type would call its own copy
function with the result of calling every property update lambda and the update Map
. Is that what you had in mind?rocketraman
08/04/2016, 1:29 PMcedric
08/04/2016, 1:30 PMrocketraman
08/04/2016, 1:35 PM(Map<String, Any>) -> T
. I want to do (Map>String, Any>, T) -> T
where the T input provides the properties that are not present in the Map.rocketraman
08/04/2016, 1:38 PMMap
... and be able to do things like updateMap.onChanged(T, T::someField) { ... }
.. and a few other things.voddan
08/04/2016, 2:44 PMvoddan
08/04/2016, 2:45 PMvoddan
08/04/2016, 2:46 PMvoddan
08/04/2016, 2:47 PMrocketraman
08/04/2016, 2:48 PMvoddan
08/04/2016, 2:59 PM