Benoit Duffez
06/04/2018, 11:41 AMEntity
) that is inherited from two children, and they need to change the type of one property.
This is because these classes are used to retrieve data from a backend (in serialized in JSON, deserialized with Gson). In fact, the server uses the same object for downlink (e.g. GET /x/y/z.json
returns a list of Entity
) and uplink (POST /abc
with one Entity
in the body), but one of the fields has not the same type whether it's uplink or downlink (bummer... I can't change the server code...).
So in Entity
i have declared the property as open var stuff: Any? = null
, and I expected the EntityUplink
for example to have override var stuff: ActualType? = null
but the compiler refuses that.
Is that a violation of the language (e.g. not possible/not designed to do that) or am I missing something?hho
06/04/2018, 11:53 AMEntity
objects, it expects to be able to put Any
type in the stuff
field. You can't have a subclass which restricts that.Benoit Duffez
06/04/2018, 12:11 PMBenoit Duffez
06/04/2018, 12:12 PMBenoit Duffez
06/04/2018, 12:13 PMAny
but then I would need a workaround in the database code so that the DAO knows how to extract this Any
from the database.Benoit Duffez
06/04/2018, 12:13 PM