Imagine a union in thrift like:
union MyUnion {
1. bool myBool
2. i64 myLong
3. double myDouble
}(persisted='true')
What I'd like to do is something like this in Scala:
case class MyClass(
myString: String,
myUnionType: ???
)
Then, I'd like to instantiate this class like:
import ...{thriftscala => thrift}
val myClass = MyClass("cool", thrift.MyUnion.MyBool)
val myOtherClass = MyClass("wow", thrift.MyUnion.MyLong)
Note that I am not instantiating MyBool
or MyLong
, I just want to pass them as "types". I.e., I am not doing:
val myClass = MyClass("cool", thrift.MyUnion.MyBool(_))
I'm curious if there is a way to do this using the thrift-generated Scala.