如何查看Thrift IDL中设置的“union”属性?

时间:2016-02-29 02:42:12

标签: thrift

我有一个Thrift IDL如下:

union Container {
  1: Point point;
  2: Polygon polygon;
}

如果我有Container个对象,如何检查ContainerPoint还是Polygon?看起来它应该是一个微不足道的检查,但我无法弄清楚如何......

Container container = <some-container>
Point point = container.getPoint(); // will error if the container is a polygon
Polygon polygon = container.getPolygon(); // will error if the container is a point

1 个答案:

答案 0 :(得分:0)

使用isset标志和......