mkrause / gx

Rx bindings for Google Drive Realtime API (Gx)
MIT License
1 stars 1 forks source link

Root map appears to be of type CollaborativeMap<String> #25

Closed yholkamp closed 11 years ago

yholkamp commented 11 years ago

In commit 10f8773 I've extended the demo app slightly to also access the root map that is now being built. I noticed though that when doing so using

CollaborativeObject foo = root.get(key);

The following exception is thrown: Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to gx.realtime.CollaborativeObject

This makes me suspect that the rootmap is internally instantiated as a CollaborativeMap<String> rather than the expected CollaborativeMap<CollaborativeObject>, as defined by Model#getRoot.

When I change the signature of the root map to CollaborativeMap<String> it appears to behave correctly but I'm thinking this is not the proper behavior. @Rdebokx or @mkrause, could either of you shine some light on this?

rdebokx commented 11 years ago

Hmm, sounds like a bug indeed. But as I was thinking about this, I think the type of CollabMap should be Object (so CollabMap) as in theory the document / model can contain any object. The thing is, however, that only CollaborativeObjects should be synced. @mkrause, what is your opinion on this?

Just checking if we're on one line before continuing to fix this bug...

mkrause commented 11 years ago

A CollaborativeMap can contain any kind of object (strings, collaborative objects, or just arbitrary objects). So I think the logical approach would be to get rid of the generic parameter and just use CollaborativeMap with a Map<String, Object>.

mkrause commented 11 years ago

I removed the generic parameter. This has the unfortunate consequence that we need a bunch of type casts wherever we want to use an object from a map.