In our Java program we receive an Erlang tuple and extract it in OtpErlangTuple. One of the elements of the tuple should be a string but can be empty. When it is empty, its value is [] – the Erlang way of representing an empty list.
My question is how to check if the element is empty so to cast it to a OtpErlangString?
As it is now (OtpErlangString)messageData.elementAt(2), the following exception is raised:
class java.lang.ClassCastException
, 'com.ericsson.otp.erlang.OtpErlangList cannot be cast to com.ericsson.otp.erla
ng.OtpErlangString'
Thanks,
Martin
Check if it is equal to
[]and do a specific operation if so:You can handle this case the way you want depending on how you then manage those
OtpErlangString