可选关键字是正确的选择.
要测试是否设置了特定的可选字段,请使用isset标志:
struct MyBean {
1: i32 IntValue
}
给
public class MyBean implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
// ... lots of other code omitted ...
// isset id assignments
private static final int __INTVALUE_ISSET_ID = 0;
private byte __isset_bitfield = 0;
// ... lots of other code omitted ...
/** Returns true if field IntValue is set (has been assigned a value) and false otherwise */
public boolean isSetIntValue() {
return EncodingUtils.testBit(__isset_bitfield, __INTVALUE_ISSET_ID);
}
public void setIntValueIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __INTVALUE_ISSET_ID, value);
}
// ... even more code omitted ...
}