Page 1 of 1

Device virtualCapabilities Map is very loose

Posted: Thu Aug 18, 2016 5:45 pm
by trickydee
The virtualCapabilities on the Scala Device API seems to be very loose

Code: Select all

device.getVirtualCapabilities.toMap[Any,Any]
While I can understand having Any as the value type (although I think it's better if this can be a sealed set of types and not allow null) I think all keys in principle are Strings.

Re: Device virtualCapabilities Map is very loose

Posted: Thu Aug 18, 2016 5:49 pm
by trickydee
Additionally, wasn't this API Map[String,String] before?

Re: Device virtualCapabilities Map is very loose

Posted: Fri Aug 19, 2016 10:57 am
by aaronp
Hi Stephen,

Thank you for letting us know. The change from [string,string] to [any,any] appear to have been made in order to meet compliance with the release of Scala 2.12-M4. I will discuss this with the engineers who worked on this project and will follow up with you when I have a more in-depth answer.

Thanks,

Aaron

Re: Device virtualCapabilities Map is very loose

Posted: Sat Aug 20, 2016 10:09 am
by trickydee
Thank you,
To highlight one thing for example, it's no longer possible to simply take a capabilities map and append it the virtual capabilities capabilities ++ virtualCapabilities without getting an Map[Any,Any] which breaks our current code.
As a workaround we're mapping over the values and just casting asInstanceOf which would throw exceptions if things don't match up

Code: Select all

device.capabilities ++ device.virtualCapabilities.map { case (k, v) => (k.asInstanceOf[String], v.asInstanceOf[String]) }
In alternatives using collect and pattern matching is an option but that could fail silently.