I want to convert this code from java to scala :
trait ThriftPailStructure[T <: Comparable] extends PailStructure[T] {
public T deserialize(byte[] record) {
// A new data object is constructed prior to deserialization
T ret = createThriftObject();
try {
getDeserializer().deserialize((TBase <?, ?>) ret, record);
} catch (TException e) {
throw new RuntimeException(e);
}
return ret;
}
...
}
Where TBase is defined in java as :
public interface TBase <T extends org.apache.thrift.TBase<?,?>,
F extends org.apache.thrift.TFieldIdEnum> extends java.lang.Comparable<T>,
java.io.Serializable {
...
}
I know about the common conversions, but i am stuck on this line of code :
getDeserializer().deserialize((TBase <?, ?>) ret, record);
It would look as
getDeserializer().deserialize(ret.asInstanceOf[TBase[_, _]], record)
But I suspect the cast may not be necessary (in both Java and Scala), since ret
already has TBase[_, _]
as supertype.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.